/* かんたん確認アプリ — 先方の画面
   375×812 を基準に設計。タップ対象は最低 52px。入力文字は16px以上（iOSのズーム防止）。
   配色は Baby Light Factory の資料と同じ「温かい紙 × 胡桃色の墨 × テラコッタ」に寄せている。 */

:root {
  color-scheme: light;
  --paper: #fbf8f2;
  --paper-2: #ffffff;
  --ink: #2b2620;
  --ink-2: #6a625a;
  --ink-3: #9a918a;
  --line: #e3dccf;
  --line-2: #cfc6b6;
  --accent: #b5683a;
  --accent-dark: #8e4f2a;
  --accent-soft: #f7ebe1;
  --teal: #5e7c72;
  --ok: #2d7a4a;
  --ok-soft: #e8f3ec;
  --err: #b03a2e;
  --err-soft: #fbeae8;
  --focus: #e0a24a;
  --radius: 18px;
  --tap: 52px;
  --shadow: 0 10px 30px rgba(43, 38, 32, .08);
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  background: var(--paper);
  scroll-behavior: smooth;
  overflow-x: clip;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: anywhere;
  overflow-x: clip;
}

button, input, textarea { font: inherit; }
button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

button:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.shell { width: min(100% - 28px, 640px); margin-inline: auto; }

.skip-link {
  position: fixed; z-index: 100; top: 8px; left: 8px;
  min-height: 44px; padding: 9px 14px;
  color: #fff; background: var(--ink); border-radius: 9px;
  transform: translateY(-150%);
}
.skip-link:focus { transform: none; }

/* ── ヘッダー ── */
.app-header {
  min-height: 64px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  min-height: 64px;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}
.brand-mark {
  display: grid; place-items: center;
  width: 38px; height: 38px;
  color: #fff; background: var(--accent);
  border-radius: 50%;
  font-size: 18px; font-weight: 900;
}
.brand-kicker, .brand-name, .save-pill { margin: 0; }
.brand-kicker { color: var(--ink-3); font-size: 12px; font-weight: 700; letter-spacing: .06em; }
.brand-name { font-size: 15px; font-weight: 800; line-height: 1.3; }
.save-pill {
  max-width: 120px; padding: 4px 10px;
  color: var(--ink-2); background: #fff;
  border: 1px solid var(--line); border-radius: 999px;
  font-size: 12px; font-weight: 700; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── 画面 ── */
.screen { padding: 20px 0 calc(28px + env(safe-area-inset-bottom)); }
.screen-center { min-height: calc(100dvh - 64px); display: grid; place-items: center; }

.card {
  padding: 24px 20px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-center { width: 100%; text-align: center; }

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 12px; font-size: clamp(22px, 6vw, 28px); line-height: 1.4; letter-spacing: .01em; }
h2 { margin-bottom: 6px; font-size: 20px; line-height: 1.4; }
p { margin-bottom: 12px; }
.lead { font-size: 16px; }
.muted { color: var(--ink-2); font-size: 14px; }

.eyebrow {
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 12px; font-weight: 800; letter-spacing: .12em;
}

.spinner {
  display: inline-block; width: 40px; height: 40px; margin-bottom: 16px;
  border: 4px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.status-icon {
  display: grid; place-items: center;
  width: 60px; height: 60px; margin: 0 auto 14px;
  border-radius: 50%; font-size: 30px; font-weight: 900;
}
.status-icon-error { color: var(--err); background: var(--err-soft); }
.status-icon-ok { color: var(--ok); background: var(--ok-soft); }

/* ── はじめに ── */
.meta-row {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px;
  margin: 18px 0;
}
.meta-row div {
  padding: 10px 6px; background: var(--accent-soft); border-radius: 12px; text-align: center;
}
.meta-row span, .meta-row strong { display: block; }
.meta-row span { color: var(--ink-2); font-size: 12px; font-weight: 700; }
.meta-row strong { margin-top: 2px; font-size: 15px; }

.assure { display: grid; gap: 8px; margin: 0 0 6px; padding: 0; list-style: none; font-size: 15px; }
.assure li { position: relative; padding-left: 26px; }
.assure li::before { content: "✓"; position: absolute; left: 2px; color: var(--ok); font-weight: 900; }

.resume-note { margin: 12px 0 0; color: var(--ok); font-size: 14px; font-weight: 800; text-align: center; }

/* ── ボタン ── */
.btn, .btn-text, .btn-icon {
  min-height: var(--tap);
  border-radius: 12px;
  cursor: pointer;
  font-weight: 800;
}
.btn { width: 100%; padding: 11px 16px; }
.btn-primary {
  color: #fff; background: var(--accent);
  border: 2px solid var(--accent);
  box-shadow: 0 6px 16px rgba(181, 104, 58, .22);
}
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-primary:disabled {
  color: #8f8781; background: #e8e2d8; border-color: #e8e2d8;
  box-shadow: none; cursor: not-allowed;
}
.btn-secondary {
  color: var(--ink); background: #fff;
  border: 2px solid var(--line-2);
}
.btn-large { min-height: 58px; margin-top: 18px; font-size: 18px; }
.btn-text {
  min-width: 72px; padding: 8px 10px;
  color: var(--accent-dark); background: transparent; border: 0;
  text-decoration: underline; text-underline-offset: 3px;
}
.btn-icon {
  width: 48px; padding: 0;
  color: var(--ink); background: #f3eee5;
  border: 1px solid var(--line); font-size: 26px;
}

/* ── 質問画面 ── */
.screen-q { padding-top: 0; }

.progress {
  position: sticky; z-index: 10; top: 0;
  margin-inline: -14px;
  padding: 10px 14px 10px;
  background: rgba(251, 248, 242, .96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.progress-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; min-height: 40px;
}
.progress-track { height: 8px; overflow: hidden; background: #e8e2d8; border-radius: 999px; }
.progress-track span {
  display: block; width: 0; height: 100%;
  background: linear-gradient(90deg, var(--accent), #d69068);
  border-radius: inherit; transition: width .2s ease;
}

.q-card { margin-top: 16px; padding: 22px 18px 18px; }
.q-number { margin-bottom: 6px; color: var(--accent); font-size: 13px; font-weight: 900; letter-spacing: .06em; }
.q-text { font-size: clamp(20px, 5.6vw, 24px); margin-bottom: 8px; }
.q-hint { color: var(--ink-2); font-size: 14px; margin-bottom: 6px; }

.options {
  display: grid; gap: 10px;
  margin: 16px 0 0; padding: 0; border: 0;
}
.opt {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 60px;
  padding: 12px 14px;
  background: #fff;
  border: 2px solid var(--line-2);
  border-radius: 14px;
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color .12s ease, background-color .12s ease, transform .06s ease;
}
.opt:active { transform: scale(.985); }
.opt input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.opt:focus-within { outline: 3px solid var(--focus); outline-offset: 3px; }
.opt-check {
  display: grid; place-items: center;
  width: 30px; height: 30px;
  color: transparent; background: #f3eee5;
  border: 2px solid var(--line-2); border-radius: 50%;
  font-weight: 900; font-size: 15px;
}
.opt.is-multi .opt-check { border-radius: 8px; }
.opt-label { display: block; font-size: 17px; font-weight: 700; line-height: 1.4; }
.opt-sel { display: none; color: var(--accent-dark); font-size: 12px; font-weight: 900; white-space: nowrap; }

.opt.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  border-width: 3px;
  padding: 11px 13px;
}
.opt.is-selected .opt-check { color: #fff; background: var(--accent); border-color: var(--accent); }
.opt.is-selected .opt-sel { display: inline; }

.other-panel, .text-panel {
  margin-top: 14px; padding: 14px;
  background: #fffaf3; border: 1px solid #ecdcc4; border-radius: 12px;
}
.field { display: grid; gap: 6px; font-weight: 800; }
.field span { font-size: 14px; }
.field input, .field textarea {
  width: 100%; min-height: var(--tap);
  padding: 12px 13px;
  color: var(--ink); background: #fff;
  border: 1px solid #b9ad9a; border-radius: 11px;
  font-size: 16px; line-height: 1.55; font-weight: 500;
}
.field textarea { min-height: 112px; resize: vertical; }
.field-meta { margin: 6px 0 0; color: var(--ink-3); font-size: 13px; text-align: right; }
.field-error { margin: 10px 0 0; color: var(--err); font-size: 14px; font-weight: 800; }

.step-nav {
  position: sticky; z-index: 9; bottom: 0;
  display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 10px;
  margin: 16px -14px 0;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: rgba(251, 248, 242, .97);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

/* ── まとめ ── */
.summary-list { display: grid; gap: 9px; margin: 16px 0; }
.summary-item {
  width: 100%; min-height: 58px;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 11px 13px;
  color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: 12px;
  text-align: left; cursor: pointer;
}
.summary-item strong, .summary-item small { display: block; }
.summary-item strong { font-size: 14px; color: var(--ink-2); font-weight: 700; }
.summary-item small { margin-top: 3px; font-size: 16px; color: var(--ink); font-weight: 700; }
.summary-item .badge { padding: 4px 9px; border-radius: 999px; font-size: 12px; font-weight: 900; white-space: nowrap; }
.badge-ok { color: var(--ok); background: var(--ok-soft); }
.badge-missing { color: var(--err); background: var(--err-soft); }
.badge-skip { color: var(--ink-2); background: #f0ebe2; }

.summary-actions { display: grid; gap: 10px; margin-top: 16px; }

/* ── 警告・トースト ── */
.warning {
  display: grid; gap: 6px;
  margin: 14px 0 0; padding: 13px 14px;
  color: #5f2b00; background: #fff3d6;
  border: 2px solid #d8872c; border-radius: 12px;
}
.warning .btn-secondary { margin-top: 4px; color: #5f2b00; border-color: #b96b1d; }

.toast {
  position: fixed; z-index: 200; left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  width: min(calc(100% - 28px), 420px);
  padding: 11px 14px;
  color: #fff; background: var(--ink);
  border-radius: 10px; box-shadow: 0 10px 30px rgba(43, 38, 32, .25);
  font-size: 14px; font-weight: 800; text-align: center;
  transform: translate(-50%, 140%); opacity: 0;
  transition: transform .18s ease, opacity .18s ease;
  pointer-events: none;
}
.toast.is-visible { transform: translate(-50%, 0); opacity: 1; }

/* ── 一覧ダイアログ ── */
.list-dialog {
  width: min(calc(100% - 20px), 600px);
  max-height: min(86dvh, 720px);
  margin: auto; padding: 0;
  color: var(--ink); background: #fff;
  border: 0; border-radius: 18px;
  box-shadow: 0 22px 70px rgba(43, 38, 32, .28);
}
.list-dialog::backdrop { background: rgba(43, 38, 32, .5); }
.dialog-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: #fff; border-bottom: 1px solid var(--line);
}
.dialog-head p, .dialog-head h2 { margin: 0; }
.dialog-list { display: grid; gap: 8px; padding: 12px 16px calc(18px + env(safe-area-inset-bottom)); }
.dialog-item {
  width: 100%; min-height: 54px;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 10px 11px;
  color: var(--ink); background: #faf7f1;
  border: 1px solid var(--line); border-radius: 10px;
  text-align: left; cursor: pointer;
}
.dialog-item strong, .dialog-item small { display: block; }
.dialog-item strong { font-size: 14px; }
.dialog-item small { color: var(--ink-2); font-size: 13px; }

@media (min-width: 700px) {
  .screen { padding-top: 32px; }
  .card { padding: 30px; }
  .summary-actions { grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); }
}

@media (max-width: 359px) {
  .shell { width: min(100% - 20px, 640px); }
  .header-inner { grid-template-columns: 36px minmax(0, 1fr); }
  .save-pill { grid-column: 1 / -1; max-width: none; margin-bottom: 6px; }
  .meta-row { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
