:root {
  --purple: #673ab7;
  --purple-dark: #5e35b1;
  --bg: #f0ebf8;
  --text: #202124;
  --sub: #5f6368;
  --line: #dadce0;
  --red: #d93025;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Roboto, "Noto Sans JP", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

.container {
  max-width: 640px;
  margin: 12px auto 40px;
  padding: 0 16px;
}

.card {
  position: relative;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 12px;
  overflow: hidden;
  transition: box-shadow .2s;
}

/* フォーカス中は左に紫の帯 */
.question::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 6px;
  background: transparent;
  transition: background .2s;
}
.question:focus-within::before { background: #4285f4; }

.header-card {
  border-top: 10px solid var(--purple);
  padding-top: 22px;
}
.header-card h1 {
  font-size: 32px;
  font-weight: 400;
  margin: 0 0 12px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.header-card .desc { margin: 0; }
.header-card hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 16px -24px 12px;
}
.required-note { color: var(--red); margin: 0; font-size: 14px; }

.q-title {
  display: block;
  font-size: 16px;
  letter-spacing: .1px;
  margin-bottom: 16px;
}
.req { color: var(--red); }

/* 下線だけのテキストフィールド */
.text-field {
  position: relative;
  width: 50%;
  min-width: 220px;
}
.text-field input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 6px 0;
  font: inherit;
  font-size: 14px;
  outline: none;
  background: transparent;
}
.text-field::after {
  content: "";
  position: absolute;
  left: 50%; right: 50%; bottom: 0;
  height: 2px;
  background: var(--purple);
  transition: left .25s, right .25s;
}
.text-field:focus-within::after { left: 0; right: 0; }

/* ラジオ */
.radio-list { display: flex; flex-direction: column; gap: 4px; }
.radio {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  cursor: pointer;
  width: fit-content;
}
.radio input {
  appearance: none;
  width: 20px; height: 20px;
  margin: 0;
  border: 2px solid var(--sub);
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.radio input::after {
  content: "";
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--purple);
  transform: scale(0);
  transition: transform .15s;
}
.radio input:checked { border-color: var(--purple); }
.radio input:checked::after { transform: scale(1); }



/* エラー */
.error-msg {
  display: none;
  color: var(--red);
  font-size: 12px;
  margin: 12px 0 0;
  align-items: center;
  gap: 8px;
}
.err-icon {
  display: inline-grid;
  place-items: center;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-weight: 700;
  font-size: 11px;
}
.has-error { border-color: var(--red); }
.has-error .error-msg { display: flex; }
.has-error .text-field input { border-bottom-color: var(--red); }

/* ボタン類 */
.actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 12px 0 24px;
}
.submit-slot { min-width: 96px; min-height: 36px; }
.btn-submit {
  background: var(--purple);
  color: #fff;
  border: 0;
  border-radius: 4px;
  padding: 0 24px;
  height: 36px;
  font: inherit;
  font-weight: 500;
  letter-spacing: .25px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15);
  z-index: 50;
}
.btn-submit:hover { background: var(--purple-dark); }
.btn-submit.fleeing {
  position: fixed;
  transition: left .18s ease-out, top .18s ease-out;
}

.btn-text {
  background: none;
  border: 0;
  color: var(--purple);
  font: inherit;
  font-weight: 500;
  padding: 8px;
  border-radius: 4px;
  cursor: pointer;
}
.btn-text:hover { background: rgba(103,58,183,.06); }

.footer {
  color: var(--sub);
  font-size: 12px;
  text-align: center;
}

/* ダイアログ */
.dialog-layer {
  position: fixed;
  inset: 0;
  background: rgba(32,33,36,.6);
  z-index: 100;
}
.dialog {
  position: fixed;
  left: 50%; top: 50%;
  width: min(400px, calc(100vw - 32px));
  background: #fff;
  border-radius: 8px;
  padding: 24px 24px 8px;
  box-shadow: 0 11px 15px -7px rgba(0,0,0,.2), 0 24px 38px 3px rgba(0,0,0,.14);
  animation: pop .15s ease-out;
}
@keyframes pop {
  from { opacity: 0; scale: .92; }
  to { opacity: 1; scale: 1; }
}
.dialog h2 {
  font-size: 20px;
  font-weight: 400;
  margin: 0 0 12px;
  word-break: break-all;
}
.dialog p { color: var(--sub); margin: 0 0 16px; }
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* 長文回答 */
.text-field.long { width: 100%; }
.text-field textarea {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 6px 0;
  font: inherit;
  font-size: 14px;
  outline: none;
  resize: none;
  overflow: hidden;
  background: transparent;
}
.has-error .text-field textarea { border-bottom-color: var(--red); }

/* 均等目盛（5段階） */
.scale {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  overflow-x: auto;
}
.scale-label { padding-bottom: 6px; color: var(--text); white-space: nowrap; }
.scale-cells { display: flex; gap: 0; padding: 0; width: auto; }
.scale-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 48px;
  cursor: pointer;
}

/* 確認ダイアログの中身 */
.summary {
  margin: 0 0 16px;
  max-height: 40vh;
  overflow-y: auto;
  font-size: 13px;
}
.summary dt { color: var(--sub); margin-top: 8px; }
.summary dd { margin: 2px 0 0; word-break: break-all; }
.muted { color: #9aa0a6; }

.spinner {
  width: 36px; height: 36px;
  margin: 8px auto 20px;
  border: 4px solid #e8def8;
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 完了画面 */
.link { color: #1a73e8; text-decoration: underline; }
.sequel {
  animation: pop .2s ease-out;
}
.sequel p { margin: 0 0 8px; }
.sequel .btn-submit { margin-top: 12px; }

@media (max-width: 480px) {
  .scale { gap: 4px; }
  .scale-cell { width: 30px; }
  .scale-label { white-space: normal; max-width: 3.5em; font-size: 12px; line-height: 1.3; }
  .header-card h1 { font-size: 24px; }
  .text-field { width: 100%; }
}
