:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f0eee9;
  --text: #1d1d1b;
  --muted: #6b6a66;
  --line: #e2dfd8;
  --accent: #1f5f5b;
  --accent-ink: #ffffff;
  --accent-soft: #e3efed;
  --warn: #a4532b;
  --warn-soft: #f7e9e1;
  --ok: #2f6f3e;
  --ok-soft: #e4f0e6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.05);
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "PingFang SC", system-ui, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 9px 18px; font-weight: 600; font-size: 15px; transition: background .15s, border-color .15s;
}
.btn:hover { border-color: #cfcbc2; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--warn); }
.btn.small { padding: 5px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

input[type=text], input[type=tel], input[type=email], input[type=date], input[type=number], input[type=password], textarea, select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  padding: 10px 12px; font-size: 16px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 80px; }
label.field { display: block; margin: 0 0 14px; }
label.field > span { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.req { color: var(--warn); font-weight: 600; margin-left: 4px; font-size: 12px; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: #2b2b29; color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px;
  z-index: 100; max-width: calc(100% - 32px); text-align: center; box-shadow: var(--shadow);
}

/* ---------- respondent ---------- */
.r-wrap { max-width: 640px; margin: 0 auto; padding: 24px 16px 40px; min-height: 100dvh; display: flex; flex-direction: column; }
.r-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.r-title { font-size: 22px; font-weight: 700; margin: 0 0 8px; line-height: 1.4; }
.r-desc { color: var(--muted); white-space: pre-wrap; margin: 0 0 18px; }
.r-section-title { font-size: 14px; font-weight: 700; margin: 22px 0 10px; color: var(--muted); }
.mode-list { display: grid; gap: 10px; }
.mode-opt {
  display: flex; gap: 14px; align-items: flex-start; text-align: left; width: 100%;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px; padding: 14px 16px;
}
.mode-opt[aria-pressed=true] { border-color: var(--accent); background: var(--accent-soft); }
.mode-opt .ico { width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; flex: none; }
.mode-opt[aria-pressed=true] .ico { background: var(--accent); color: #fff; }
.mode-opt b { display: block; font-size: 15px; }
.mode-opt small { color: var(--muted); font-size: 13px; line-height: 1.5; display: block; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); margin-top: 18px; }
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #cfccc5; border-radius: 999px; transition: .2s; }
.switch span::after { content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
.r-start { margin-top: 18px; width: 100%; padding: 14px; font-size: 17px; }
.privacy { font-size: 12px; color: var(--muted); margin-top: 12px; line-height: 1.6; }

.r-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.r-head h1 { font-size: 15px; margin: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; margin-bottom: 18px; }
.progress > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .4s; }

/* Q&A mode */
.qa-history { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.qa-history details { font-size: 14px; color: var(--muted); }
.qa-history summary { cursor: pointer; padding: 4px 0; }
.qa-pair { padding: 8px 0; border-bottom: 1px solid var(--line); }
.qa-pair .q { color: var(--muted); }
.qa-pair .a { color: var(--text); }
.qa-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 22px 18px; flex: none; }
.qa-question { font-size: 20px; font-weight: 600; line-height: 1.55; min-height: 2em; white-space: pre-wrap; }
.qa-tools { display: flex; gap: 8px; margin-top: 12px; }
.qa-answer { margin-top: 12px; padding: 10px 14px; background: var(--accent-soft); border-radius: 10px; font-size: 15px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.chip { border: 1.5px solid var(--line); background: var(--surface); border-radius: 999px; padding: 9px 16px; font-size: 15px; font-weight: 600; }
.chip[aria-pressed=true] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.chip.go { background: var(--accent); color: #fff; border-color: var(--accent); }
.dock { margin-top: auto; padding-top: 20px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.ptt {
  width: 96px; height: 96px; border-radius: 50%; border: none; background: var(--accent); color: #fff;
  display: grid; place-items: center; box-shadow: 0 6px 20px rgba(31, 95, 91, .3); position: relative;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; transition: transform .1s;
}
.ptt::before { content: ""; position: absolute; inset: -10px; border-radius: 50%; border: 3px solid var(--accent); opacity: 0; transform: scale(var(--lvl, 1)); transition: transform .08s, opacity .2s; }
.ptt.rec { transform: scale(1.08); background: #b0472a; box-shadow: 0 6px 24px rgba(176, 71, 42, .35); }
.ptt.rec::before { opacity: .35; border-color: #b0472a; }
.ptt:disabled { background: #9db5b2; box-shadow: none; }
.ptt svg, .orb svg { width: 36px; height: 36px; }
.dock-hint { font-size: 14px; color: var(--muted); min-height: 1.6em; text-align: center; }
.textbar { display: flex; gap: 8px; width: 100%; }
.textbar textarea { min-height: 46px; height: 46px; flex: 1; }
.linkbtn { background: none; border: none; color: var(--accent); font-size: 14px; padding: 4px 8px; text-decoration: underline; text-underline-offset: 3px; }

/* Chat mode */
.chat-stage { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 8px 0 14px; }
.orb {
  width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center; color: #fff;
  background: radial-gradient(circle at 35% 30%, #3c8a84, var(--accent) 60%, #164744);
  box-shadow: 0 8px 30px rgba(31, 95, 91, .35); transform: scale(var(--lvl, 1)); transition: transform .08s;
  border: none;
}
.orb.thinking { animation: breathe 1.4s ease-in-out infinite; }
.orb.speaking { background: radial-gradient(circle at 35% 30%, #4c9a8f, #2a7a6f 60%, #164744); }
.orb.muted { background: #a9a7a1; box-shadow: none; }
@keyframes breathe { 50% { transform: scale(.92); opacity: .85; } }
.chat-status { font-size: 15px; color: var(--muted); min-height: 1.6em; text-align: center; }
.log { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; flex: 1; min-height: 160px; max-height: 46dvh; padding: 4px 2px; }
.bubble { max-width: 86%; padding: 10px 14px; border-radius: 16px; font-size: 15px; line-height: 1.6; white-space: pre-wrap; }
.bubble.ai { background: var(--surface); box-shadow: var(--shadow); align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.me { background: var(--accent); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble.pending { opacity: .6; }
.bubble.cut::after { content: " …"; }
.chat-controls { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }

/* Form mode */
.f-q { padding: 18px 0; border-top: 1px solid var(--line); }
.f-q:first-of-type { border-top: none; }
.f-q > .t { font-weight: 600; margin-bottom: 10px; }
.f-opts { display: flex; flex-direction: column; gap: 8px; }
.f-opt { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; cursor: pointer; }
.f-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.f-opt input { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; }

.done-wrap { text-align: center; padding: 60px 10px; }
.done-wrap .mark { width: 72px; height: 72px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); display: grid; place-items: center; margin: 0 auto 18px; }
.done-wrap h2 { margin: 0 0 8px; }

/* ---------- admin ---------- */
.a-top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.a-top-in { max-width: 1120px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 14px; }
.a-brand { font-weight: 700; font-size: 16px; text-decoration: none; color: var(--text); display: flex; align-items: center; gap: 8px; }
.a-brand i { width: 26px; height: 26px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; color: #fff; font-style: normal; font-size: 14px; }
.a-main { max-width: 1120px; margin: 0 auto; padding: 24px 16px 60px; }
.a-h1 { font-size: 22px; margin: 0; }
.a-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.a-row.between { justify-content: space-between; }
.a-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.a-list { display: grid; gap: 10px; margin-top: 18px; }
.a-item { display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); padding: 16px 18px; }
.a-item:hover { outline: 1.5px solid var(--line); }
.a-item .grow { flex: 1; min-width: 0; }
.a-item b { display: block; font-size: 16px; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.open { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.acc { background: var(--accent-soft); color: var(--accent); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 18px 0 20px; overflow-x: auto; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.on { color: var(--accent); border-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
@media (max-width: 720px) { .grid2 { grid-template-columns: 1fr; } }
.seg { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.seg label { display: inline-flex; align-items: center; gap: 6px; border: 1.5px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: 14px; cursor: pointer; background: var(--surface); }
.seg label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.seg input { display: none; }
.q-card { background: var(--surface); border-radius: 12px; border: 1px solid var(--line); padding: 14px 16px; margin-bottom: 10px; }
.q-card .q-head { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.q-num { width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-size: 13px; font-weight: 700; flex: none; }
.q-card select { width: auto; padding: 6px 10px; font-size: 14px; }
.q-card .q-tools { margin-left: auto; display: flex; gap: 2px; }
.iconbtn { border: none; background: none; width: 32px; height: 32px; border-radius: 8px; color: var(--muted); display: grid; place-items: center; }
.iconbtn:hover { background: var(--surface-2); color: var(--text); }
.q-sub { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
@media (max-width: 720px) { .q-sub { grid-template-columns: 1fr; } }
.q-sub label > span { font-size: 13px; color: var(--muted); display: block; margin-bottom: 4px; }
.opt-editor { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.opt-row { display: flex; gap: 6px; align-items: center; }
.opt-row input { padding: 7px 10px; font-size: 15px; }
.add-q { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.savebar { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 18px 0 10px; display: flex; gap: 10px; justify-content: flex-end; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--surface); }
table.t th, table.t td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t th { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; background: var(--surface-2); }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #faf9f6; }
.tablewrap { overflow-x: auto; border-radius: 12px; box-shadow: var(--shadow); }
.ans-low { color: var(--warn); }
.bars { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.bar { display: grid; grid-template-columns: minmax(80px, 200px) 1fr 96px; gap: 10px; align-items: center; font-size: 14px; }
.bar .track { height: 12px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.bar .track i { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.bar .n { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.md h2 { font-size: 17px; margin: 18px 0 6px; }
.md h3 { font-size: 15px; margin: 14px 0 4px; }
.md p { margin: 6px 0; }
.md ul { margin: 6px 0; padding-left: 1.3em; }
.tr-line { padding: 8px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 70px 1fr; gap: 10px; font-size: 14px; }
.tr-line .who { color: var(--muted); font-size: 12px; font-weight: 600; padding-top: 2px; }
.tr-line.user .who { color: var(--accent); }
.ans-grid { display: grid; gap: 10px; }
.ans-item { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.ans-item .qt { font-size: 13px; color: var(--muted); }
.ans-item .v { font-weight: 700; margin: 4px 0; }
.ans-item .ev { font-size: 13px; color: var(--muted); }
.split { display: grid; grid-template-columns: 1.1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } }
.login-box { max-width: 360px; margin: 12vh auto; }
.linkbox { display: flex; gap: 8px; align-items: center; background: var(--surface-2); border-radius: 10px; padding: 8px 8px 8px 12px; font-size: 14px; }
.linkbox code { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
