/* Aerogramme — see the direction contract comment at the top of <body> and DESIGN.md. */

@font-face { font-family: 'Anuphan'; src: url('/static/fonts/anuphan-thai-wght-normal.woff2') format('woff2'); font-weight: 100 700; font-display: swap; unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Anuphan'; src: url('/static/fonts/anuphan-latin-wght-normal.woff2') format('woff2'); font-weight: 100 700; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --paper: #d9e6f2;        /* aerogramme ground */
  --paper-deep: #c6d7e8;
  --sheet: #f7f9fb;        /* the letter */
  --ink: #1d2a4d;
  --ink-soft: #3b4a6b;     /* secondary text, tinted from the ink */
  --ink-faint: #5d6b89;
  --fold: rgba(29, 42, 77, 0.16);
  --action: #1f5fa8;       /* airmail blue: the only pressable colour */
  --action-deep: #164a87;
  --action-wash: #e3edf8;
  --airmail: #c8352e;      /* open rounds, self scores, errors */
  --airmail-deep: #a92a24;
  --airmail-wash: #f8e8e6;
  --radius: 6px;
  --measure: 40rem;
  color-scheme: light;
  accent-color: var(--action);
  caret-color: var(--action);
  scrollbar-color: var(--ink-faint) var(--paper);
}

* { box-sizing: border-box; }
::selection { background: var(--action); color: #fff; }

html { background: var(--paper); }
body {
  margin: 0;
  color: var(--ink);
  font: 400 1.0625rem/1.75 'Anuphan', system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--action); text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
a:hover { color: var(--action-deep); text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--action); outline-offset: 2px; border-radius: 2px; }

h1 { font-size: clamp(1.5rem, 1.2rem + 1.5vw, 2rem); line-height: 1.3; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 0.5rem; text-wrap: balance; }
h2 { font-size: 1.2rem; line-height: 1.4; font-weight: 700; margin: 2.5rem 0 0.75rem; text-wrap: balance; }
h3 { font-size: 1.05rem; line-height: 1.45; font-weight: 600; margin: 0 0 0.5rem; }
p { margin: 0 0 0.75rem; }
code { font-size: 0.9em; }
.meta { color: var(--ink-soft); font-size: 0.9rem; }
.empty { color: var(--ink-soft); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
picture { display: contents; }
picture > source { display: none; } /* the UA leaves <source> displayable: in a grid it became an empty item */

/* ---------- The sheet: one letter on the aerogramme ground ---------- */
.page, .sheet {
  max-width: var(--measure);
  margin: 1rem auto 3rem;
  padding: 1.75rem 1.25rem 2.25rem;
  background: var(--sheet);
  position: relative;
  box-shadow: 0 1px 2px rgba(29, 42, 77, 0.08), 0 12px 32px -18px rgba(29, 42, 77, 0.35);
}
/* Perforated bottom edge, like a stamp sheet. */
.page::after, .sheet::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: -6px; height: 12px;
  background: radial-gradient(circle at 7px 6px, var(--paper) 4px, transparent 4.5px) 0 0 / 14px 12px repeat-x;
}
@media (min-width: 40rem) {
  .page, .sheet { margin-top: 2.5rem; padding: 2.5rem 2.75rem 3rem; }
}

.sheet-head { padding-bottom: 1.25rem; }
.intro { white-space: pre-line; color: var(--ink-soft); }
.privacy {
  display: flex; gap: 0.75rem; align-items: flex-start;
  font-size: 1rem; color: var(--ink);   /* the promise respondents need most: body size, full ink */
  border: 1px solid var(--fold); border-radius: var(--radius);
  padding: 0.75rem 0.9rem; margin-top: 1rem;
  background: #fff;
}
/* A miniature cancellation postmark beside the privacy promise: ring plus wave lines, never a control. */
.privacy-mark { flex: none; width: 3.25rem; height: auto; margin-top: 0.15rem; fill: none; stroke: var(--action); stroke-width: 1.8; stroke-linecap: round; transform: rotate(-8deg); }
@media (max-width: 30rem) {
  .privacy { gap: 0.5rem; padding: 0.6rem 0.7rem; margin-top: 0.75rem; }
  .privacy-mark { width: 2rem; }
}

/* Fold line: a crisp crease with a faint shade under it. */
.question {
  border: 0; margin: 0; min-width: 0;
  padding: 1.5rem 0 1.25rem;
  border-top: 1px solid var(--fold);
  background: linear-gradient(to bottom, rgba(29, 42, 77, 0.05), transparent 0.6rem) top / 100% 0.6rem no-repeat;
}
.question legend { font-weight: 600; padding: 0; float: left; width: 100%; margin-bottom: 0.25rem; }
.question > label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
.question legend + * { clear: both; }
.q-num { display: inline-block; min-width: 1.6em; color: var(--ink-faint); font-variant-numeric: tabular-nums; font-weight: 700; }
.q-help { color: var(--ink-soft); font-size: 0.95rem; margin: 0 0 0.9rem; clear: both; }

/* Rating: an icon ladder. Five native radios; each key is a tile whose icon grows with the step.
 * Picking step n lights icons 1…n and shows that step's word in the readout. Values stay 1–5 / na.
 * Themes swap the art through --scale-icon-1…5 (absolute /static/ paths: url() in a custom property
 * is resolved where it is used, not where it is declared). */
:root {
  --scale-icon-1: url('/static/img/scale/aero-1.svg');
  --scale-icon-2: url('/static/img/scale/aero-2.svg');
  --scale-icon-3: url('/static/img/scale/aero-3.svg');
  --scale-icon-4: url('/static/img/scale/aero-4.svg');
  --scale-icon-5: url('/static/img/scale/aero-5.svg');
  --scale-lit: var(--action-wash);   /* tile fill of a lit step */
}
.scale { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.4rem; clear: both; max-width: 26rem; } /* wide tiles would dwarf the icons */
.scale-readout { max-width: 26rem; }
.scale-key { position: relative; display: block; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.scale-key input, .scale-na input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.scale-key:nth-child(1) { --i: 1; --icon: var(--scale-icon-1); }
.scale-key:nth-child(2) { --i: 2; --icon: var(--scale-icon-2); }
.scale-key:nth-child(3) { --i: 3; --icon: var(--scale-icon-3); }
.scale-key:nth-child(4) { --i: 4; --icon: var(--scale-icon-4); }
.scale-key:nth-child(5) { --i: 5; --icon: var(--scale-icon-5); }
.scale-icon {
  display: flex; align-items: center; justify-content: center;
  height: 4rem;
  border: 1.5px solid var(--control-border, var(--ink-faint)); border-radius: var(--radius); background: #fff;
  transition: background-color 160ms ease-out, border-color 160ms ease-out;
}
.scale-icon::before {
  content: ''; display: block;
  width: calc(1.55rem + var(--i) * 0.27rem); height: calc(1.55rem + var(--i) * 0.27rem);   /* ~65% → 100%, centred; the largest still fits its hop (112%) inside the tile */
  max-width: 88%;
  background: var(--icon) center / contain no-repeat;
  filter: grayscale(1) brightness(0.7); opacity: 0.45;   /* darkened so pale art (a sun) still reads when unlit */
  transition: filter 160ms ease-out, opacity 160ms ease-out, transform 160ms ease-out;
}
/* The step number sits small in the tile's corner, so the ladder's order reads before anything is picked. */
.scale-icon { position: relative; }
.scale-num { position: absolute; right: 0.35rem; bottom: 0.15rem; font-size: 0.75rem; font-weight: 600; line-height: 1; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.scale-key:hover .scale-icon { border-color: var(--action); }
.scale-key input:focus-visible ~ .scale-icon { outline: 3px solid var(--action); outline-offset: 2px; }
/* Lit: every step up to the checked one. */
.scale:has(input[value='1']:checked) .scale-key:nth-child(-n+1) .scale-icon,
.scale:has(input[value='2']:checked) .scale-key:nth-child(-n+2) .scale-icon,
.scale:has(input[value='3']:checked) .scale-key:nth-child(-n+3) .scale-icon,
.scale:has(input[value='4']:checked) .scale-key:nth-child(-n+4) .scale-icon,
.scale:has(input[value='5']:checked) .scale-key:nth-child(-n+5) .scale-icon { background: var(--scale-lit); border-color: var(--action); }
.scale:has(input[value='1']:checked) .scale-key:nth-child(-n+1) .scale-icon::before,
.scale:has(input[value='2']:checked) .scale-key:nth-child(-n+2) .scale-icon::before,
.scale:has(input[value='3']:checked) .scale-key:nth-child(-n+3) .scale-icon::before,
.scale:has(input[value='4']:checked) .scale-key:nth-child(-n+4) .scale-icon::before,
.scale:has(input[value='5']:checked) .scale-key:nth-child(-n+5) .scale-icon::before { filter: none; opacity: 1; }
/* The chosen step is the one that is pressed: solid border, a small hop. */
.scale-key input:checked ~ .scale-icon { border-width: 2.5px; box-shadow: 0 3px 0 -1px var(--action); }
.scale-key input:checked ~ .scale-icon::before { animation: scale-hop 320ms cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes scale-hop { 0% { transform: scale(0.7); } 60% { transform: scale(1.12); } 100% { transform: none; } }
/* Hover previews the ladder up to the pointer (pointer devices only). */
@media (hover: hover) {
  .scale:not(:has(input:checked)) .scale-key:hover .scale-icon::before,
  .scale:not(:has(input:checked)) .scale-key:has(~ .scale-key:hover) .scale-icon::before { filter: none; opacity: 0.75; }
}
.scale-readout { margin: 0.4rem 0 0; min-height: 1.6em; text-align: center; font-size: 0.85rem; color: var(--ink-soft); }
.scale-readout span { display: none; }
.scale-readout [data-v='0'] { display: inline; }
.question-rating:has(.scale input:checked) .scale-readout [data-v='0'] { display: none; }
.question-rating:has(.scale input[value='1']:checked) .scale-readout [data-v='1'],
.question-rating:has(.scale input[value='2']:checked) .scale-readout [data-v='2'],
.question-rating:has(.scale input[value='3']:checked) .scale-readout [data-v='3'],
.question-rating:has(.scale input[value='4']:checked) .scale-readout [data-v='4'],
.question-rating:has(.scale input[value='5']:checked) .scale-readout [data-v='5'] {
  display: inline-block; font-size: 1rem; font-weight: 700; color: var(--action-deep);
  padding: 0 0.75rem; border-bottom: 2px solid var(--action);
}
.question-rating:has(.scale-na input:checked) .scale-readout { visibility: hidden; }
@media (forced-colors: active) {
  .scale-icon::before { display: none; }
  .scale-num { position: static; font-size: 1rem; color: inherit; }
  .scale-icon { align-items: center; padding: 0; }
  .scale-key input:checked ~ .scale-icon { border-width: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  .scale-icon, .scale-icon::before { transition: none; }
  .scale-key input:checked ~ .scale-icon::before { animation: none; }
}
.scale-na-row { margin-top: 0.6rem; }
.scale-na {
  position: relative; display: inline-flex; align-items: center; min-height: 2.75rem;
  padding: 0.35rem 0.9rem; border: 1.5px dashed var(--control-border, var(--ink-faint)); border-radius: var(--radius);
  font-size: 0.92rem; color: var(--ink-soft); cursor: pointer; background: #fff;
}
.scale-na:hover { border-color: var(--action); }
/* "Not sure" is marked by pattern, not only by colour. */
.scale-na:has(input:checked) {
  border-style: solid; border-color: var(--action); color: var(--ink); font-weight: 600;
  background: repeating-linear-gradient(135deg, var(--action-wash) 0 6px, #fff 6px 12px);
}
.scale-na:has(input:focus-visible) { outline: 3px solid var(--action); outline-offset: 2px; }
body .scale-na:has(input:checked) { background: repeating-linear-gradient(135deg, var(--action-wash) 0 6px, #fff 6px 12px); }

textarea, input[type='text'], input[type='email'], input[type='password'], input[type='number'], select {
  width: 100%; font: inherit; color: var(--ink); background: #fff;
  border: 1.5px solid var(--control-border, var(--ink-faint)); border-radius: var(--radius); padding: 0.6rem 0.75rem;
}
textarea { resize: vertical; min-height: 5.5rem; line-height: 1.65; }
textarea:hover, input[type='text']:hover, input[type='email']:hover, input[type='password']:hover, select:hover { border-color: var(--ink-soft); }
textarea:focus-visible, input[type='text']:focus-visible, input[type='email']:focus-visible, input[type='password']:focus-visible, select:focus-visible { outline: 3px solid var(--action); outline-offset: 1px; border-color: var(--action); }
::placeholder { color: var(--ink-faint); }
.comment { display: block; margin-top: 1rem; font-weight: 400; font-size: 0.92rem; color: var(--ink-soft); }
.comment textarea { margin-top: 0.35rem; }
details.comment > summary { cursor: pointer; color: var(--action); min-height: 2.75rem; display: flex; align-items: center; list-style: none; }
details.comment > summary::-webkit-details-marker { display: none; }

/* Errors */
.question-rating.has-error .scale-icon, .question-rating.has-error .scale-na, .question-text.has-error textarea { border-color: var(--airmail); }
.field-error { color: var(--airmail-deep); font-weight: 600; font-size: 0.92rem; margin: 0.5rem 0 0; }
.form-errors {
  background: var(--airmail-wash); border: 1px solid var(--airmail); border-radius: var(--radius);
  padding: 0.9rem 1rem; margin: 0 0 1.25rem; color: var(--ink);
}
.form-errors p { font-weight: 700; color: var(--airmail-deep); margin-bottom: 0.35rem; }
.form-errors ul { margin: 0; padding-left: 1.2rem; }
.ed-todo p, .ed-stale p { margin: 0 0 0.35rem; }
.ed-issues.ed-todo a { color: var(--action); }
.ed-todo ul, .ed-stale ul { margin: 0; padding-left: 1.2rem; }
.ed-stale li { white-space: pre-line; }

/* Buttons */
button, .button {
  font: inherit; font-weight: 600; line-height: 1.4;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 2.75rem; padding: 0.6rem 1.2rem;
  background: var(--action); color: #fff; border: 1.5px solid var(--action); border-radius: var(--radius);
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
button:hover, .button:hover { background: var(--action-deep); border-color: var(--action-deep); color: #fff; }
button:disabled, button[aria-disabled='true'], button[aria-disabled='true']:hover { background: var(--paper-deep); border-color: var(--paper-deep); color: var(--ink-soft); cursor: not-allowed; }
button.secondary { background: transparent; color: var(--action); }
button.secondary:hover { background: var(--action-wash); color: var(--action-deep); }
.button.secondary { background: transparent; color: var(--action); }
.button.secondary:hover { background: var(--action-wash); color: var(--action-deep); }
button.danger { background: var(--airmail); border-color: var(--airmail); }
button.danger:hover { background: var(--airmail-deep); border-color: var(--airmail-deep); }
.submit { width: 100%; margin-top: 1.5rem; min-height: 3.25rem; font-size: 1.05rem; }

.progress {
  position: sticky; bottom: 0; z-index: 1;
  max-width: var(--measure); margin: 0 auto; padding: 0.5rem 1.25rem;
  background: var(--paper); color: var(--ink-soft); font-size: 0.9rem; font-variant-numeric: tabular-nums;
  pointer-events: none; /* never blocks the submit button underneath */
}
.progress:empty { display: none; }

.notice {
  background: #fff; border: 1px solid var(--fold); border-radius: var(--radius);
  padding: 0.75rem 1rem; color: var(--ink-soft);
}
.warning {
  background: var(--airmail-wash); border: 1px solid var(--airmail); border-radius: var(--radius);
  padding: 0.75rem 1rem; margin-bottom: 1rem;
}
.warning ul { margin: 0.25rem 0 0; padding-left: 1.2rem; }

/* ---------- Postmark ---------- */
.postmark { display: flex; justify-content: center; margin: 2rem 0 1rem; }
.postmark-ring {
  display: grid; place-items: center; align-content: center; gap: 0.1rem;
  width: 11rem; height: 11rem; border-radius: 50%; text-align: center;
  color: var(--action); border: 3px solid var(--action);
  box-shadow: inset 0 0 0 5px var(--sheet), inset 0 0 0 6.5px var(--action);
  transform: rotate(-8deg); padding: 1.5rem;
}
.postmark-title { font-weight: 700; font-size: 0.95rem; line-height: 1.3; max-width: 8rem; overflow-wrap: anywhere; }
.postmark-date { font-weight: 700; font-size: 1.15rem; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.postmark-foot { font-size: 0.75rem; letter-spacing: 0.08em; }
/* The one authored motion: the postmark lands once. */
.postmark-drop .postmark-ring { animation: stamp 560ms cubic-bezier(0.16, 1, 0.3, 1) both; }
/* Results: the small postmark stamps down the first time a round's results are opened in this browser (results.js adds .is-revealing).
   results.js is deferred, so the ring is already painted when the class lands: it starts visible and lifted, never from opacity 0. */
@media (prefers-reduced-motion: no-preference) {
  .is-revealing .postmark-small .postmark-ring { animation: restamp 560ms cubic-bezier(0.16, 1, 0.3, 1) both; }
}
@keyframes stamp {
  from { transform: rotate(-16deg) scale(1.5); opacity: 0; filter: blur(3px); }
  to { transform: rotate(-8deg) scale(1); opacity: 1; filter: blur(0); }
}
@keyframes restamp {
  from { transform: rotate(-8deg) scale(1.25); opacity: 1; }
  to { transform: rotate(-8deg) scale(1); opacity: 1; }
}
.thanks { text-align: center; }
/* Owner-supplied cheering cartoon (transparent PNG); decorative, so alt="". */
.thanks-art { display: block; width: auto; height: auto; max-width: min(12rem, 55vw); max-height: min(22rem, 48vh); margin: 0 auto 1.25rem; } /* tall art (a postbox) is capped by height */
.intro-art { display: block; width: auto; height: auto; max-width: min(12rem, 55vw); max-height: 12rem; margin: 0 auto 0.75rem; }
@media (max-width: 30rem) { .intro-art { max-height: 8rem; width: auto; } }

/* Sealed bundle on locked results */
.sealed {
  display: grid; place-items: center; align-content: center;
  width: 9rem; height: 9rem; margin: 1.5rem auto; border-radius: 50%;
  border: 3px double var(--action); color: var(--action); transform: rotate(-6deg);
}
.sealed-count { font-size: 2.5rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.sealed-label { font-size: 0.8rem; }

/* ---------- Admin ---------- */
.account-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 0.4rem 1rem;
  max-width: var(--measure); margin: 0 auto; padding: 0.75rem 0.25rem 0; font-size: 0.9rem; color: var(--ink-soft);
}
/* The signed-in account: a person mark in a pill; a long name ends in an ellipsis (the full name is in the title). */
.account-name {
  display: inline-flex; align-items: center; gap: 0.35rem; min-width: 0; max-width: min(15rem, 100%);
  padding: 0.15rem 0.7rem 0.15rem 0.45rem; border: 1px solid var(--fold); border-radius: 999px; background: var(--sheet);
  font-weight: 600; color: var(--ink); text-decoration: none; min-height: 2.75rem; box-sizing: border-box;
}
.account-name:hover { border-color: var(--action); color: var(--action-deep); }
.account-bar > a:not(.account-brand):not(.account-name) { display: inline-flex; align-items: center; min-height: 2.75rem; }
.account-icon { flex: none; }
.account-name-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 30rem) { .account-bar { gap: 0.4rem 0.6rem; } .account-brand { font-size: 0.95rem; } .account-name { max-width: 7.5rem; } }
@media (max-width: 27rem) { .account-name { max-width: 5rem; } } /* 360-430px: brand + PREVIEW + ชุดคำถาม + name stay on one row */
@media (max-width: 22rem) { .account-bar { font-size: 0.85rem; gap: 0.4rem; } .account-brand { font-size: 0.9rem; } .account-name { max-width: 4.5rem; } .preview-badge { padding: 0 0.35rem; letter-spacing: 0.04em; } }
/* Preview deploys only (PREVIEW_PASSWORD_LOGIN): never mistaken for production. */
.preview-badge { display: inline-block; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; line-height: 1.6; padding: 0 0.5rem; border-radius: 4px; background: transparent; color: var(--airmail-deep); border: 1px solid var(--airmail); } /* outline: red fill is reserved for deletes */
.account-bar .preview-badge { margin-right: auto; }
/* With the badge, it (not the brand) takes the free space, so brand and badge stay together. */
.account-bar .account-brand:has(+ .preview-badge) { margin-right: 0; }

/* ---------- Login ---------- */
.login-note { font-size: 0.9rem; color: var(--ink-soft); }
.login-note a { display: inline-block; padding-block: 0.2rem; }
.preview-banner { padding: 0.6rem 0.8rem; border: 2px dashed var(--airmail); border-radius: var(--radius); color: var(--airmail-deep); font-weight: 600; }
.preview-login { margin: 1.5rem 0; padding-top: 1rem; border-top: 1px dashed var(--fold); }
.preview-login h2 { font-size: 1.1rem; }
/* One column: label, field, label, field, hint, button. Not the section>form flex row used elsewhere. */
.preview-login > .preview-login-form { display: grid; gap: 0.35rem; max-width: 26rem; margin: 1rem 0 0; }
.preview-login-form label { margin-top: 0.5rem; }
.preview-login-form label:first-child { margin-top: 0; }
.preview-login-form .field-hint { margin: 0; }
.preview-login-form .form-errors { margin: 0.5rem 0 0; }
.preview-login-form button { justify-self: start; margin-top: 0.75rem; }
@media (max-width: 30rem) { .preview-login-form button { justify-self: stretch; } }
.crumbs { font-size: 0.9rem; margin-bottom: 1rem; color: var(--ink-soft); }
.crumbs a, .site-footer-links a { display: inline-block; padding-block: 0.6rem; }
.badge { display: inline-block; vertical-align: middle; font-size: 0.78rem; font-weight: 600; line-height: 1.6; border-radius: 999px; padding: 0 0.6rem; border: 1.5px solid currentColor; }
.badge-open { color: var(--airmail-deep); }
.badge-draft { color: var(--ink-faint); border-style: dashed; }
.badge-closed { color: var(--action); border-style: double; border-width: 3px; line-height: 1.45; } /* postmark: a double ring */
h1 .badge { margin-left: 0.35rem; }
/* A round title is user text (often a name): balance halved it mid-word and left the right side empty. */
h1.round-title { text-wrap: pretty; }

.rounds { list-style: none; padding: 0; margin: 0.75rem 0 0; }
.rounds li {
  padding: 1rem 0; border-top: 1px solid var(--fold);
  background: linear-gradient(to bottom, rgba(29, 42, 77, 0.05), transparent 0.6rem) top / 100% 0.6rem no-repeat;
}
.rounds li > a { display: inline-block; padding: 0.3rem 0; font-weight: 700; font-size: 1.05rem; }
.rounds .meta { display: block; }
.rounds .meta a { display: inline-block; padding-block: 0.2rem; }
.round-quick { display: block; margin-top: 0.5rem; }
.round-quick button, .round-quick .button { padding: 0.35rem 0.9rem; font-size: 0.9rem; }

.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin: 1rem 0; }
.actions form { display: contents; }
section > form { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin: 0 0 0.75rem; }
section > form label { flex-basis: 100%; }
/* An input and its one button on the same line, tops and bottoms aligned; the label sits above the row. */
.field-row { display: flex; gap: 0.5rem; align-items: stretch; flex-basis: 100%; }
.field-row input { flex: 1 1 auto; min-width: 0; }
.field-row button { flex: none; }
.field-hint { flex-basis: 100%; margin: -0.35rem 0 0; font-size: 0.85rem; }
@media (max-width: 30rem) { .field-row { flex-wrap: wrap; } .field-row button { flex: 1 1 100%; } }
/* Round page: each job is one titled block, split by a fold line. */
.round-block { margin: 2rem 0 0; padding: 1.25rem 0 0; border-top: 1px solid var(--fold); }
.round-block h2 { margin: 0 0 0.75rem; }
.round-block > label { display: block; margin: 0 0 0.35rem; }
.round-block .field-hint { margin: -0.15rem 0 0.4rem; }
.button-row { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1rem 0 0; }
/* A secondary control inside a block: what it does on the left, its button on the right. */
.round-subaction { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; margin: 1.25rem 0 0; padding: 0.75rem 0.9rem; border: 1px dashed var(--fold); border-radius: var(--radius); }
.round-subaction p { flex: 1 1 18rem; margin: 0; line-height: 1.5; }
.round-subaction form { margin: 0; }
.close-warn { color: var(--ink); font-weight: 600; }
.round-subaction .close-warn, .round-subaction .close-warn + .button-row { flex: 1 1 100%; margin: 0; }
.field-row textarea { flex: 1 1 auto; min-width: 0; resize: vertical; }
.round-block > .invite-label { margin-top: 1rem; }
/* The open round leads with sharing; its one primary is "คัดลอกลิงก์". Closing with enough answers is a two-step disclosure. */
.confirm-close > summary { list-style: none; cursor: pointer; }
.confirm-close > summary::-webkit-details-marker { display: none; }
.confirm-close[open] { border-color: var(--airmail); background: var(--airmail-wash); }
.confirm-close > p { flex: 1 1 100%; margin: 0; }
/* Chrome renders details content outside the flex box (::details-content), so the open disclosure spaces its own children. */
.round-subaction.confirm-close[open] > :not(summary) { margin-top: 0.75rem; }
.round-page .danger-zone { margin-top: 2.5rem; }
/* Irreversible actions live in their own tinted block, apart from everything else on the page. */
.danger-zone { margin-top: 2.5rem; padding: 0.25rem 1rem 0.5rem; border: 1px solid var(--airmail); border-radius: var(--radius); background: var(--airmail-wash); }
.danger-zone h2 { margin-top: 1rem; color: var(--airmail-deep); }
.danger-zone input[type='text'] { background: #fff; }
.settings-session { margin-top: 2rem; }
.settings-delete > summary { cursor: pointer; padding: 0.75rem 0; font-weight: 700; color: var(--airmail-deep); }
.settings-delete:not([open]) { background: none; border-style: dashed; }
.copy-row { display: flex; gap: 0.5rem; }
.copy-row input { min-width: 0; }
form p label { display: block; font-weight: 600; margin-bottom: 0.25rem; }

/* ---------- Question sets: list and no-JS editor ---------- */
.set-new { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin: 1.25rem 0 1.75rem; }
.set-new label { flex-basis: 100%; font-weight: 600; }
.set-new select { flex: 1 1 14rem; width: auto; min-width: 0; }
.set-new .template-preview { flex-basis: 100%; margin: 0; }
.ed-status { font-weight: 600; }
.ed-ready::before { content: '✓ '; }
.ed-issues a { color: var(--airmail-deep); }
.ed-preview { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin: 0 0 1.5rem; }
.ed-preview label { flex-basis: 100%; font-weight: 600; }
.ed-preview select { flex: 1 1 12rem; width: auto; min-width: 0; }
.ed-savebar {
  position: sticky; top: 0; z-index: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.9rem;
  margin: 0 -0.5rem 1.25rem; padding: 0.6rem 0.5rem; background: var(--sheet); border-bottom: 1px solid var(--fold);
}
.ed-savebar .meta { flex: 1 1 12rem; font-size: 0.85rem; }
.ed-field { margin: 0 0 1rem; }
.ed-field.has-error input, .ed-field.has-error textarea, .ed-chip.has-error input { border-color: var(--airmail); }
.ed-field textarea { min-height: 3.5rem; }
.ed-section { border: 0; border-top: 2px solid var(--ink); margin: 2.25rem 0 0; padding: 0.75rem 0 0; min-width: 0; }
.ed-section > legend { font-weight: 700; font-size: 1.15rem; padding: 0 0.5rem 0 0; }
.ed-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.4rem; margin: 0 0 0.6rem; }
.ed-head h3 { margin: 0; }
.ed-tools { display: flex; gap: 0.35rem; }
button.ed-mini { min-height: 2.75rem; min-width: 2.75rem; padding: 0.25rem 0.7rem; font-size: 0.9rem; }
button.secondary:disabled { background: transparent; border-color: var(--fold); color: var(--ink-faint); }
/* Each question is its own card, so what belongs to a question (chips) and what belongs to the section (add a question) never blur. */
.ed-question { margin: 0 0 0.85rem; padding: 0.9rem 1rem 1rem; background: #fff; border: 1px solid var(--fold); border-radius: var(--radius); scroll-margin-top: 4.5rem; }
.ed-section, .ed-chip-group, .ed-field input, .ed-field textarea { scroll-margin-top: 4.5rem; }
.ed-check label { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 400; }
.ed-check input { width: 1.15rem; height: 1.15rem; }
.ed-chips { display: grid; gap: 0.75rem; justify-items: start; }
.ed-chip-group { border: 1px solid var(--fold); border-radius: var(--radius); padding: 0.6rem 0.75rem 0.75rem; margin: 0; width: 100%; min-width: 0; }
.ed-chip-group legend { font-weight: 600; padding: 0 0.3rem; }
.ed-chip { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.4rem; align-items: center; margin: 0 0 0.5rem; }
.ed-chip .field-error { grid-column: 1 / -1; margin: 0; }
.ed-add { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.ed-add-question { padding: 0.6rem 0.75rem; border: 1.5px dashed var(--fold); border-radius: var(--radius); }
.ed-add-label { flex: 1 1 100%; font-size: 0.9rem; font-weight: 600; color: var(--ink-soft); }
@media (min-width: 36rem) { .ed-add-label { flex: 1 1 auto; } }
.ed-add-section { margin: 2rem 0 0; padding: 1rem; border: 2px dashed var(--ink-faint); border-radius: var(--radius); justify-content: center; text-align: center; }
.ed-add-section .meta { flex-basis: 100%; font-size: 0.85rem; }
.ed-manage { margin-top: 3rem; padding-top: 0.25rem; border-top: 1px solid var(--fold); }

/* Results */
.count { color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.gaps { margin-top: 1.5rem; }
.gap-list h3, .chip-gaps h3 { margin-top: 1.25rem; }
.gap-list ol { list-style: none; padding: 0; margin: 0; }
.gap-list li { padding: 0.6rem 0; border-top: 1px solid var(--fold); font-variant-numeric: tabular-nums; }
.gap-list li > a, .chip-gaps li > a { display: inline-block; padding-block: 0.2rem; } /* standalone links reach 24px (WCAG 2.5.8) */
.gap-list strong { font-size: 1.15rem; color: var(--ink); }
.result { padding: 1.25rem 0; border-top: 1px solid var(--fold); }
/* One compact line per topic: others · self · gap · n, with the distribution beside it. */
.stat-line { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0.5rem 1.5rem; margin: 0.25rem 0 0.75rem; }
.stat-row { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; margin: 0; }
.stat-row div { display: flex; align-items: baseline; gap: 0.35rem; }
.stat-row dt { color: var(--ink-soft); font-size: 0.85rem; }
.stat-row dd { margin: 0; font-weight: 700; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.stat-row .stat-n dd { font-weight: 600; font-size: 0.95rem; }
.stat-line .chart.dist { width: 9rem; flex: none; }
@media (min-width: 40rem) { .stat-line { flex-wrap: nowrap; align-items: center; } }
.self-val, .self-val dt, .self-val dd { color: var(--airmail-deep); }
.results-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.results-head h1 { margin: 0; }
.results-head { overflow-x: clip; padding-right: 1.25rem; } /* the restamping postmark ring is the only thing it must contain; the padding keeps the lifted ring unclipped at 390 */
.postmark-small { margin: 0; flex: none; }
.postmark-small .postmark-ring { width: 7rem; height: 7rem; padding: 0.9rem; white-space: nowrap; border-width: 2px; box-shadow: inset 0 0 0 3px var(--sheet), inset 0 0 0 4px var(--action); }
.postmark-small .postmark-date { font-size: 1.05rem; line-height: 1.2; }
.postmark-small .postmark-foot { font-size: 0.75rem; line-height: 1.3; letter-spacing: 0; }
.self-comment { background: var(--airmail-wash); border-radius: var(--radius); padding: 0.5rem 0.75rem; font-size: 0.95rem; overflow-wrap: anywhere; }
.comments { padding-left: 1.2rem; margin: 0.5rem 0 0; }
.comments li { margin-bottom: 0.4rem; overflow-wrap: anywhere; }
.comments-head { font-size: 0.9rem; margin: 0.75rem 0 0; color: var(--ink-soft); }
.agree { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--fold); }
.agree ul { list-style: none; margin: 0; padding: 0; }
.agree li { padding: 0.4rem 0; font-variant-numeric: tabular-nums; }
.how-to-read { margin: 0.75rem 0; }
.how-to-read summary { cursor: pointer; color: var(--action); min-height: 2.75rem; padding-block: 0.6rem; box-sizing: border-box; }
.how-to-read ul { margin: 0.25rem 0 0; padding-left: 1.2rem; }
.legend { font-size: 0.9rem; color: var(--ink-soft); }
.key-others { color: var(--ink); font-weight: 600; }
.key-self { color: var(--airmail-deep); font-weight: 600; }
.legend-list { font-size: 0.92rem; color: var(--ink-soft); padding-left: 1.5rem; }

/* Charts */
.chart { width: 100%; height: auto; display: block; }
.chart.radar { max-width: 32rem; margin: 0 auto; }
.chart.radar text { font-size: 18px; }
.chart.radar-compact { display: none; max-width: 20rem; } /* phones: numbers only, in the square geometry, so the shape keeps its size */
.chart.radar-compact text { font-size: 18px; }
@media (max-width: 30rem) { .chart.radar-wide { display: none; } .chart.radar-compact { display: block; } }
.chart.dist { max-width: 12rem; }
.chart text { font: 12px 'Anuphan', system-ui, sans-serif; fill: var(--ink-soft); font-variant-numeric: tabular-nums; }
.grid-line { stroke: var(--fold); fill: none; }
.radar-others { fill: var(--ink); fill-opacity: 0.14; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; }
.radar-self { fill: none; stroke: var(--airmail); stroke-width: 2; stroke-dasharray: 6 4; stroke-linejoin: round; }
.dist-bar { fill: var(--ink); }
.trend-others { stroke: var(--ink); stroke-width: 2; fill: none; }
.trend-self { stroke: var(--airmail); stroke-width: 2; fill: none; stroke-dasharray: 5 4; }
.dot-others { fill: var(--ink); }
.dot-self { fill: var(--airmail); }
.trend-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1.25rem; }
.trend-grid figure { margin: 0; }
.trend-grid figcaption { font-weight: 600; font-size: 0.95rem; margin-bottom: 0.25rem; }

.message h1 { margin-bottom: 0.75rem; }

.self-list { list-style: none; padding: 0; margin: 0; }
.self-list li { display: flex; justify-content: space-between; gap: 1rem; padding: 0.5rem 0; border-top: 1px solid var(--fold); }
.self-list strong { font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ── Journey: chapters, map, chips (all themes; themes restyle via [data-theme]) ── */
.journey-summary { font-weight: 600; font-variant-numeric: tabular-nums; margin: 0.75rem 0; }
.journey-start { width: 100%; min-height: 3.25rem; font-size: 1.05rem; margin-top: 1rem; }
.chapter { border: 0; margin: 0; padding: 0; }
.chapter-title { display: flex; flex-direction: column; gap: 0.15rem; margin: 1.5rem 0 1rem; }
.chapter-title:focus { outline: none; }
/* The map and the progress line already show the position, so JS-on keeps it for screen readers only. */
.journey-on .chapter-step { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.chapter-step { font-size: 0.85rem; font-weight: 600; color: var(--ink-soft); letter-spacing: 0.04em; font-variant-numeric: tabular-nums; }
.chapter-art { display: block; width: 100%; max-width: 20rem; height: auto; margin: 0 auto 1rem; }
.chapter-nav { display: none; }
.journey-on .chapter-nav { display: grid; grid-template-columns: auto 1fr; gap: 0.75rem; align-items: center; margin-top: 1.5rem; }
.journey-on .chapter-nav:not(:has([data-back])) > button { grid-column: 1 / -1; }
.journey-on .chapter-nav .submit, .journey-on .chapter-nav [data-next] { margin: 0; min-height: 3.25rem; }
.chapter-missing { grid-column: 1 / -1; margin: 0; font-size: 0.9rem; color: var(--ink-soft); min-height: 1.3em; }
.journey-on .form-submit { display: none; }
.journey-map { display: none; }
/* The sticky map must not cover whatever takes focus or is scrolled to (WCAG 2.4.11). */
html:has(body.journey-on) { scroll-padding-top: 7.5rem; }
.journey-on .journey-map { display: block; position: sticky; top: 0; z-index: 2; background: var(--sheet); padding: 0.6rem 0; margin: 0 0 0.5rem; border-bottom: 1px dashed var(--fold); }
.journey-map ol { list-style: none; display: flex; justify-content: space-between; gap: 0.25rem; margin: 0; padding: 0; position: relative; }
.journey-map ol::before { content: ''; position: absolute; left: 1rem; right: 1rem; top: 0.9rem; border-top: 2px dashed var(--ink-faint); }
.journey-map li { position: relative; display: flex; flex-direction: column; align-items: center; gap: 0.2rem; flex: 1; min-width: 0; text-align: center; }
.journey-dot { position: relative; z-index: 1; display: grid; place-items: center; width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--sheet); border: 2px solid var(--ink-faint); font-weight: 700; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.journey-label { font-size: 0.72rem; line-height: 1.3; color: var(--ink-soft); overflow-wrap: anywhere; }
.journey-map [data-state='current'] .journey-dot { border-color: var(--action); color: var(--action); }
.journey-map [data-state='current'] .journey-label { color: var(--ink); font-weight: 600; }
.journey-map [data-state='done'] .journey-dot { background: var(--action); border-color: var(--action); color: #fff; }
@media (max-width: 30rem) {
  .journey-label { display: none; }
  .journey-map li { position: static; }
  .journey-map [data-state='current'] .journey-label { display: block; position: absolute; left: 0; right: 0; top: 2.2rem; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .journey-on .journey-map ol { margin-bottom: 1.5rem; }   /* room for the current step's label under the dots */
}
/* The position line lives inside the sticky map, so it (and the blocked-Next message) is always on screen. */
.journey-on .progress { position: static; background: none; padding: 0; margin: 0.4rem 0 0; text-align: right; font-size: 0.85rem; }
.journey-on .journey-map .progress { text-align: center; }
.chapter-done { position: fixed; inset: auto 1rem 1.25rem; z-index: 5; margin: 0 auto; max-width: 28rem; padding: 1rem 1.25rem; background: var(--sheet); border: 2px solid var(--action); border-radius: 0.5rem; text-align: center; font-weight: 700; box-shadow: 0 0.5rem 1.5rem rgb(29 42 77 / 0.18); }
.chapter-done.is-playing { animation: chapter-done 1500ms cubic-bezier(0.16, 1, 0.3, 1) both; pointer-events: none; }
.chapter-done.is-inline { position: static; box-shadow: none; margin: 0.75rem auto 1rem; }
@keyframes chapter-done { 0% { opacity: 0; transform: translateY(1rem) scale(0.96); } 15%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; } }
.preview-banner { background: var(--action-wash); border: 1px dashed var(--action); border-radius: 0.4rem; padding: 0.6rem 0.9rem; font-weight: 600; }

.chips { display: grid; gap: 0.75rem; margin-top: 1rem; }
.chip-group { border: 0; margin: 0; padding: 0; }
.chip-group legend { font-size: 0.9rem; font-weight: 600; margin-bottom: 0.4rem; padding: 0; }
.chip-hint { font-weight: 400; color: var(--ink-soft); font-size: 0.82rem; }
/* Chips: gummed paper labels (Aerogramme). A picked label is stuck down: filled, a ✓, a hair of tilt.
 * Strengths and improve use different fills so the two piles never read as one; themes restyle the shape. */
:root { --chip-plus: var(--action); --chip-minus: #7a4a17; /* improve: warm ink, never the error red */ }
.chip-group { --chip-on: var(--chip-plus); }
.chip-group[data-group='improve'] { --chip-on: var(--chip-minus); }
.chip-group legend::before {
  content: ''; display: inline-block; width: 0.6rem; height: 0.6rem; margin-right: 0.4rem;
  border-radius: 2px; background: var(--chip-on); vertical-align: 0.05em;
}
/* JS on: a rating question's chips wait for a rating (not "ไม่แน่ใจ"), unless a chip is already ticked (restored draft). */
.questionnaire.progressive .question-rating:not(:has(.scale input:checked)):not(:has(.chips input:checked)) .chips { display: none; }
.chip-picks {
  display: inline-block; margin-left: 0.35rem; padding: 0 0.45rem; border-radius: 999px;
  font-size: 0.78rem; font-weight: 600; font-variant-numeric: tabular-nums;
  color: var(--ink-soft); background: var(--paper);
}
/* Without JS nothing enforces or updates the cap, so the counter would only be a stale 0/2. */
.questionnaire:not(.progressive) .chip-picks { display: none; }
.chip { position: relative; display: inline-flex; margin: 0 0.35rem 0.45rem 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip span {
  display: inline-flex; align-items: center; gap: 0.3rem; min-height: 2.5rem;
  padding: 0.35rem 0.8rem; border: 1.5px solid var(--control-border, var(--ink-faint)); border-radius: 4px;
  background: #fff; box-shadow: 0 1.5px 0 var(--fold);
  font-size: 0.92rem; line-height: 1.35;
  transition: background-color 140ms ease-out, border-color 140ms ease-out, transform 140ms ease-out;
}
.chip span::before {
  content: ''; flex: none; width: 0; height: 0.95em;
  background: currentColor; -webkit-mask: url('/static/img/check.svg') center / contain no-repeat; mask: url('/static/img/check.svg') center / contain no-repeat;
  transition: width 140ms ease-out;
}
.chip:hover span { border-color: var(--chip-on); }
/* `body` lifts these above every theme's `body[data-theme] .chip span` / `.scale-na` restyle, so each theme keeps them. */
body .chip:hover input:not(:checked):not(:disabled) + span { border-color: var(--chip-on); border-style: solid; }
.chip input:checked + span {
  background: var(--chip-on); border-color: var(--chip-on); color: #fff;
  transform: rotate(-1deg); box-shadow: 0 2px 0 rgba(29, 42, 77, 0.25);
  animation: chip-pick 260ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.chip input:checked + span::before { width: 0.95em; }
@keyframes chip-pick { 0% { transform: scale(0.92); } 70% { transform: scale(1.05) rotate(-1deg); } 100% { transform: rotate(-1deg); } }
.chip input:focus-visible + span { outline: 3px solid var(--action); outline-offset: 2px; }
.chip input:disabled + span { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
@media (prefers-reduced-motion: reduce) { .chip input:checked + span { animation: none; } .chip span, .chip span::before { transition: none; } }
/* Forced colours drop fills, so a picked chip is told apart by a heavy solid border and a ✓ drawn in CanvasText.
 * !important: every theme restates .chip span borders at the same specificity. */
@media (forced-colors: active) {
  .chip input:checked + span { border-width: 3px !important; border-style: solid !important; }
  .chip span::before { forced-color-adjust: none; background: CanvasText; }
}
.chip-note { font-size: 0.82rem; color: var(--ink-soft); margin: 0.1rem 0 0; }
.question-rating:has(.scale-na input:checked) .chips { display: none; }

.reward { margin: 1.5rem auto 0.5rem; }
.reward-card { margin: 0 auto; display: grid; justify-items: center; gap: 0.5rem; max-width: 18rem; }
.reward-card img { width: 9rem; height: auto; filter: drop-shadow(0 2px 3px rgba(29, 42, 77, 0.22)); }
.reward-card figcaption { display: grid; gap: 0.15rem; }
.reward-heading { font-size: 0.82rem; color: var(--ink-soft); letter-spacing: 0.04em; }
.reward-title { font-size: 1.2rem; }
.reward-line { color: var(--ink-soft); }
@media (prefers-reduced-motion: no-preference) { .reward:not([hidden]) .reward-card img { animation: reward-land 560ms cubic-bezier(0.16, 1, 0.3, 1) both; } }
.reward-card img { transform: rotate(-4deg); }
@keyframes reward-land {
  from { transform: rotate(-14deg) scale(1.4); opacity: 0; filter: blur(3px); }
  to { transform: rotate(-4deg) scale(1); opacity: 1; filter: blur(0); }
}

/* Owner side */
/* Theme cards: equal columns and equal heights, so 6 themes sit as 3×2 (2×3 on a phone) whatever their name length. */
.theme-pick { border: 0; padding: 0; margin: 0 0 1rem; min-width: 0; }
.theme-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
@media (min-width: 36rem) { .theme-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.75rem; } }
.theme-option {
  position: relative; display: grid; grid-template-rows: auto auto 1fr; justify-items: center; align-content: start; gap: 0.15rem;
  padding: 1.6rem 0.6rem 0.7rem; border: 1.5px solid var(--fold); border-radius: 0.5rem; background: var(--sheet); cursor: pointer; text-align: center;
}
.theme-option input { position: absolute; top: 0.5rem; left: 0.5rem; margin: 0; }
.theme-option img { width: 100%; max-width: 7.5rem; height: auto; margin: 0 0 0.4rem; }
.theme-tagline { font-weight: 600; color: var(--ink); line-height: 1.3; }
.theme-name { font-size: 0.85rem; color: var(--ink-soft); line-height: 1.35; }
.theme-option:hover { border-color: var(--ink-soft); }
.theme-option:has(input:checked) { border-color: var(--action); box-shadow: 0 0 0 1.5px var(--action); }
.theme-option:has(input:focus-visible) { outline: 2px solid var(--action); outline-offset: 2px; }
/* What the chosen question set asks, under the picker. */
.template-preview { margin: -0.25rem 0 1rem; padding: 0.6rem 0.85rem; border: 1px solid var(--fold); font-size: 0.92rem; }
.template-preview[hidden] { display: none; }
.template-preview-meta { margin: 0; color: var(--ink-soft); }
.template-preview summary { cursor: pointer; color: var(--action); margin-top: 0.25rem; min-height: 2.75rem; padding-block: 0.6rem; box-sizing: border-box; }
.template-preview-section { font-size: 0.92rem; font-weight: 700; margin: 0.75rem 0 0.25rem; }
.template-preview ol { margin: 0.35rem 0 0; padding-left: 1.4rem; display: grid; gap: 0.2rem; }
.template-preview-type { font-size: 0.78rem; color: var(--ink-soft); white-space: nowrap; }
/* A form's closing buttons: the primary action last, at the right edge. */
.form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.6rem; margin-top: 1.5rem; }
/* New round: ticking "แบ่งกลุ่มผู้ตอบ" swaps the primary to what it will really do (the server ignores open_now then). No JS needed. */
form:has(input[name='with_groups']:checked) .when-no-groups { display: none; }
form:not(:has(input[name='with_groups']:checked)) .when-groups { display: none; }
/* A quiet extra under the buttons (the preview): a text link, still a submit button. */
.form-aside { display: flex; justify-content: flex-end; margin: 0.25rem 0 0; }
.link-button { background: none; border: 0; border-radius: 0; padding: 0 0.25rem; min-height: 2.75rem; color: var(--action); font: inherit; text-decoration: underline; cursor: pointer; }
.link-button:hover { background: none; color: var(--action-deep); }
.link-button:disabled { color: var(--ink-faint); cursor: default; }
.chip-tally { display: grid; gap: 0.75rem; margin-top: 1rem; }
.chip-tally h4 { font-size: 0.9rem; margin: 0 0 0.35rem; }
/* A pile's heading carries its colour square, as the form's chip-group legend does; results and gaps share it. */
.pile { --chip-on: var(--chip-plus); }
.pile[data-group='improve'] { --chip-on: var(--chip-minus); }
.pile::before {
  content: ''; display: inline-block; width: 0.6rem; height: 0.6rem; margin-right: 0.4rem;
  border-radius: 2px; background: var(--chip-on); vertical-align: 0.05em;
}
.chip-tally ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.25rem; }
.chip-tally li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 0.5rem; align-items: baseline; }
.chip-bar { color: var(--action); letter-spacing: -0.1em; }
.chip-count { font-variant-numeric: tabular-nums; color: var(--ink-soft); font-size: 0.9rem; }
.self-tag { display: inline-block; margin-left: 0.35rem; padding: 0 0.4rem; border: 1px dashed var(--airmail); border-radius: 4px; font-size: 0.75rem; font-weight: 600; line-height: 1.5; color: var(--airmail-deep); vertical-align: 0.1em; }   /* self = red dashed, as on the charts */
.chip-unpicked summary { cursor: pointer; min-height: 2.75rem; padding-block: 0.6rem; box-sizing: border-box; }
.results-frame { padding: 0.75rem 0.9rem; border: 1px dashed var(--fold); border-radius: var(--radius); color: var(--ink-soft); }
.results-next { margin-top: 2.5rem; padding-top: 1.25rem; border-top: 1px solid var(--fold); }
.trends-empty { margin-top: 1rem; }
.group-rule { margin: 0.25rem 0 0.75rem; }
/* One compact row per group: name takes the width, the minimum is a short number field, remove sits at the end. */
.group-row { flex-wrap: wrap; align-items: center; gap: 0.35rem 0.75rem; margin: 0 0 0.6rem; }
.group-row label { display: inline-flex; align-items: center; gap: 0.4rem; white-space: nowrap; }
.group-row label:first-of-type { flex: 1 1 14rem; }
.group-row label:first-of-type input { flex: 1 1 auto; min-width: 0; }
.group-row input[type='number'] { flex: none; width: 4.5rem; }
.group-row input[type='checkbox'] { flex: none; }
.group-rule summary { cursor: pointer; color: var(--action); min-height: 2.75rem; padding-block: 0.6rem; box-sizing: border-box; }
.chip-trend { width: 100%; border-collapse: collapse; margin: 1rem 0 1.5rem; font-variant-numeric: tabular-nums; }
.chip-trend caption { text-align: left; font-weight: 600; margin-bottom: 0.35rem; }
.chip-trend th, .chip-trend td { padding: 0.3rem 0.5rem; border-bottom: 1px solid var(--fold); text-align: right; }
.chip-trend td { white-space: nowrap; }
.chip-trend th[scope='row'], .chip-trend thead th:first-child { text-align: left; font-weight: 400; }
.chip-trend th[scope='colgroup'] { text-align: left; padding-top: 0.9rem; }
.chip-trend th[scope='colgroup'] .pile { margin: 0; font-size: 1rem; font-weight: 700; } /* an h3 (no skipped level under the page's h2), drawn like the h4 it replaces */
.chip-trends { overflow-x: auto; }
@media (prefers-reduced-motion: reduce) { .chapter-done.is-playing { animation: none; } }
.owner-line { margin: 0 0 0.75rem; color: var(--ink-soft); font-size: 1rem; }
.owner-line strong { color: var(--ink); }

/* Thanks: one memento. Aerogramme cancels the reward stamp with the postmark, like a posted letter. */
.nowrap { white-space: nowrap; }
.envelope-corner { position: relative; margin: 1.5rem auto 0.5rem; max-width: 20rem; }
.envelope-corner .reward { margin: 0; }
.postmark-cancel { margin: 1rem 0 0; }
.postmark-cancel .postmark-ring { width: 8.5rem; height: 8.5rem; padding: 1.35rem 1rem; gap: 0; background: transparent; box-shadow: inset 0 0 0 4px transparent, inset 0 0 0 5.5px var(--action); }
.postmark-cancel .postmark-title { font-size: 0.72rem; line-height: 1.25; max-width: 6rem; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: normal; }
.postmark-cancel .postmark-date { font-size: 0.9rem; white-space: nowrap; }
.postmark-cancel .postmark-foot { font-size: 0.66rem; letter-spacing: 0.02em; }
/* With a stamp shown, the ring lands on the stamp's right edge; a sheet-coloured halo keeps the ink legible over the stamp. */
.envelope-corner:has(.reward:not([hidden])) .postmark-cancel { position: absolute; top: 0; left: calc(50% + 0.1rem); margin: 0; pointer-events: none; }
.envelope-corner:has(.postmark-cancel) .reward-card img { translate: -1.6rem 0; }
.envelope-corner:has(.reward:not([hidden])) .postmark-ring span { text-shadow: 0 0 2px var(--sheet), 0 0 4px var(--sheet), 0 0 6px var(--sheet); }
@media (prefers-reduced-motion: no-preference) { .postmark-cancel .postmark-ring { animation: stamp 560ms 350ms cubic-bezier(0.16, 1, 0.3, 1) both; } }
.sheet.thanks { overflow-x: clip; } /* the landing postmark starts at 1.5× and must not widen the page */

/* ---------- Brand and footer (every page) ---------- */
.account-brand { margin-right: auto; font-weight: 700; color: var(--ink); text-decoration: none; letter-spacing: 0.01em; }
.account-brand:hover { color: var(--action); }
.site-footer {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.25rem 1.25rem;
  max-width: var(--measure); margin: -1rem auto 0; padding: 0 1rem 2rem; font-size: 0.85rem; color: var(--page-ink-soft, var(--ink-soft));
}
/* The footer sits on the desk, not the sheet: a theme with a dark desk sets --page-ink / --page-ink-soft / --page-link. */
.site-footer-brand { font-weight: 700; color: var(--page-ink, var(--ink)); }
.site-footer-links { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; }
.site-footer-links a { color: var(--page-link, var(--action)); }
.surface-public:has(.landing) .site-footer { max-width: 60rem; }

/* ---------- Privacy policy and terms: plain reading on the one sheet ---------- */
.legal .legal-lede { color: var(--ink-soft); }
.legal h2 { margin-top: 2rem; }
.legal h3 { margin-top: 1.25rem; }
.legal ul { padding-left: 1.25rem; }
.legal li { margin-bottom: 0.5rem; }
.legal a { overflow-wrap: anywhere; }
.legal .legal-back { margin-top: 2rem; }
.legal .legal-back a { display: inline-block; padding-block: 0.2rem; }

/* ---------- Landing: one wide letter on the aerogramme ground ---------- */
.landing { max-width: 60rem; overflow: hidden; }
.landing h2 { margin-top: 0; }
.landing .button { text-decoration: none; }
.lp-hero { display: grid; gap: 1.5rem; }
.lp-brand { display: flex; align-items: center; gap: 0.6rem; margin: 0 0 1rem; font-weight: 700; font-size: 1.15rem; letter-spacing: 0.02em; color: var(--ink); }
.lp-brand-mark { width: 3rem; height: auto; fill: none; stroke: var(--action); stroke-width: 1.8; stroke-linecap: round; transform: rotate(-8deg); }
.lp-hero h1 { font-size: clamp(1.6rem, 1.1rem + 2.6vw, 2.75rem); line-height: 1.28; letter-spacing: -0.015em; margin-bottom: 0.9rem; max-width: 18em; }
.lp-phrase { display: inline-block; } /* Thai has no spaces: break only between phrases */
.lp-lede { color: var(--ink-soft); font-size: 1.08rem; max-width: 34em; margin-bottom: 1.25rem; }
.lp-cta { margin: 0 0 0.5rem; }
.lp-button { min-height: 3.25rem; padding: 0.75rem 1.6rem; font-size: 1.05rem; }
.lp-cta-note { font-size: 0.9rem; color: var(--ink-soft); margin: 0; }
.lp-hero-art { position: relative; display: flex; justify-content: center; align-items: flex-end; min-height: 12rem; }
.lp-postbox { display: block; width: auto; height: 15rem; max-width: 45%; object-fit: contain; }
.lp-postmark { position: absolute; left: 50%; bottom: 1rem; margin: 0; transform: translateX(-118%); }
.lp-postmark .postmark-ring { width: 8.5rem; height: 8.5rem; padding: 1rem; }
.lp-postmark .postmark-title { font-size: 0.82rem; }
.lp-postmark .postmark-date { font-size: 1.6rem; line-height: 1.1; }
.lp-postmark .postmark-foot { font-size: 0.7rem; letter-spacing: 0.02em; }
@media (prefers-reduced-motion: no-preference) { .lp-postmark .postmark-ring { animation: stamp 560ms 250ms cubic-bezier(0.16, 1, 0.3, 1) both; } }

/* Sections are separated by fold creases, never boxed. */
.lp-section, .lp-close {
  margin-top: 2.5rem; padding-top: 2.25rem; border-top: 1px solid var(--fold);
  background: linear-gradient(to bottom, rgba(29, 42, 77, 0.05), transparent 0.6rem) top / 100% 0.6rem no-repeat;
}
.lp-steps { list-style: none; padding: 0; margin: 0; counter-reset: lp-step; display: grid; gap: 1.75rem; }
.lp-step { counter-increment: lp-step; display: grid; gap: 0.75rem; }
.lp-step-art { display: block; width: 100%; max-width: 13rem; height: auto; }
.lp-step h3 { display: flex; align-items: center; gap: 0.6rem; font-size: 1.15rem; margin-bottom: 0.35rem; }
/* The step number is a small double-ringed postmark (sequence matters: close the round before reading). */
.lp-step h3::before {
  content: counter(lp-step); flex: none; display: grid; place-items: center; width: 2rem; height: 2rem;
  border-radius: 50%; border: 3px double var(--action); color: var(--action);
  font-size: 0.95rem; font-weight: 700; font-variant-numeric: tabular-nums; transform: rotate(-8deg);
}
.lp-step p { color: var(--ink-soft); margin: 0; max-width: 36em; }

.lp-promises { display: flex; gap: 1rem; align-items: flex-start; background: #fff; border: 1px solid var(--fold); border-radius: var(--radius); padding: 1rem 1rem 0.25rem; }
.lp-promises-mark { flex: none; width: 3.5rem; height: auto; margin-top: 0.2rem; fill: none; stroke: var(--action); stroke-width: 1.8; stroke-linecap: round; transform: rotate(-8deg); }
.lp-promises ul { list-style: none; padding: 0; margin: 0; min-width: 0; }
.lp-promises li { padding: 0 0 0.9rem; }
.lp-promises li + li { border-top: 1px solid var(--fold); padding-top: 0.9rem; }
.lp-promises h3 { margin-bottom: 0.2rem; }
.lp-promises p { color: var(--ink-soft); font-size: 0.97rem; margin: 0; text-wrap: pretty; }
.lp-caveat { font-size: 0.9rem; color: var(--ink-soft); margin: 0.9rem 0 0; max-width: 40em; text-wrap: pretty; }

.lp-themes { list-style: none; padding: 0; margin: 1.25rem 0 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem 0.75rem; }
.lp-themes li { display: grid; gap: 0.35rem; justify-items: center; text-align: center; font-size: 0.85rem; color: var(--ink-soft); line-height: 1.4; }
.lp-themes img { display: block; width: 100%; max-width: 7rem; height: auto; border-radius: var(--radius); border: 1px solid var(--fold); }

.lp-close { padding-bottom: 0.5rem; }
@media (max-width: 35.99rem) { .lp-close { text-align: center; } } /* left-aligned from 36rem, like the hero */
.lp-close h2 { margin-bottom: 1rem; }

/* Too narrow for two columns: the promise and the call to action come first; the art returns in the steps. */
/* A phone is a letter held in one hand. The opening is an envelope front, centred around the postbox;
   the body reads down one left edge, the steps as compact rows (small art, text beside it) that fill the width. */
@media (max-width: 35.99rem) {
  .lp-hero { display: flex; flex-direction: column; align-items: center; gap: 0; text-align: center; }
  .lp-hero-text { display: contents; }
  .lp-brand { order: 0; justify-content: center; margin-bottom: 0.25rem; }
  .lp-hero-art { order: 1; display: flex; justify-content: center; min-height: 0; width: 100%; margin: 0 0 1rem; padding-left: 4.5rem; } /* the postbox steps right so the stamp sits beside it */
  .lp-hero h1, .lp-lede, .lp-cta, .lp-cta-note { order: 2; }
  .lp-postbox { height: 11.5rem; max-width: none; }
  .lp-postmark { left: 50%; bottom: 0.25rem; transform: translateX(-105%); }
  .lp-postmark .postmark-ring { width: 7.75rem; height: 7.75rem; padding: 0.7rem; }
  .lp-postmark .postmark-title { font-size: 0.74rem; }
  .lp-postmark .postmark-date { font-size: 1.4rem; }
  .lp-postmark .postmark-foot { font-size: 0.64rem; }
  .lp-hero h1 { margin-inline: auto; }
  .lp-lede { margin-inline: auto; font-size: 1rem; }
  .lp-cta { width: 100%; }
  .lp-cta .lp-button { width: 100%; max-width: 22rem; }

  .lp-steps { gap: 1.25rem; }
  .lp-step { grid-template-columns: 5.5rem minmax(0, 1fr); gap: 0.9rem; align-items: start; }
  .lp-step-art { width: 5.5rem; height: 5.5rem; object-fit: contain; }
  .lp-step h3 { font-size: 1.05rem; margin: 0.15rem 0 0.25rem; }
  .lp-step h3::before { width: 1.7rem; height: 1.7rem; font-size: 0.85rem; }
  .lp-step p { font-size: 0.95rem; }
}
@media (max-width: 30rem) {
  .lp-promises { padding: 0.9rem 0.9rem 0.1rem; }
  .lp-promises-mark { display: none; }
}
@media (min-width: 40rem) {
  .lp-step { grid-template-columns: 13rem minmax(0, 1fr); gap: 1.5rem; }
  .lp-themes { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
/* From a large phone up, the hero is the same letter as on desktop: text left, postbox right, scaled to the width. */
@media (min-width: 36rem) {
  .lp-hero { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); align-items: center; gap: 1.25rem; }
  .lp-hero-art { min-height: 0; justify-content: flex-end; } /* the postbox keeps to the right so the stamp has room on its left */
  .lp-postbox { height: clamp(17rem, 12rem + 18vw, 26rem); max-width: 100%; }
  .lp-postmark { left: -0.5rem; bottom: 0; transform: none; }
  .lp-postmark .postmark-ring { width: 9.5rem; height: 9.5rem; padding: 0.8rem; }
  .lp-step { grid-template-columns: 11rem minmax(0, 1fr); gap: 1.25rem; align-items: center; }
}
@media (min-width: 52rem) {
  .landing { padding: 3rem 3.5rem 3.25rem; }
  .lp-hero { gap: 2rem; }
  .lp-hero-art { justify-content: center; }
  .lp-postmark { left: -1.5rem; }
  .lp-postmark .postmark-ring { width: 10rem; height: 10rem; }
}
.group-picker { border: 1px solid var(--fold); border-radius: 0.5rem; padding: 0.75rem 1rem; margin: 0 0 1.5rem; }
.group-picker legend { font-weight: 700; padding: 0 0.25rem; }
.group-option { display: flex; gap: 0.5rem; align-items: baseline; padding: 0.35rem 0; }

.table-scroll { overflow-x: auto; }
.group-table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.group-table th, .group-table td { padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--fold); text-align: right; }
.group-table th[scope="row"], .group-table thead th:first-child { text-align: left; }
