/* ============================================================
   住宅需要エリア分析ツール — style.css
   ============================================================ */

/* ── リセット ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── デザイントークン ── */
:root {
  --bg:           #FDF4EA;
  --surface:      #FFFFFF;
  --surface2:     #F5EAD8;
  --border:       rgba(73,167,206,0.15);
  --border2:      rgba(73,167,206,0.30);
  --text:         #2C2C2C;
  --muted:        #7A7A7A;
  --accent:       #49A7CE;
  --accent-dark:  #3388AD;
  --accent-light: rgba(73,167,206,0.10);
  --accent-glow:  rgba(73,167,206,0.20);
  --success:      #2DA870;
  --warning:      #D48A10;
  --danger:       #D64545;
  --success-bg:   rgba(45,168,112,0.09);
  --warning-bg:   rgba(212,138,16,0.09);
  --danger-bg:    rgba(214,69,69,0.09);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

/* ── ベース ── */
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Sans JP', sans-serif;
  font-weight: 400;
  min-height: 100vh;
  line-height: 1.7;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================
   ヘッダー
   ============================================================ */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border2);
  padding: 0 2rem;
}
.header-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 1.2rem 0;
  display: flex;
  align-items: center;
  gap: 14px;
}
.logo-link {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  text-decoration: none;
}
.logo-img {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: block;
}
.logo-text {
  font-family: 'Outfit', sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.logo-text small {
  display: block;
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--muted);
  font-family: 'Noto Sans JP', sans-serif;
  letter-spacing: 0;
}
.header-free-badge {
  background: var(--accent);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  padding: 0.28rem 0.75rem;
  border-radius: 999px;
  white-space: nowrap;
  font-family: 'Noto Sans JP', sans-serif;
}

.header-usage-count {
  margin-left: auto;
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--muted);
  font-family: 'Noto Sans JP', sans-serif;
  white-space: nowrap;
  flex-shrink: 0;
}
.header-usage-count strong {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  color: var(--accent-dark);
}

/* ============================================================
   ヒーロー
   ============================================================ */
.hero {
  background: linear-gradient(135deg, #FDF4EA 0%, #FEF1DA 50%, #FDF4EA 100%);
  border-bottom: 2px solid rgba(73,167,206,0.15);
  padding: 2.8rem 2rem 0;
  overflow: hidden;
}
.hero-inner {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 1rem;
}
.hero-text {
  flex: 1;
  padding-bottom: 2.5rem;
}
.hero h1 {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(1.5rem, 4vw, 2.1rem);
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  letter-spacing: -0.02em;
  margin-bottom: 0.9rem;
}
.hero h1 em {
  font-style: normal;
  color: var(--accent);
}
.hero-lead {
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.8;
  max-width: 480px;
  margin-bottom: 1.4rem;
}
.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.hero-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  background: #fff;
  border: 1px solid var(--border2);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font-size: 0.8rem;
  color: var(--text);
  font-weight: 500;
}
.badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #AAAAAA;
  flex-shrink: 0;
  display: inline-block;
}
.hero-chara {
  flex-shrink: 0;
  width: 300px;
  height: 300px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
}
.hero-chara img {
  width: 300px;
  height: 300px;
  object-fit: contain;
  object-position: bottom;
  display: block;
}

/* ============================================================
   ツール本体
   ============================================================ */
.tool-section {
  max-width: 860px;
  margin: 0 auto;
  padding: 2.5rem 2rem 4rem;
}
.tool-heading {
  font-family: 'Outfit', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tool-heading::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 1.1em;
  background: var(--accent);
  border-radius: 2px;
  flex-shrink: 0;
}

/* ============================================================
   検索パネル（入力カード）
   ============================================================ */
.input-card {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 2rem 2.25rem;
  box-shadow: 0 2px 16px rgba(73,167,206,0.07);
  margin-bottom: 2rem;
}
.input-card h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

/* タブ */
.mode-tabs {
  display: flex;
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 1.5rem;
}
.mode-tab {
  flex: 1;
  padding: 0.6rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: var(--surface);
  color: var(--muted);
  font-family: 'Noto Sans JP', sans-serif;
  transition: background 0.15s, color 0.15s;
  border-right: 1px solid var(--border2);
  text-align: center;
}
.mode-tab:last-child { border-right: none; }
.mode-tab.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* フォーム行 */
.form-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.1rem;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  flex: 1;
  min-width: 140px;
}
.field-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.form-group select {
  padding: 0.7rem 1rem;
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237A7A7A' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* 比較チェックボックス */
.compare-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  margin-bottom: 0.75rem;
  user-select: none;
  width: fit-content;
}
.compare-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}
.compare-toggle span {
  font-size: 0.855rem;
  color: var(--muted);
}
.compare-row {
  display: none;
  margin-bottom: 1rem;
  animation: fadeIn 0.2s ease;
}
.compare-row.visible { display: block; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* オプション行 */
.option-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.option-label {
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  min-width: 80px;
}
.radio-group, .check-group {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.radio-group label, .check-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  cursor: pointer;
  color: var(--text);
}
.radio-group input, .check-group input {
  accent-color: var(--accent);
  cursor: pointer;
}

/* 年齢グリッド */
.age-section-label {
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.6rem;
  display: block;
}
.age-quick {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.age-quick-btn {
  padding: 0.35rem 0.85rem;
  font-size: 0.8rem;
  border: 1px solid var(--border2);
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  font-family: 'Noto Sans JP', sans-serif;
  transition: all 0.15s;
}
.age-quick-btn:hover { border-color: var(--accent); color: var(--accent-dark); background: var(--accent-light); }
.age-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.age-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--muted);
  transition: all 0.15s;
  user-select: none;
}
.age-checkbox:hover { border-color: var(--accent); background: var(--accent-light); color: var(--accent-dark); }
.age-checkbox:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent-dark);
  font-weight: 500;
}
.age-checkbox input { display: none; }

/* 区切り線 */
.form-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.25rem 0;
}

/* 実行ボタン */
.btn-run {
  width: 100%;
  padding: 0.9rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.03em;
  transition: background 0.15s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-run:hover  { background: var(--accent-dark); }
.btn-run:active { transform: scale(0.99); }
.btn-run:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* ============================================================
   結果エリア
   ============================================================ */
.result-area { display: none; }
.result-area.visible { display: block; }

.result-card {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 2px 16px rgba(73,167,206,0.07);
}
.result-card-header {
  padding: 1.25rem 1.75rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  background: var(--surface2);
}
.result-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.result-meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 2px;
}
.result-actions { display: flex; gap: 0.5rem; align-items: center; }
.btn-csv {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0.45rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--accent-dark);
  cursor: pointer;
  font-family: 'Noto Sans JP', sans-serif;
  font-weight: 500;
  transition: all 0.15s;
}
.btn-csv:hover { background: var(--accent-light); border-color: var(--accent); }

/* テーブル */
.table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 480px;
}
.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  white-space: nowrap;
}
.result-table th {
  background: var(--surface2);
  padding: 0.65rem 1rem;
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  border-bottom: 1px solid var(--border2);
  position: sticky;
  top: 0;
  z-index: 1;
}
.result-table th.num { text-align: right; }
.result-table th.sortable {
  cursor: pointer;
  user-select: none;
  padding-right: 22px;
}
.result-table th.sortable:hover { color: var(--accent-dark); background: #ede3d4; }
.result-table th.sort-asc::after  { content: ' ▲'; color: var(--accent); font-size: 0.68em; }
.result-table th.sort-desc::after { content: ' ▼'; color: var(--accent); font-size: 0.68em; }
.result-table td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
}
.result-table td.num {
  text-align: right;
  font-family: 'Outfit', sans-serif;
}
.result-table tr:last-child td { border-bottom: none; }
.result-table tr:hover td { background: var(--accent-light); }
.rank {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  color: var(--accent-dark);
}
.positive { color: var(--success); }
.negative { color: var(--danger); }
.neutral  { color: var(--muted); }

/* ローディング */
.loading-row td {
  padding: 3rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.875rem;
}
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 0.75rem;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty-msg { text-align: center; padding: 3rem; color: var(--muted); font-size: 0.875rem; }

/* ChatGPTボタン */
.btn-prompt {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 1rem;
  padding: 0.85rem 1.5rem;
  background: linear-gradient(135deg, #49A7CE, #3388AD);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  letter-spacing: 0.02em;
}
.btn-prompt:hover { opacity: 0.88; }

/* e-Stat表記 */
.estat-credit {
  font-size: 0.72rem;
  color: var(--muted);
  padding: 0.5rem 0 0;
  background: none;
  border: none;
  border-radius: 0;
}

/* プロンプトモーダル */
.prompt-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.5);
  padding: 20px;
  align-items: center;
  justify-content: center;
}
.prompt-modal.open { display: flex; }
.prompt-modal-inner {
  background: var(--surface);
  border-radius: var(--radius-lg);
  max-width: 760px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.prompt-modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border2);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.prompt-modal-header h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent-dark);
}
.prompt-modal-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}
.prompt-modal-close:hover { background: var(--surface2); }
.prompt-modal-body { padding: 1rem 1.5rem; overflow-y: auto; flex: 1; }
.prompt-note { font-size: 0.8rem; color: var(--muted); margin-bottom: 0.75rem; }
.prompt-textarea {
  width: 100%;
  height: 340px;
  padding: 1rem;
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.8rem;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  resize: vertical;
}
.prompt-modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  align-items: center;
  background: var(--surface2);
}
.btn-copy-prompt {
  padding: 0.6rem 1.5rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Outfit', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-copy-prompt:hover { background: var(--accent-dark); }
.btn-copy-prompt.copied { background: var(--success); }
.copy-note { font-size: 0.78rem; color: var(--muted); }

/* ============================================================
   コンテンツセクション
   ============================================================ */
.content-section {
  max-width: 860px;
  margin: 0 auto;
  padding: 3rem 2rem;
  border-top: 1px solid var(--border);
}
.section-heading {
  font-family: 'Outfit', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-heading::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 1.2em;
  background: var(--accent);
  border-radius: 2px;
  flex-shrink: 0;
}
.section-lead {
  color: var(--muted);
  font-size: 0.875rem;
  margin-bottom: 1.75rem;
}
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}
.feature-card {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.35rem;
  transition: box-shadow 0.15s;
}
.feature-card:hover { box-shadow: 0 4px 16px rgba(73,167,206,0.10); }
.feature-icon { font-size: 1.5rem; margin-bottom: 0.6rem; }
.feature-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.4rem;
}
.feature-desc { font-size: 0.83rem; color: var(--muted); line-height: 1.65; }

.usecase-list { display: flex; flex-direction: column; gap: 1rem; }
.usecase-item {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.35rem;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}
.usecase-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
  margin-top: 1px;
}
.usecase-body strong {
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.3rem;
}
.usecase-body p {
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.65;
  margin: 0;
}

/* ============================================================
   開発コスト表
   ============================================================ */
.cost-table-wrap { overflow-x: auto; }
.cost-table {
  width: 100%;
  max-width: 480px;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.cost-table th,
.cost-table td {
  padding: 0.7rem 1.1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.cost-table th {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: var(--surface2);
  text-transform: uppercase;
}
.cost-table td:nth-child(2),
.cost-table td:nth-child(3) { text-align: right; }
.cost-table th:nth-child(2),
.cost-table th:nth-child(3) { text-align: right; }
.cost-table-total td {
  font-weight: 600;
  color: var(--text);
  background: var(--accent-light);
  border-top: 2px solid var(--border2);
  border-bottom: none;
}

/* ============================================================
   レスポンシブ
   ============================================================ */
@media (max-width: 600px) {
  .hero h1 { font-size: 1.4rem; }
  .hero-chara { display: none; }
  .form-row { flex-direction: column; }
  .option-row { flex-direction: column; gap: 0.5rem; }
  .features-grid { grid-template-columns: 1fr; }
  .result-card-header { flex-direction: column; align-items: flex-start; }
  .header-usage-count { display: none; }
}
