:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --ink: #1f2328;
  --muted: #636c76;
  --line: #d8dbe0;
  --accent: #2f5d8a;
  --accent-ink: #ffffff;
  --ai: #eef2f6;
  --me: #e3efe6;
  --error: #b42318;
  --missing: #fbe9e7;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181c; --card: #1f2227; --ink: #e8e6e3; --muted: #9aa3ad; --line: #353a42;
    --accent: #6f9fd0; --accent-ink: #0d1117; --ai: #262b33; --me: #22302a; --error: #ff8a80; --missing: #3a2422;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  font-size: 16px; line-height: 1.75;
}
.bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--card);
}
.bar-title { font-weight: 600; font-size: 15px; }
.bar-progress { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.wrap { max-width: 760px; margin: 0 auto; padding: 20px 16px 64px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 22px 22px 18px; margin-bottom: 16px;
}
.card.center { text-align: center; }
h2 { font-size: 18px; line-height: 1.5; margin: 0 0 12px; }
.rich p { margin: 0 0 10px; }
.rich ul { margin: 0 0 12px; padding-left: 1.3em; }
.rich li { margin-bottom: 6px; }
.lead { font-size: 17px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.notice { background: var(--missing); border-radius: 6px; padding: 10px 12px; }
.error { color: var(--error); font-weight: 600; }
.row { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; align-items: center; }
.row.space { justify-content: space-between; margin-top: 8px; }
.btn {
  appearance: none; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  border-radius: 8px; padding: 10px 22px; font-size: 16px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn.ghost { background: transparent; color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
.btn:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* 質問 */
fieldset.q { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px 14px; margin: 0 0 14px; }
fieldset.q.missing { border-color: var(--error); background: var(--missing); }
legend { font-weight: 600; padding: 0 4px; }
.likert .scale { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 6px; }
.likert .opt {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0;
  border: 1px solid var(--line); border-radius: 6px; cursor: pointer; font-variant-numeric: tabular-nums;
}
.likert .opt input { margin: 0; width: 18px; height: 18px; }
.likert .ends { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; margin-top: 4px; }
.choices { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.choice { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.choice input { width: 18px; height: 18px; margin: 0; }
.sub { margin: 10px 0 4px; color: var(--muted); font-size: 14px; }
textarea, input.num {
  width: 100%; font: inherit; color: inherit; background: var(--bg);
  border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px;
}
input.num { max-width: 8em; }

/* 会話 */
.chatlog, .transcript { display: flex; flex-direction: column; gap: 12px; }
.chatlog { max-height: 58vh; overflow-y: auto; padding: 4px 2px 8px; }
.transcript { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 18px; max-height: 50vh; overflow-y: auto; }
.msg { display: flex; flex-direction: column; max-width: 88%; }
.msg.ai { align-self: flex-start; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.who { font-size: 12px; color: var(--muted); margin: 0 4px 2px; }
.bubble { padding: 10px 14px; border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.ai .bubble { background: var(--ai); border-top-left-radius: 4px; }
.msg.user .bubble { background: var(--me); border-top-right-radius: 4px; }
.msg.typing .bubble { color: var(--muted); font-style: italic; }
.input { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }

/* 空き状況 */
.status-big { font-size: 22px; font-weight: 700; margin: 6px 0 8px; }
.status-open { color: #1a7f37; }
.status-full, .status-limit { color: #9a6700; }
.status-closed { color: var(--muted); }
@media (prefers-color-scheme: dark) { .status-open { color: #56d364; } .status-full, .status-limit { color: #e3b341; } }

@media (max-width: 560px) {
  .card { padding: 16px 14px 14px; }
  .likert .scale { gap: 3px; }
  .msg { max-width: 94%; }
}

/* 対の言葉の7段階(不気味さ指標) */
.likert.sd .ends { margin: 0 0 4px; color: var(--text, inherit); font-size: 14px; }
.likert.sd .opt { justify-content: center; }
/* 順位 */
.ranking .rankrow { display: flex; gap: 10px; align-items: center; margin: 6px 0; }
.ranking select { font-size: 16px; padding: 4px 6px; }
.likert.p5 .scale { grid-template-columns: repeat(5, 1fr); }

/* 事前の確認: 評価してもらう発言 */
.stimulus { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 8px;
  padding: 14px; margin: 0 0 16px; position: sticky; top: 0; background: var(--card); z-index: 1; }
.stimulus .bubble { font-size: 17px; }
