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

:root {
  --bg:       #f0f2f5;
  --surface:  #ffffff;
  --border:   #e4e8ef;
  --text:     #111827;
  --muted:    #6b7280;
  --subtle:   #9ca3af;
  --blue:     #2563eb;
  --blue-lt:  #eff6ff;
  --green:    #16a34a;
  --green-lt: #f0fdf4;
  --red:      #dc2626;
  --red-lt:   #fef2f2;
  --amber:    #d97706;
}

html { font-size: 16px; }

body {
  font-family: -apple-system, "Hiragino Sans", "Yu Gothic UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ── トップバー ────────────────────────────────── */
.topbar {
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-logo {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 7px;
}
.topbar-logo-icon {
  width: 28px;
  height: 28px;
  background: var(--blue);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
}
.topbar-sep { flex: 1; }
.topbar-badge {
  font-size: 11px;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── 2カラムレイアウト ─────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  grid-template-rows: auto;
  gap: 0;
  min-height: calc(100vh - 52px);
}

/* 左ペイン: 入力 */
.pane-input {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: calc(100vh - 52px);
  position: sticky;
  top: 52px;
  overflow-y: auto;
}

/* 右ペイン: 結果 */
.pane-result {
  padding: 24px;
  overflow-y: auto;
}

/* ── 入力ペイン内 ──────────────────────────────── */
.input-header {
  padding: 20px 24px 0;
}
.input-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 16px;
}

.field {
  padding: 0 24px;
  margin-bottom: 20px;
}
.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.field-label span { font-weight: 400; color: var(--subtle); }

.range-wrap {
  position: relative;
}
.range-value-row {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin-bottom: 8px;
}
.range-num {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  min-width: 80px;
}
.range-unit {
  font-size: 14px;
  color: var(--muted);
  font-weight: 500;
}

input[type=range] {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 1px 4px rgba(37,99,235,0.4);
  cursor: pointer;
  transition: transform 0.1s;
}
input[type=range]::-webkit-slider-thumb:active {
  transform: scale(1.2);
}
input[type=range].green::-webkit-slider-thumb { background: var(--green); }

.range-minmax {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--subtle);
  margin-top: 4px;
}

/* 数値直接入力 */
.input-text-wrap {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #fafbfc;
  transition: border-color 0.15s;
}
.input-text-wrap:focus-within {
  border-color: var(--blue);
  background: #fff;
}
.input-text-wrap input {
  border: none;
  background: none;
  padding: 10px 12px;
  font-size: 16px;
  font-weight: 600;
  width: 100%;
  color: var(--text);
  outline: none;
  -webkit-appearance: none;
}
.input-text-unit {
  padding: 0 12px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  border-left: 1px solid var(--border);
  background: var(--bg);
  align-self: stretch;
  display: flex;
  align-items: center;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0 20px;
}

/* オプションセクション */
.option-section {
  padding: 0 24px 20px;
}
.option-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  margin-bottom: 12px;
}
.toggle-switch {
  position: relative;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 10px;
  transition: background 0.2s;
  cursor: pointer;
}
.toggle-track::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-track { background: var(--blue); }
.toggle-switch input:checked + .toggle-track::after { transform: translateX(16px); }
.toggle-switch input:checked + .toggle-track.green { background: var(--green); }

.option-fields { display: flex; flex-direction: column; gap: 12px; }
.option-fields.hidden { display: none; }

.input-footer {
  margin-top: auto;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--subtle);
  display: flex;
  align-items: center;
  gap: 5px;
}

/* ── 結果ペイン ────────────────────────────────── */

/* 空状態 */
.empty-state {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--subtle);
  text-align: center;
  gap: 12px;
  min-height: 400px;
}
.empty-icon { font-size: 48px; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--muted); }
.empty-desc { font-size: 13px; line-height: 1.6; }

/* KPIグリッド */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.kpi.blue  { background: var(--blue-lt);  border-color: #bfdbfe; }
.kpi.green { background: var(--green-lt); border-color: #bbf7d0; }
.kpi.red   { background: var(--red-lt);   border-color: #fecaca; }
.kpi-label { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: 0.04em; margin-bottom: 6px; }
.kpi-value { font-size: clamp(18px,3vw,26px); font-weight: 900; letter-spacing: -0.02em; color: var(--text); }
.kpi.blue  .kpi-value { color: var(--blue); }
.kpi.green .kpi-value { color: var(--green); }
.kpi.red   .kpi-value { color: var(--red); }
.kpi-sub   { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* セクション */
.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 16px;
  overflow: hidden;
}
.section-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}
.section-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}
.section-badge.green { background: var(--green-lt); color: var(--green); }
.section-badge.blue  { background: var(--blue-lt);  color: var(--blue); }
.section-badge.red   { background: var(--red-lt);   color: var(--red); }
.section-body { padding: 18px; }

/* チャート */
.chart-wrap { position: relative; }
canvas { max-height: 220px; }

/* 比較テーブル */
.comp-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.comp-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.05em;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.comp-table th:not(:first-child) { text-align: right; }
.comp-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--bg);
  font-size: 13px;
}
.comp-table td:not(:first-child) { text-align: right; }
.comp-table tr:last-child td { border-bottom: none; font-weight: 700; }
.save { color: var(--green); font-weight: 700; }

/* 損益分岐 */
.breakeven-bar-wrap { margin-top: 14px; }
.breakeven-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}
.bar-track {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--blue);
  transition: width 0.7s ease;
  width: 0;
}
.bar-fill.green { background: var(--green); }

/* 判定バナー */
.verdict-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
}
.verdict-banner.go   { background: var(--green-lt); border: 1px solid #bbf7d0; }
.verdict-banner.stop { background: var(--red-lt);   border: 1px solid #fecaca; }
.verdict-banner.warn { background: #fffbeb;          border: 1px solid #fde68a; }
.verdict-icon  { font-size: 28px; flex-shrink: 0; }
.verdict-text  { flex: 1; }
.verdict-title { font-size: 15px; font-weight: 800; color: var(--text); }
.verdict-desc  { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* CTA */
.cta-block { padding: 18px; border-top: 1px solid var(--border); }
.cta-heading {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}
.bank-list { display: flex; flex-direction: column; gap: 8px; }
.bank-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}
.bank-row:hover { border-color: var(--blue); background: var(--blue-lt); }
.bank-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: var(--bg);
  flex-shrink: 0;
}
.bank-info { flex: 1; min-width: 0; }
.bank-name { font-size: 13px; font-weight: 700; }
.bank-detail { font-size: 11px; color: var(--muted); margin-top: 1px; }
.bank-detail strong { color: var(--green); }
.bank-pill {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}
.bank-pill.rank1 { background: #fef3c7; color: var(--amber); }
.bank-pill.rank2 { background: var(--blue-lt); color: var(--blue); }
.bank-pill.rank3 { background: var(--green-lt); color: var(--green); }
.bank-chevron { color: var(--border); font-size: 16px; flex-shrink: 0; }
.cta-note { font-size: 10px; color: var(--subtle); margin-top: 10px; line-height: 1.5; }

/* アコーディオン */
.acc-item { border-top: 1px solid var(--border); }
.acc-btn {
  width: 100%;
  padding: 13px 18px;
  text-align: left;
  background: none;
  border: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.acc-btn:hover { background: var(--bg); }
.acc-chevron { transition: transform 0.2s; }
.acc-btn.open .acc-chevron { transform: rotate(180deg); }
.acc-body {
  display: none;
  padding: 0 18px 16px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.75;
}
.acc-body.open { display: block; }

/* シェア */
.share-row {
  display: flex;
  gap: 8px;
  padding: 16px 18px;
  border-top: 1px solid var(--border);
}
.share-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  color: var(--text);
  transition: background 0.12s;
}
.share-btn:hover { background: var(--bg); }
.share-btn.x    { background: #000; color: #fff; border-color: #000; }
.share-btn.line { background: #06c755; color: #fff; border-color: #06c755; }
.share-hint { font-size: 11px; color: var(--muted); padding: 0 18px 14px; min-height: 16px; }

/* AdSense */
.ad-slot {
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 8px;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #c5ccd8;
  margin-bottom: 16px;
}

/* フッター */
.site-footer {
  font-size: 11px;
  color: var(--subtle);
  padding: 20px 0;
  text-align: center;
  line-height: 1.8;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}
.site-footer a { color: var(--subtle); }

/* ── レスポンシブ ────────────────────────────────── */
@media (max-width: 768px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
  }
  .pane-input {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .pane-result { padding: 16px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-grid .kpi:nth-child(3) { grid-column: 1 / -1; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-grid .kpi:nth-child(3) { grid-column: auto; }
}

.hidden { display: none !important; }
