/* ============================================================
   賃貸 vs 購入 トータルコスト比較シミュレーター
   Design System: 計算・金融ジャンル
   ============================================================ */

:root {
  /* 賃貸カラー */
  --rent: #f97316;
  --rent-hover: #ea6c0b;
  --rent-light: #fff7ed;
  --rent-border: #fed7aa;
  --rent-rgb: 249, 115, 22;

  /* 購入カラー */
  --buy: #2563eb;
  --buy-hover: #1d4ed8;
  --buy-light: #eff6ff;
  --buy-border: #bfdbfe;
  --buy-rgb: 37, 99, 235;

  /* プライマリ（汎用） */
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --primary-rgb: 29, 78, 216;

  /* ベース */
  --bg: #f9f7f4;
  --surface: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --text-weak: #9ca3af;
  --border: #e2e8f0;

  /* シャドウ */
  --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);

  /* その他 */
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.15s ease;
}

/* ============================================================
   Base
   ============================================================ */

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

html { scroll-behavior: smooth; }

body {
  font-family: 'BIZ UDPGothic', 'Hiragino Sans', 'Yu Gothic Medium', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  overflow-x: hidden;
  word-break: break-word;
}

img { max-width: 100%; }

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1rem 3rem;
}

/* ============================================================
   Header
   ============================================================ */

header {
  background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 60%, #2563eb 100%);
  color: #fff;
  padding: 2rem 1.25rem 1.75rem;
  text-align: center;
}

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

.header-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.badge-rent,
.badge-buy {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.9rem;
  border-radius: 100px;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
}
.badge-rent { background: rgba(249,115,22,0.22); border: 1.5px solid rgba(249,115,22,0.5); }
.badge-buy  { background: rgba(255,255,255,0.15); border: 1.5px solid rgba(255,255,255,0.4); }

.badge-vs {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 1.1rem;
  opacity: 0.7;
  letter-spacing: 0.05em;
}

header h1 {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(1.2rem, 3.5vw, 1.75rem);
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 0.4rem;
}

.header-sub {
  font-size: 0.9rem;
  opacity: 0.88;
}

/* ============================================================
   広告ユニット
   ============================================================ */

.ad-unit { min-height: 0; margin: 1.25rem 0; }

/* ============================================================
   プライバシー通知
   ============================================================ */

.privacy-notice {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  font-size: 0.8125rem;
  color: #166534;
  margin: 1rem 0;
}
.privacy-notice i { font-size: 1rem; flex-shrink: 0; }

/* ============================================================
   入力セクション
   ============================================================ */

.input-section {
  margin: 1rem 0;
}

/* 2カラムレイアウト */
.input-columns {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

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

.input-col {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,0.05);
  overflow: hidden;
}

.col-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1.25rem;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
}
.col-header-rent { background: linear-gradient(90deg, #ea580c, #f97316); }
.col-header-buy  { background: linear-gradient(90deg, #1d4ed8, #2563eb); }
.col-header i { font-size: 1.1rem; }

.fields-wrap { padding: 1.25rem; display: flex; flex-direction: column; gap: 1rem; }

/* 物件種別トグル */
.type-toggle-wrap {
  display: flex;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1.5px solid var(--buy-border);
}

.type-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
  min-height: 44px;
}
.type-btn.active {
  background: var(--buy);
  color: #fff;
}
.type-btn:not(.active):hover {
  background: var(--buy-light);
  color: var(--buy);
}

/* フォーム共通 */
.field { display: flex; flex-direction: column; gap: 5px; }

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

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

.optional-badge {
  background: #f3f4f6;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 400;
  padding: 0.1rem 0.45rem;
  border-radius: 100px;
}

.input-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-input {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  font-size: 1rem;
  font-family: 'Outfit', sans-serif;
  background: #fff;
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  min-height: 44px;
  width: 100%;
}
.form-input::placeholder { color: var(--text-weak); }
.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

/* 賃貸カラムのフォーカスは賃貸色 */
.col-rent .form-input:focus {
  border-color: var(--rent);
  box-shadow: 0 0 0 3px rgba(var(--rent-rgb), 0.15);
}

.input-suffix {
  font-size: 0.8125rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* 計算ボタン */
.calc-btn-wrap { margin-top: 1.25rem; }

.btn-calc {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.875rem 2rem;
  background: linear-gradient(135deg, #1d4ed8, #2563eb);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Outfit', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 54px;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
  box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.35);
}
.btn-calc:hover {
  background: linear-gradient(135deg, #1e40af, #1d4ed8);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(var(--primary-rgb), 0.4);
}
.btn-calc:active {
  transform: translateY(0);
  box-shadow: none;
}

/* ============================================================
   結果エリア
   ============================================================ */

.results-area { margin-top: 1.5rem; display: flex; flex-direction: column; gap: 1.25rem; }

/* 判定バナー */
.verdict-banner {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.verdict-banner.rent-wins {
  background: linear-gradient(135deg, #fff7ed, #ffedd5);
  border: 1.5px solid var(--rent-border);
}
.verdict-banner.buy-wins {
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border: 1.5px solid var(--buy-border);
}
.verdict-banner.draw {
  background: linear-gradient(135deg, #f9fafb, #f3f4f6);
  border: 1.5px solid var(--border);
}

.verdict-icon { font-size: 2.25rem; line-height: 1; flex-shrink: 0; }
.verdict-title {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(1rem, 3vw, 1.3rem);
  font-weight: 700;
  line-height: 1.3;
}
.verdict-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* KPIグリッド */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

@media (max-width: 479px) {
  .kpi-grid { grid-template-columns: 1fr; }
}

.kpi-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  text-align: center;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,0.05);
  transition: box-shadow var(--transition), transform var(--transition);
}
.kpi-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.kpi-icon { font-size: 1.5rem; margin-bottom: 0.35rem; }
.kpi-rent .kpi-icon { color: var(--rent); }
.kpi-buy  .kpi-icon { color: var(--buy); }
.kpi-diff .kpi-icon { color: #6d28d9; }

.kpi-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.4rem;
}
.kpi-value {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 800;
  line-height: 1;
  margin-bottom: 0.2rem;
}
.kpi-rent .kpi-value { color: var(--rent); }
.kpi-buy  .kpi-value { color: var(--buy); }
.kpi-diff .kpi-value { color: #6d28d9; }
.kpi-unit { font-size: 0.8rem; color: var(--text-muted); }

/* 損益分岐点カード */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,0.05);
}

.breakeven-card { padding: 1.25rem 1.5rem; }

.breakeven-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.breakeven-icon {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: #d97706;
  flex-shrink: 0;
}

.breakeven-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-weight: 600;
}
.breakeven-value {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}
.breakeven-note {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* グラフ */
.chart-card { padding: 1.25rem; }

.chart-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.chart-legend {
  display: flex;
  gap: 1.25rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}
.legend-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
}
.legend-rent { background: var(--rent); }
.legend-buy  { background: var(--buy); }

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

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

.chart-note {
  font-size: 0.775rem;
  color: var(--text-weak);
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.75rem;
}

/* コスト内訳 */
.breakdown-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

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

.breakdown-title {
  font-size: 0.9375rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
}

.breakdown-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8375rem;
}
.breakdown-table tr {
  border-bottom: 1px solid var(--border);
}
.breakdown-table tr:last-child { border-bottom: none; }
.breakdown-table td {
  padding: 0.5rem 0.25rem;
  color: var(--text-muted);
}
.breakdown-table td:last-child {
  text-align: right;
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  color: var(--text);
}
.breakdown-table .total-row td {
  border-top: 2px solid var(--border);
  font-weight: 700;
  color: var(--text);
  padding-top: 0.65rem;
}
.breakdown-table .total-row td:last-child { color: var(--primary); font-size: 1rem; }

/* ============================================================
   使い方セクション
   ============================================================ */

.howto-section {
  margin-top: 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.howto-section h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
  border-left: 4px solid var(--buy);
  padding-left: 0.75rem;
  margin-bottom: 0.25rem;
}

.howto-section p {
  font-size: 0.9375rem;
  line-height: 1.8;
  color: #374151;
  max-width: 65ch;
}

.howto-details {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,0.05);
  overflow: hidden;
}

.howto-summary {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1rem 1.25rem;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.9375rem;
  list-style: none;
  user-select: none;
  color: var(--buy);
}
.howto-summary::-webkit-details-marker { display: none; }
.howto-summary:hover { background: var(--buy-light); }

.howto-steps {
  padding: 0.5rem 1.25rem 1.25rem 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.howto-steps li {
  font-size: 0.9rem;
  line-height: 1.65;
  color: #374151;
}
.howto-steps strong { color: var(--text); }

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

.accordion-item {
  background: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  border: 1px solid var(--border);
  overflow: hidden;
}

.accordion-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  list-style: none;
  user-select: none;
  min-height: 44px;
}
.accordion-summary::-webkit-details-marker { display: none; }
.accordion-summary:hover { background: #f9fafb; }

.accordion-icon {
  width: 18px;
  height: 18px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
details[open] .accordion-icon { transform: rotate(-135deg); }

.accordion-body {
  padding: 0 1.25rem 1.25rem;
  font-size: 0.875rem;
  color: #374151;
  line-height: 1.7;
}

.accordion-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  margin-top: 0.5rem;
}
.accordion-body th,
.accordion-body td {
  padding: 0.5rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.accordion-body th {
  font-weight: 700;
  background: var(--bg);
  color: var(--text);
}
.accordion-body tr:last-child td { border-bottom: none; }

.accordion-body dl dt {
  font-weight: 700;
  color: var(--text);
  margin-top: 0.85rem;
}
.accordion-body dl dd {
  margin-left: 0;
  margin-top: 0.2rem;
  color: var(--text-muted);
}

.disclaimer-note {
  background: #fff9f0;
  border: 1px solid #fcd34d;
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  font-size: 0.8125rem;
  color: #92400e;
}

/* ============================================================
   Footer
   ============================================================ */

footer {
  background: #1a1a2e;
  color: rgba(255,255,255,0.7);
  text-align: center;
  padding: 2rem 1.25rem;
  margin-top: 3rem;
  font-size: 0.875rem;
  line-height: 2;
}
footer a {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  transition: color var(--transition);
}
footer a:hover { color: #fff; }

/* ============================================================
   アニメーション
   ============================================================ */

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

.results-area > * {
  animation: fadeSlideUp 0.3s ease both;
}

/* ============================================================
   モバイル最適化
   ============================================================ */

@media (max-width: 479px) {
  .header-badge { flex-wrap: wrap; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-diff { grid-column: 1 / -1; }
  .breakdown-grid { grid-template-columns: 1fr; }
  .input-columns { grid-template-columns: 1fr; }
}
