/* ============================================================
   電話かけサポートシステム - スタイル
   高齢ボランティア向け: 大きなタップ領域(最小56px)・入力18px以上
   （iOS の自動ズーム防止）・WCAG AA コントラスト
   ============================================================ */

:root {
  /* だいだい（参政党カラー）を基調にする。
     鮮やかなだいだい #f08300 は白文字とのコントラストが 2.6:1 しかなく
     高齢の方には読みにくいため、白文字を載せる面には濃いだいだいを使う。
     見出し・帯・枠線など「文字を載せない面」だけ鮮やかな方を使う。 */
  --brand: #f08300;        /* ブランドのだいだい（帯・見出し・枠線） */
  --brand-soft: #fff4e6;   /* だいだいの淡い背景 */
  --primary: #bc5a00;      /* 主ボタン（白文字 4.6:1 でAA適合） */
  --primary-dark: #a94f00; /* 押下時 */
  --call-green: #1a8f4a;   /* 発信ボタン・「話せた」（発信=緑は直感的なので維持） */
  --warn: #8a6a00;         /* 不在・留守電（ブランドだいだいと見分くよう黄土寄り） */
  --danger: #c53030;       /* 拒否・エラー */
  --neutral: #5f6672;      /* 補助テキスト・「番号違い」 */
  --bg: #fdf8f2;           /* だいだいをわずかに含んだ生成り色 */
  --card: #fff;
  --text: #1b1e23;
  --border: #e6d8c8;
  --radius: 12px;
  --tap: 56px;             /* 最小タップ高さ */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans",
    "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 8px 16px 88px; /* 下部はトーストと重ならない余白 */
}

/* ---------- ヘッダー ---------- */
/* 画面最上部のだいだいの帯でブランドを示す（文字は載せないので鮮やかな色を使える） */
body::before {
  content: "";
  display: block;
  height: 6px;
  background: var(--brand);
}

.app-header {
  text-align: center;
  padding: 12px 0 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
}
body[data-screen="auth"] .app-header {
  font-size: 18px;
  color: var(--primary);
  padding-top: 20px;
}

/* ---------- カード・見出し ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.center { text-align: center; }
.screen-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 12px;
}
.section-label {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 10px;
}

/* ---------- ボタン共通 ---------- */
button {
  font-family: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(29, 111, 220, 0.15);
}
.btn {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); }
.btn-huge { min-height: 76px; font-size: 21px; }
.btn-secondary {
  background: #fff;
  color: var(--neutral);
  border: 2px solid var(--border);
}
.btn-warn { background: var(--warn); color: #fff; }
button:disabled { opacity: 0.45; cursor: default; }

.text-link {
  background: none;
  border: none;
  color: var(--primary);
  text-decoration: underline;
  font-size: 15px;
  padding: 10px 8px;
  cursor: pointer;
}
.link-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ---------- 入力 ---------- */
input[type="text"],
textarea {
  width: 100%;
  font-family: inherit;
  font-size: 18px; /* 16px 未満だと iOS がフォーカス時に自動ズームする */
  padding: 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}
input[type="text"]:focus,
textarea:focus {
  border-color: var(--primary);
  outline: 2px solid rgba(29, 111, 220, 0.35);
}
.field-label {
  display: block;
  font-size: 15px;
  font-weight: 700;
  margin: 14px 0 6px;
}
.field-note {
  font-size: 14px;
  color: var(--neutral);
  margin: 8px 0 14px;
}
.auth-msg {
  background: #fdecec;
  color: #8f1f1f;
  border: 1px solid #efc4c4;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
  margin-bottom: 8px;
}

/* ---------- READY ---------- */
.greeting {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 10px;
}
.stat-chip {
  display: inline-block;
  background: #e8ecf2;
  color: #3c4250;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 15px;
  margin-bottom: 18px;
}

/* ---------- ローディング ---------- */
.loading-box {
  text-align: center;
  padding: 56px 0;
  color: var(--neutral);
  font-size: 16px;
}
.spinner {
  width: 44px;
  height: 44px;
  margin: 0 auto 16px;
  border: 4px solid rgba(29, 111, 220, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  /* アニメーションを止め、静的な表示+文言で代替 */
  .spinner { animation: none; }
  #toast { transition: none; }
}

/* ---------- 通話画面 ---------- */
.calling-top {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  flex-wrap: wrap;
}
.chip {
  display: inline-block;
  margin-left: auto;
  background: #e8ecf2;
  color: #3c4250;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 14px;
  white-space: nowrap;
}
.chip.warn {
  background: #fbf0dc;
  color: #7a5000; /* 小さめ文字でも AA を満たす濃い琥珀 */
}
.badge-recall {
  display: inline-block;
  background: #fbf0dc;
  color: #7a5000;
  border: 1px solid var(--warn);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 14px;
  font-weight: 700;
}
.contact-name {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.4;
  margin: 8px 0 4px;
  word-break: break-word;
}
.tel-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 72px;
  margin: 12px 0 6px;
  background: var(--call-green);
  color: #fff;
  border-radius: var(--radius);
  text-decoration: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(26, 143, 74, 0.3);
}
.tel-link:active { background: #157a3e; }
.tel-number {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 1px;
}
.tel-caption {
  text-align: center;
  font-size: 14px;
  color: var(--neutral);
  margin-bottom: 4px;
}
.extra-rows { margin-top: 10px; }
.extra-row {
  display: flex;
  gap: 10px;
  padding: 6px 0;
  border-top: 1px dashed var(--border);
  font-size: 16px;
}
.extra-label {
  color: var(--neutral);
  min-width: 5em;
  flex-shrink: 0;
}
.extra-value { word-break: break-word; }
.prev-box {
  background: #f3f5f8;
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 12px;
  font-size: 15px;
}
.prev-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--neutral);
  margin-bottom: 4px;
}

/* ---------- 結果ボタン ---------- */
.outcome-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.outcome-btn {
  min-height: var(--tap);
  background: #fff;
  border: 2px solid;
  border-radius: var(--radius);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}
.outcome-wide { grid-column: 1 / -1; }
.outcome-green { border-color: var(--call-green); color: var(--call-green); }
.outcome-amber { border-color: var(--warn); color: var(--warn); }
.outcome-red { border-color: var(--danger); color: var(--danger); }
.outcome-gray { border-color: var(--neutral); color: var(--neutral); }
.outcome-btn.selected { color: #fff; }
.outcome-btn.selected::before { content: "✓ "; }
.outcome-green.selected { background: var(--call-green); }
.outcome-amber.selected { background: var(--warn); }
.outcome-red.selected { background: var(--danger); }
.outcome-gray.selected { background: var(--neutral); }

#memo { margin-top: 12px; }
#btn-submit { margin-top: 12px; }
#btn-skip { margin-top: 12px; }

.autonext-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 2px 0;
  font-size: 16px;
  cursor: pointer;
}
.autonext-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  accent-color: var(--primary);
}

.skip-confirm {
  margin-top: 10px;
  background: #f3f5f8;
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  font-size: 16px;
}
.skip-confirm-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

/* ---------- バナー ---------- */
.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-size: 15px;
}
.banner-error {
  background: #fdecec;
  color: #8f1f1f;
  border: 1px solid #efc4c4;
}
.banner-info {
  background: #e8f1fd;
  color: #174e91;
  border: 1px solid #c3d8f3;
}
.banner-retry {
  background: #fff;
  color: inherit;
  border: 2px solid currentColor;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
}

/* オフライン: 常時表示バナー（sticky で先頭に固定） */
#offline-banner {
  position: sticky;
  top: 0;
  z-index: 70;
  background: var(--neutral);
  color: #fff;
  text-align: center;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 700;
}

/* ---------- トースト ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  z-index: 60;
  background: #1b1e23;
  color: #fff;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 16px;
  max-width: 90%;
  text-align: center;
  opacity: 0;
  transition: opacity 0.2s;
}
#toast.show { opacity: 1; }

/* ---------- 完了・エラー画面 ---------- */
#done-totals { margin: 10px 0 16px; }
#btn-recheck { margin-top: 8px; }
#btn-paused-retry { margin-top: 12px; }
