:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #1d2430;
  --muted: #5d6675;
  --line: #d9dee6;
  --accent: #2f5d8a;
  --accent-ink: #ffffff;
  --user: #e3edf7;
  --bot: #ffffff;
  --warn: #8a4b00;
  --warn-bg: #fff4e0;
  --avatar-bg: #e8ebef;   /* same as placeholder background: none keeps an identical neutral box (§8-3) */
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.65 "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  /* M1.3.1 ①: Korean lines break between words, never inside one; only a too-long run (URL, code) may break */
  word-break: keep-all; overflow-wrap: break-word; }
/* M1.3.5 ①: "모아(Moa)" + its particle (M1.3.6 ①: or "입니다.") never split at a line end; M1.3.6 ②: "첫 번째"/
   "두 번째" too (app.js keep()) */
.moa, .nth { white-space: nowrap; }
button { font: inherit; }
[hidden] { display: none !important; }

/* participant code (판정 M1.2 #3): one small grey line on the right, same on PC and phone.
   Chat screen: inside .chat-bar. Other screens: a line in the page colour that stays in view (§8-5). */
.pcode { font-size: 12px; color: var(--muted); text-align: right; white-space: nowrap; }
.pcode-line { position: sticky; top: 0; z-index: 30; margin: -20px 0 6px; padding: 4px 0; background: var(--bg); }

.root { max-width: 720px; margin: 0 auto; padding: 24px 16px 48px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 22px; }
.card + .card { margin-top: 16px; }
.banner { background: var(--warn-bg); color: var(--warn); border: 1px solid #f0d3a8; border-radius: 8px;
  padding: 10px 14px; margin-bottom: 16px; font-weight: 600; }
.btn { appearance: none; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  border-radius: 8px; padding: 10px 20px; cursor: pointer; font-weight: 600; }
.btn.secondary { background: #fff; color: var(--accent); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
/* button colour rule (판정 M1.3.1보고 §2, M1.3.2 ②⑤⑥): dark = can and should be pressed now;
   light grey border + grey text = cannot be pressed, or there is no need to */
.btn.soft { background: #fff; border-color: #c9cfd8; color: #8b93a1; opacity: 1; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
input.code { font: inherit; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; width: 13em;
  text-transform: uppercase; letter-spacing: .05em; }
input.code.bad { border-color: #b3261e; }
.btn-lg { font-size: 18px; padding: 14px 36px; }
.welcome-main { padding: 36px 22px; text-align: center; }
.welcome-main .welcome-q { font-size: 22px; font-weight: 700; margin: 0 0 8px; }
.welcome-main .row { justify-content: center; }
/* A ⑧-③: screen 0 lower box at 80% width, lighter border (both sets) */
.welcome-resume { font-size: 14px; padding: 14px 18px; width: 80%; margin-left: auto; margin-right: auto; border-color: #e6e9ef; }
.welcome-resume p { margin: 0 0 8px; }
.field-label { display: block; color: var(--muted); font-size: 13px; }
.welcome-resume .row { margin-top: 4px; }
.welcome-resume .hint { color: #b3261e; }

/* B0 (§3-2: four paragraphs, last one bold + bordered) */
.b0 p { margin: 0 0 14px; }
.b0 ul { list-style: none; margin: 0 0 14px; padding: 0 0 0 4px; }
.b0 li { margin: 2px 0; font-weight: 700; }
.b0 strong { font-weight: 700; }
.b0 .b0-top { font-weight: 700; }  /* M1.3.6 ③: situation 2's top line (revised) */
.b0 .boxed { font-weight: 700; border: 2px solid var(--ink); border-radius: 8px; padding: 12px 14px; }
textarea { width: 100%; min-height: 220px; font: inherit; padding: 12px; border: 1px solid var(--line);
  border-radius: 8px; resize: vertical; }
.hint { color: var(--warn); font-weight: 600; margin-top: 8px; }
.saved-note { color: var(--muted); font-size: 14px; margin: 8px 0 0; }
.narrative-saved { white-space: pre-wrap; background: #f1f3f6; border: 1px solid var(--line);
  border-radius: 8px; padding: 12px; color: var(--ink); }

/* Survey (§3-4, A10): numbers 1-7 + end anchors; four bordered boxes [v1.2] */
.survey { margin-top: 16px; }
.survey-head { font-weight: 700; margin: 0 0 6px; }
.survey-sub { margin: 0 0 6px; }
.qbox { background: var(--card); border: 1px solid #b9c2cf; border-radius: 10px; padding: 4px 18px 8px; margin-top: 14px; }
.anchor-line { color: var(--muted); margin: 14px 0 8px; font-size: 15px; }
.item { padding: 14px 0; border-top: 1px solid var(--line); }
.item.missing { border-left: 4px solid #b3261e; padding-left: 10px; margin-left: -14px; background: #fdf3f2; }
.partc { margin-top: 18px; background: #eef3f9; border: 2px solid var(--accent); border-radius: 10px; padding: 16px 18px; }
.partc p { margin: 0 0 8px; }
.item-text { margin: 0 0 10px; }
.scale { display: grid; grid-template-columns: minmax(70px, 1fr) auto minmax(70px, 1fr); align-items: center; gap: 10px; }
.scale .end { font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.scale .end.left { text-align: right; }
.scale .nums { display: flex; gap: 6px; }
.scale .num { position: relative; display: flex; flex-direction: column; align-items: center; }
.scale input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.scale .num span { display: inline-flex; width: 40px; height: 40px; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 50%; background: #fff; cursor: pointer; font-weight: 600; }
.scale input:checked + span { background: var(--accent); color: #fff; border-color: var(--accent); }
.scale input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.scale .mid { grid-column: 2; font-size: 12px; color: var(--muted); text-align: center; line-height: 1.3; margin-top: -4px; }
@media (max-width: 560px) {
  .scale { grid-template-columns: 1fr 1fr; }
  .scale .end.left { order: 1; text-align: left; }
  .scale .end.right { order: 2; text-align: right; }
  .scale .nums { order: 3; grid-column: 1 / -1; justify-content: space-between; }
  .scale .mid { order: 4; grid-column: 1 / -1; }
  .scale .num span { width: 36px; height: 36px; }
}

/* Chat (§3-5, §8-2 [v1.2]): one layout for PC and phone — header avatar ~56px + name, ~28px per bot bubble */
.chat-root { max-width: 720px; padding: 0; }  /* M1.3 ⑤: PC 720px on every participant screen */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 100vh; }
.avatar-sm img, .avatar-xs img { width: 100%; height: 100%; display: block; }
.chat-bar { position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--line);
  padding: 8px 18px; display: flex; align-items: center; gap: 10px; }
.chat-bar .who { display: flex; align-items: center; gap: 10px; font-weight: 700; }
/* M1.3.1 ②: header photo PC 96px / phone 72px; bubble icon PC 80px / phone 60px (M1.3.3 ①: 83% of the header; was 56 / 44) */
.avatar-sm { width: 96px; height: 96px; border-radius: 14px; background: var(--avatar-bg); overflow: hidden; flex: none; }
.bar-right { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.counter { font-size: 14px; font-weight: 700; color: var(--accent); white-space: nowrap; }
.log { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.msg { display: flex; gap: 8px; align-items: flex-end; }
.msg.user { justify-content: flex-end; }
.bubble { max-width: 78%; padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; }
.msg.user .bubble { background: var(--user); border-bottom-right-radius: 4px; }
.bot-col { display: flex; flex-direction: column; align-items: flex-start; max-width: 78%; min-width: 0; }
.bot-col .bubble { max-width: 100%; }
/* M1.3.2 ④: name under the icon, centred; the column is exactly as wide as the icon (a wider name overhangs both
   sides evenly), so bubbles and the photo card keep their place */
.icon-col { display: flex; flex-direction: column; align-items: center; width: 80px; flex: none; }
.bubble-name { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.3; white-space: nowrap; }
.msg.bot .bubble { background: var(--bot); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.avatar-xs { width: 80px; height: 80px; border-radius: 12px; background: var(--avatar-bg); overflow: hidden; flex: none; }
.avatar-sm.blank, .avatar-xs.blank { background: transparent; }  /* M1.3.1 ⑦: "none" keeps the place, shows nothing */
.typing { color: var(--muted); font-style: italic; }
/* M1.3 ⑧ photo card: bot side, same file as the avatar; PC 368px (M1.3.2 ③, was 320), phone = bubble width */
.avatar-gap { width: 80px; flex: none; }
.photo-card { width: 368px; max-width: 78%; border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  background: var(--bot); }
/* square place kept before the picture arrives, so a late image cannot push the first reply under the composer */
.photo-card img { display: block; width: 100%; height: auto; aspect-ratio: 1 / 1; object-fit: cover; }
.status { margin: 0 18px; }
.status p { margin: 0 0 8px; }
.dock { position: sticky; bottom: 0; margin-top: auto; background: var(--bg); border-top: 1px solid var(--line); }
.composer { padding: 10px 18px 12px; display: flex; gap: 8px; align-items: stretch; }
.composer .btn { white-space: nowrap; flex: none; }
.composer textarea { min-height: 130px; height: 160px; }  /* M1.3.2 ①: 128 -> 160px (min in proportion); the button follows */
.send-hint { margin: -6px 18px 10px; font-size: 14px; }
.safety { padding: 8px 18px 12px; background: #eef5ff; border-top: 1px solid #c7dbf3; font-size: 14px; font-weight: 600; }
.done-card { text-align: center; }
.done-card .row { justify-content: center; }
.done-card .code { font-size: 34px; font-weight: 800; letter-spacing: .06em; margin: 2px 0 4px; user-select: all; }
/* M1.3.2 ⑤: label + code + [복사] in one translucent light blue rounded box (정우 sketch 11/10) */
.code-box { display: inline-block; min-width: 260px; max-width: 100%; margin: 4px 0 14px; padding: 14px 28px 16px;
  background: rgba(47, 93, 138, .08); border: 1px solid rgba(47, 93, 138, .2); border-radius: 14px; }
.code-box .code-label { margin: 0; }
.code-box .row { margin-top: 4px; }
.done-inline { margin: 8px 18px 24px; }
/* scrolled-to bubbles and the completion box stop above the sticky composer instead of behind it (M1.3 ②) */
.log > .msg, .done-inline { scroll-margin-bottom: 232px; }  /* dock ≈ 184px + hint line (M1.3.2 ①) */

@media (max-width: 560px) {
  .bubble, .bot-col { max-width: 84%; }
  .bot-col .bubble { max-width: 100%; }
  .photo-card { width: 84%; max-width: 84%; }
  .avatar-sm { width: 72px; height: 72px; border-radius: 12px; }
  .avatar-xs, .avatar-gap, .icon-col { width: 60px; }
  .avatar-xs { height: 60px; border-radius: 10px; }
}

/* researcher console (admin.html) */
.root.admin { max-width: 1100px; }
.root.admin input.code { text-transform: none; width: 18em; }
