/* ============================================================
   年末調整 還付・追徴額 かんたん計算ツール — style.css
   カラー: ロイヤルブルー (#1e40af メイン)
   ============================================================ */

:root {
  --primary:        #1e40af;
  --primary-hover:  #1d3a9e;
  --primary-light:  #3b82f6;
  --primary-rgb:    30, 64, 175;
  --accent:         #1e40af;
  --bg:             #f9f7f4;
  --surface:        #ffffff;
  --text:           #1a1a2e;
  --text-muted:     #6b7280;
  --text-weak:      #9ca3af;
  --border:         #e2e8f0;
  --radius:         12px;
  --radius-sm:      8px;
  --shadow:         0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.08);
  --shadow-hover:   0 4px 16px rgba(0,0,0,0.10), 0 1px 4px rgba(0,0,0,0.06);
  --transition:     0.15s ease;

  /* ステップカラー */
  --step-blue:      #eff6ff;
  --step-border:    #bfdbfe;
}

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

/* ============================================================
   ベース
   ============================================================ */
body {
  font-family: 'BIZ UDPGothic', -apple-system, BlinkMacSystemFont,
               "Hiragino Sans", "Noto Sans JP", "Yu Gothic Medium", sans-serif;
  font-size: 1rem;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

/* ============================================================
   ヘッダー
   ============================================================ */
header {
  background: linear-gradient(135deg, #1e40af 0%, #1d4ed8 60%, #2563eb 100%);
  color: #fff;
  padding: 2rem 1.25rem 1.75rem;
  text-align: center;
}

.header-inner {
  max-width: 700px;
  margin: 0 auto;
}

.header-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  opacity: 0.92;
}

header h1 {
  font-family: 'Outfit', 'BIZ UDPGothic', sans-serif;
  font-size: clamp(1.3rem, 4vw, 1.9rem);
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: 0.01em;
}

.subtitle {
  font-size: 0.9rem;
  opacity: 0.88;
  margin-top: 0.5rem;
  line-height: 1.5;
}

/* ============================================================
   メインコンテナ
   ============================================================ */
main {
  max-width: 820px;
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
}

@media (min-width: 640px) {
  main {
    padding: 1.5rem 1.5rem 3rem;
  }
}

/* ============================================================
   広告ユニット
   ============================================================ */
.ad-unit {
  min-height: 0;
  margin: 1.5rem 0;
}

/* ============================================================
   プライバシー通知
   ============================================================ */
.privacy-notice {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm);
  padding: 0.65rem 1rem;
  font-size: 0.8125rem;
  color: #1e40af;
  margin-bottom: 1.25rem;
}

.privacy-notice i {
  flex-shrink: 0;
  font-size: 1rem;
}

/* ============================================================
   ツールセクション
   ============================================================ */
.tool-section {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ============================================================
   ステップカード
   ============================================================ */
.step-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,0.05);
  transition: box-shadow var(--transition);
}

.step-card:hover {
  box-shadow: var(--shadow-hover);
}

.step-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.875rem;
  border-bottom: 1.5px solid var(--step-border);
}

.step-badge {
  background: var(--primary);
  color: #fff;
  font-family: 'Outfit', sans-serif;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  white-space: nowrap;
}

.step-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.step-title i {
  color: var(--primary);
  font-size: 1.1rem;
}

/* ============================================================
   フィールドグリッド
   ============================================================ */
.fields-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.125rem;
}

@media (min-width: 560px) {
  .fields-grid {
    grid-template-columns: 1fr 1fr;
  }

  .field.full-width {
    grid-column: 1 / -1;
  }
}

/* ============================================================
   フィールド
   ============================================================ */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.field-label {
  font-size: 0.875rem;
  font-weight: 700;
  color: #374151;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-wrap: wrap;
}

.field-required {
  font-size: 0.6875rem;
  font-weight: 700;
  color: #fff;
  background: #dc2626;
  padding: 0.1rem 0.45rem;
  border-radius: 100px;
}

.field-hint-inline {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
}

.field-hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.field-hint-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.25rem;
}

/* ============================================================
   入力フィールド
   ============================================================ */
input[type="number"],
input[type="text"],
select {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  min-height: 44px;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
}

input[type="number"]:focus,
input[type="text"]:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

select {
  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='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
  cursor: pointer;
}

/* 数値入力のスピナー非表示 */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
}
input[type="number"] { -moz-appearance: textfield; }

/* ============================================================
   単位付き入力
   ============================================================ */
.input-with-unit {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.input-with-unit input {
  flex: 1;
}

.input-unit {
  font-size: 0.8125rem;
  color: var(--text-muted);
  white-space: nowrap;
  font-weight: 500;
}

/* ============================================================
   扶養家族入力行
   ============================================================ */
.dependent-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.dependent-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

/* ============================================================
   トグルグループ（社会保険料切替）
   ============================================================ */
.toggle-group {
  display: flex;
  gap: 0;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.toggle-btn {
  flex: 1;
  padding: 0.55rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: inherit;
  border: none;
  background: #fff;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  min-height: 44px;
  line-height: 1.3;
  text-align: center;
}

.toggle-btn:first-child {
  border-right: 1.5px solid var(--border);
}

.toggle-btn.active {
  background: var(--primary);
  color: #fff;
}

.toggle-btn:hover:not(.active) {
  background: var(--step-blue);
  color: var(--primary);
}

/* ============================================================
   計算ボタン
   ============================================================ */
.btn-calculate {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.875rem 1.5rem;
  font-size: 1.0625rem;
  font-weight: 700;
  font-family: inherit;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-height: 54px;
  transition: background var(--transition), transform 0.12s ease, box-shadow var(--transition);
  box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.35);
  margin-top: 0.25rem;
}

.btn-calculate i {
  font-size: 1.15rem;
}

.btn-calculate:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(var(--primary-rgb), 0.4);
}

.btn-calculate:active {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(var(--primary-rgb), 0.25);
}

/* ============================================================
   結果セクション
   ============================================================ */
.result-section {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* メイン結果カード */
.result-main {
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem;
  text-align: center;
  box-shadow: var(--shadow);
}

.result-main.refund {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border: 1.5px solid #93c5fd;
}

.result-main.surcharge {
  background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
  border: 1.5px solid #fdba74;
}

.result-label-top {
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 0.375rem;
}

.result-main.refund .result-label-top { color: #1e40af; }
.result-main.surcharge .result-label-top { color: #c2410c; }

.result-value {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(2.5rem, 8vw, 4rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.result-main.refund .result-value { color: #1d4ed8; }
.result-main.surcharge .result-value { color: #ea580c; }

.result-sub {
  font-size: 0.875rem;
  margin-top: 0.5rem;
  opacity: 0.8;
}

/* 詳細テーブル */
.result-details {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,0.05);
  overflow: hidden;
}

.detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.125rem;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-row:hover {
  background: #f8fafc;
}

.detail-row.highlight {
  background: var(--step-blue);
  font-weight: 700;
}

.detail-row.highlight:hover {
  background: #dbeafe;
}

.detail-row.ref-row {
  background: #f9fafb;
  opacity: 0.85;
}

.detail-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.detail-label i {
  color: var(--primary-light);
  font-size: 0.9375rem;
}

.detail-row.highlight .detail-label {
  color: var(--primary);
  font-weight: 700;
}

.detail-value {
  font-family: 'Outfit', sans-serif;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  text-align: right;
}

.detail-row.highlight .detail-value {
  font-size: 1.0625rem;
  color: var(--primary);
}

/* ============================================================
   グラフカード
   ============================================================ */
.chart-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,0.05);
}

.chart-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.chart-title i {
  color: var(--primary);
}

.chart-wrap {
  position: relative;
  height: 260px;
}

@media (min-width: 560px) {
  .chart-wrap { height: 300px; }
}

/* ============================================================
   結果注意書き
   ============================================================ */
.result-note {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.6;
  padding: 0.75rem 1rem;
  background: #f9fafb;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.result-note i {
  flex-shrink: 0;
  margin-top: 0.1rem;
  color: var(--primary-light);
}

/* ============================================================
   使い方セクション
   ============================================================ */
.howto-section {
  margin-top: 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.howto-section > h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--step-border);
}

.howto-section > h2 i {
  color: var(--primary);
}

/* ============================================================
   アコーディオン
   ============================================================ */
.accordion-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.accordion-item {
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.accordion-item[open] {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.08);
}

.accordion-summary {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  list-style: none;
  min-height: 48px;
  transition: background var(--transition);
  user-select: none;
}

.accordion-summary::-webkit-details-marker { display: none; }

.accordion-summary:hover {
  background: var(--step-blue);
  color: var(--primary);
}

.accordion-item[open] .accordion-summary {
  background: var(--step-blue);
  color: var(--primary);
}

.accordion-num {
  font-family: 'Outfit', sans-serif;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--primary);
  background: #dbeafe;
  padding: 0.15rem 0.5rem;
  border-radius: 100px;
  white-space: nowrap;
  flex-shrink: 0;
}

.accordion-icon {
  margin-left: auto;
  font-size: 0.875rem;
  color: var(--text-muted);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.accordion-item[open] .accordion-icon {
  transform: rotate(180deg);
  color: var(--primary);
}

.accordion-body {
  padding: 0 1rem 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.75;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

/* ============================================================
   About・FAQ セクション
   ============================================================ */
.about-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,0.05);
}

.about-section h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.about-section h2 i { color: var(--primary); }

.about-section p {
  font-size: 0.9rem;
  color: #4b5563;
  line-height: 1.8;
  margin-bottom: 0.75rem;
}

.about-section p:last-child { margin-bottom: 0; }

.faq-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.faq-section h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.faq-section h2 i { color: var(--primary); }

/* ============================================================
   フッター
   ============================================================ */
footer {
  text-align: center;
  padding: 2rem 1rem;
  font-size: 0.85rem;
  color: #9ca3af;
  border-top: 1px solid var(--border);
  margin-top: 1rem;
}

footer a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
}

footer a:hover {
  color: var(--primary);
}

footer p + p {
  margin-top: 0.25rem;
}

/* ============================================================
   レスポンシブ
   ============================================================ */
@media (min-width: 640px) {
  .step-card {
    padding: 1.5rem;
  }

  .result-main {
    padding: 2rem 2rem;
  }

  .result-details .detail-row {
    padding: 0.875rem 1.5rem;
  }

  .chart-card {
    padding: 1.5rem;
  }

  .about-section {
    padding: 1.5rem;
  }
}
