:root {
  --ink: #1b1b1b;
  --paper: #ffffff;
  --bg: #f6f4ee;
  --line: #e2ded3;
  --mute: #6a675f;
  --soft: #f1eee6;
  --caution: #ffd400;      /* 工事現場の黄色 */
  --caution-soft: #fff6c2;
  --ok: #1f9d61;
  --warn: #d9730d;
  --danger: #c62828;
  --line-green: #06c755;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
[hidden] { display: none !important; }

/* 上部バー */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--ink);
  color: #fff;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: .04em;
  text-decoration: none;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--caution);
  color: var(--ink);
  font-size: 15px;
}
.clock { font-size: 12px; color: #cfcbc0; white-space: nowrap; }
.clock b { color: var(--caution); font-size: 15px; font-variant-numeric: tabular-nums; margin-left: 4px; }
.tape {
  height: 8px;
  background: repeating-linear-gradient(-45deg, var(--caution) 0 12px, var(--ink) 12px 24px);
}

.page {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 16px 32px;
}
.site-link { padding: 0 16px calc(24px + env(safe-area-inset-bottom)); font-size: 11px; text-align: center; }
.site-link a { color: var(--mute); }

/* 質問 */
.progress { display: flex; gap: 6px; margin-bottom: 18px; }
.progress span { flex: 1; height: 5px; border-radius: 3px; background: var(--line); }
.progress .is-done { background: var(--ink); }
.lead { font-size: 13px; color: var(--mute); margin-bottom: 4px; }
.question { font-size: 22px; line-height: 1.4; font-weight: 800; }
.hint { font-size: 13px; color: var(--mute); margin-top: 4px; }

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.choice {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 60px;
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  font-weight: 700;
  font-size: 15px;
  line-height: 1.35;
  text-align: left;
}
.choice:active, .choice.is-picked { border-color: var(--ink); background: var(--caution-soft); }
.choice-emoji { font-size: 24px; line-height: 1; }
.choices.is-plain .choice { justify-content: center; text-align: center; font-size: 17px; }
.choices.is-plain .choice:last-child { grid-column: 1 / -1; }

.back {
  display: block;
  margin: 18px auto 0;
  padding: 10px 14px;
  border: 0;
  background: none;
  color: var(--mute);
  font-size: 14px;
  text-decoration: underline;
}

/* 確認 */
.summary { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.summary button {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  font-size: 14px;
  font-weight: 700;
}
.field-label { display: block; margin: 22px 0 8px; font-size: 13px; font-weight: 700; color: var(--mute); }
.segment { display: grid; grid-template-columns: repeat(3, 1fr); border: 2px solid var(--ink); border-radius: 12px; overflow: hidden; }
.segment button { padding: 10px 4px; border: 0; background: var(--paper); font-weight: 700; }
.segment button + button { border-left: 2px solid var(--ink); }
.segment button[aria-pressed="true"] { background: var(--ink); color: #fff; }
textarea {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  font-size: 16px;
  resize: vertical;
}
textarea:focus { outline: none; border-color: var(--ink); }

.primary {
  display: block;
  width: 100%;
  margin-top: 24px;
  padding: 16px;
  border: 0;
  border-radius: 14px;
  background: var(--caution);
  box-shadow: 0 4px 0 var(--ink);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: .06em;
}
.primary:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }

/* 作成中 */
.loading { display: grid; justify-items: center; gap: 18px; padding: 80px 0; }
.spinner {
  width: 48px;
  height: 48px;
  border: 5px solid var(--line);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.loading-text { font-weight: 700; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 結果 */
.notice {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fdecec;
  color: var(--danger);
  font-size: 13px;
}
.card {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-top: 5px solid var(--ink);
  border-radius: 12px;
  background: var(--paper);
}
.card-shoujiki { border-top-color: var(--ok); }
.card-bunan { border-top-color: #2f6fde; }
.card-fukakouryoku { border-top-color: var(--warn); }
.card-warai { border-top-color: #d6409f; }
.card-type { font-size: 12px; font-weight: 700; color: var(--mute); }
.card h2 { font-size: 18px; line-height: 1.4; }
.message {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--soft);
  font-size: 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.actions { display: flex; gap: 8px; margin-top: 10px; }
.actions > * {
  flex: 1;
  padding: 11px 8px;
  border: 0;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}
.copy, .mail { background: var(--ink); color: #fff; }
.line { background: var(--line-green); color: #fff; }

.meter { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 13px; color: var(--mute); }
.meter-bar { flex: 1; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.meter-bar i { display: block; height: 100%; background: var(--ok); }
.meter b { min-width: 3em; text-align: right; font-size: 15px; color: var(--ink); font-variant-numeric: tabular-nums; }
.meter-mid .meter-bar i { background: var(--warn); }
.meter-low .meter-bar i { background: var(--danger); }

.risk, .tip { margin-top: 8px; font-size: 13px; }
.risk b, .tip b {
  display: inline-block;
  margin-right: 8px;
  padding: 0 6px;
  border-radius: 4px;
  background: var(--caution);
  font-size: 12px;
}
.followup { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 10px; font-size: 14px; }
.followup summary { font-weight: 700; cursor: pointer; }
.followup p { margin-top: 6px; padding-left: 14px; }
.tip { margin-top: 18px; padding: 12px; border-radius: 10px; background: var(--caution-soft); font-size: 14px; }
.footnote { margin-top: 20px; font-size: 12px; color: var(--mute); text-align: center; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
