* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
button { touch-action: manipulation; }

body {
  font-family: 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', sans-serif;
  background: #f5f5f5;
  color: #333;
  line-height: 1.7;
  overflow-x: hidden;
}

header {
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.logo {
  font-size: 1.2rem;
  font-weight: bold;
  color: #1a73e8;
  text-decoration: none;
}

main {
  max-width: 800px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

h2 {
  font-size: 1.2rem;
  font-weight: bold;
  margin-bottom: 1rem;
}

.card {
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid #e0e0e0;
}

/* ━━━ ヒーロー ━━━ */
.hero {
  text-align: center;
  padding: 28px 0 20px;
  margin-bottom: 1.5rem;
}
.hero-icon { font-size: 3rem; margin-bottom: 10px; }
.hero h1 { font-size: 1.8rem; font-weight: bold; margin-bottom: 6px; color: #1e293b; }
.hero .description { color: #666; font-size: 0.95rem; line-height: 1.7; margin-bottom: 0; }
.hero-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}
.badge {
  display: inline-block;
  padding: 5px 13px;
  background: #dbeafe;
  color: #1a73e8;
  border: 1.5px solid #bfdbfe;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

/* ━━━ 入力 ━━━ */
.input-group {
  margin-bottom: 1.2rem;
}
.input-group label {
  display: block;
  font-size: 0.875rem;
  color: #666;
  margin-bottom: 0.4rem;
}

.asset-select {
  width: 100%;
  padding: .6rem .8rem;
  border: 1.5px solid #e0e0e0;
  border-radius: 8px;
  font-size: .95rem;
  font-family: inherit;
  color: #333;
  background: #fff;
  cursor: pointer;
  transition: border-color .15s;
}
.asset-select:focus { outline: none; border-color: #1a73e8; }

.custom-input-row {
  display: flex;
  gap: .6rem;
}
.custom-ticker-input {
  flex: 1;
  padding: .55rem .75rem;
  border: 1.5px solid #e0e0e0;
  border-radius: 8px;
  font-size: .9rem;
  font-family: inherit;
}
.custom-ticker-input:focus { outline: none; border-color: #1a73e8; }

.plan-select {
  border: 1.5px solid #e0e0e0;
  border-radius: 7px;
  padding: 4px 6px;
  font-size: .82rem;
  color: #333;
  background: #f8fbff;
  font-family: inherit;
}

/* 日付行 */
.date-row {
  display: flex;
  align-items: flex-end;
  gap: .75rem;
  margin-bottom: 1.2rem;
}
.date-row .input-group { flex: 1; min-width: 0; margin-bottom: 0; }
.date-arrow {
  font-size: .9rem;
  color: #aaa;
  padding-bottom: .55rem;
  flex-shrink: 0;
}
.date-input {
  width: 100%;
  max-width: 100%;   /* iOSで内部chrome幅がwidth:100%を超えるのを防ぐ */
  min-width: 0;
  padding: .55rem .75rem;
  border: 1.5px solid #e0e0e0;
  border-radius: 8px;
  font-size: .9rem;
  font-family: inherit;
  color: #333;
  box-sizing: border-box;
}
.date-input:focus { outline: none; border-color: #1a73e8; }

.date-with-btn {
  display: flex;
  gap: .5rem;
  align-items: center;
}
.today-btn {
  padding: .48rem .75rem;
  background: #f0f4ff;
  border: 1.5px solid #bfdbfe;
  border-radius: 8px;
  font-size: .8rem;
  color: #1a73e8;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  transition: background .12s;
}
.today-btn:hover { background: #dbeafe; }
.date-with-btn .date-input { flex: 1; min-width: 0; }

/* スライダー */
.range-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.range-row input[type=range] {
  flex: 1;
  min-width: 0;
  accent-color: #1a73e8;
}
.num-box {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 100px;
}
.num-input {
  width: 72px;
  border: 1.5px solid #e0e0e0;
  border-radius: 7px;
  padding: 4px 8px;
  font-size: 0.95rem;
  font-weight: bold;
  text-align: right;
  color: #1a73e8;
  background: #f8fbff;
  transition: border-color .15s;
  -moz-appearance: textfield;
}
.num-input::-webkit-inner-spin-button,
.num-input::-webkit-outer-spin-button { -webkit-appearance: none; }
.num-input:focus { outline: none; border-color: #1a73e8; background: #fff; }
.unit { font-size: 0.85rem; color: #666; white-space: nowrap; }

/* エラーメッセージ */
.error-msg {
  margin-top: .75rem;
  padding: .7rem 1rem;
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  color: #b91c1c;
  font-size: .85rem;
}

/* 計算ボタン */
.calc-btn {
  display: block;
  width: 100%;
  margin-top: 1.2rem;
  padding: .85rem 1rem;
  background: #1a73e8;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.calc-btn:hover { background: #1557b0; }
.calc-btn:active { transform: scale(.99); }
.calc-btn:disabled { background: #93c5fd; cursor: not-allowed; }

/* ━━━ 結果ヘッダー ━━━ */
.result-header {
  padding: 1rem 1.5rem;
  background: linear-gradient(135deg, #f0f6ff, #fafcff);
}
.result-asset-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1a73e8;
  margin-bottom: .2rem;
}
.result-period { font-size: .82rem; color: #888; }

/* ━━━ メトリクス（4列） ━━━ */
.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.metrics-4 { grid-template-columns: repeat(4, 1fr); }

.metric {
  background: #fff;
  border-radius: 12px;
  padding: 1.2rem;
  border: 1px solid #e0e0e0;
  text-align: center;
}
.metric-label { font-size: 0.78rem; color: #666; margin-bottom: 0.5rem; }
.metric-value { font-size: 1.1rem; font-weight: bold; }
.metric-value.highlight { color: #1a73e8; }
.metric-value.profit { color: #16a34a; }
.metric-value.loss   { color: #dc2626; }

/* ━━━ サブメトリクス ━━━ */
.sub-metrics-card { padding: 1rem 1.5rem; }
.sub-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .75rem;
}
.sub-metric { text-align: center; }
.sub-metric-label { font-size: .74rem; color: #888; margin-bottom: .2rem; }
.sub-metric-value { font-size: .92rem; font-weight: 700; }
.sub-metric-value.profit { color: #16a34a; }
.sub-metric-value.loss   { color: #dc2626; }
.sub-metric-value.neutral { color: #555; }

/* ━━━ チャート ━━━ */
.chart-card h2 { margin-bottom: .5rem; }
.chart-wrap {
  width: 100%;
  overflow-x: auto;
}
.chart-wrap svg {
  width: 100%;
  height: auto;
  display: block;
  min-width: 300px;
}

/* ━━━ 為替注記 ━━━ */
.fx-note {
  background: #f0f9ff;
  border: 1.5px solid #bae6fd;
  border-radius: 10px;
  padding: .85rem 1.1rem;
  margin-bottom: 1.5rem;
  font-size: .81rem;
  color: #0369a1;
  line-height: 1.65;
}

/* ━━━ 活用シーン ━━━ */
.scene-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: .75rem;
}
.scene-item {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .85rem 1rem;
  background: #f0f6ff;
  border: 1.5px solid #bfdbfe;
  border-radius: 12px;
}
.scene-icon { font-size: 1.7rem; flex-shrink: 0; }
.scene-body strong { display: block; font-size: .88rem; font-weight: 700; color: #1a56db; margin-bottom: .2rem; }
.scene-body p { font-size: .78rem; color: #4b5563; line-height: 1.55; margin: 0; }

/* ━━━ Amazonおすすめ ━━━ */
.amazon-card h2 { margin-bottom: 0.25rem; }
.amazon-note { font-size: 0.82rem; color: #999; margin-bottom: 1rem; }
.amazon-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
.amazon-item {
  display: block;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  padding: 0.9rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.1s;
}
.amazon-item:hover {
  border-color: #FF9900;
  box-shadow: 0 2px 8px rgba(255,153,0,0.15);
  transform: translateY(-1px);
}
.amazon-item-icon { font-size: 1.7rem; margin-bottom: 0.35rem; }
.amazon-item-name { font-size: 0.88rem; font-weight: bold; margin-bottom: 0.2rem; }
.amazon-item-desc { font-size: 0.76rem; color: #888; line-height: 1.5; margin-bottom: 0.45rem; }
.amazon-item-link { font-size: 0.78rem; color: #FF9900; font-weight: bold; }

/* ━━━ Tips grid ━━━ */
.tips-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.tip-item { display: flex; gap: .65rem; }
.tip-icon { font-size: 1.4rem; flex-shrink: 0; }
.tip-text strong { display: block; font-weight: 700; margin-bottom: .15rem; font-size: .88rem; }
.tip-text p { font-size: .8rem; color: #78716c; line-height: 1.55; }

/* ━━━ テーブル共通 ━━━ */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
th {
  text-align: right;
  padding: 0.6rem 0.8rem;
  color: #666;
  font-weight: normal;
  border-bottom: 1px solid #e0e0e0;
}
th:first-child { text-align: left; }
td {
  text-align: right;
  padding: 0.5rem 0.8rem;
  border-bottom: 1px solid #f0f0f0;
}
td:first-child { text-align: left; color: #666; }

.info-table th, .info-table td { text-align: left; }
.section-note { font-size: .82rem; color: #888; margin-bottom: .75rem; }
.table-note   { font-size: .76rem; color: #aaa; margin-top: .6rem; }

/* イベント表 */
.event-table thead th { background: #f0f6ff; color: #1a56db; font-weight: 700; font-size: .8rem; text-align: left; padding: .6rem .75rem; }
.event-table tbody td { font-size: .82rem; text-align: left; }
.event-table tbody tr:hover td { background: #fafcff; }

/* ━━━ FAQ ━━━ */
.faq-list { display: flex; flex-direction: column; }
.faq-item { padding: .9rem 0; border-bottom: 1px solid #f0f0f0; }
.faq-item:last-child { border-bottom: none; padding-bottom: 0; }
.faq-q { font-size: .9rem; font-weight: 700; color: #1a73e8; margin-bottom: .35rem; }
.faq-a { font-size: .85rem; color: #555; line-height: 1.75; }

/* ━━━ 関連ツール ━━━ */
.related-tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .75rem; }
.related-tool-item {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .85rem 1rem;
  border: 1.5px solid #e8edf5;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.related-tool-item:hover { border-color: #1a73e8; box-shadow: 0 2px 8px rgba(26,115,232,.1); }
.related-tool-icon { font-size: 1.6rem; flex-shrink: 0; }
.related-tool-item strong { display: block; font-size: .88rem; font-weight: 700; color: #1a73e8; margin-bottom: .2rem; }
.related-tool-item p { font-size: .76rem; color: #888; line-height: 1.5; margin: 0; }

/* ━━━ ユーティリティ ━━━ */
.hidden { display: none !important; }

/* ━━━ フッター ━━━ */
footer {
  text-align: center;
  padding: 1.5rem 1rem;
  font-size: .82rem;
  color: #a8a29e;
  border-top: 1px solid #e7e5e4;
  margin-top: auto;
}
footer a { color: #ea580c; text-decoration: none; }
footer a:hover { text-decoration: underline; }
footer p + p { margin-top: .3rem; }
.amazon-notice { font-size: 0.72rem; color: #bbb; margin-top: 0.2rem; }

/* ━━━ レスポンシブ ━━━ */
@media (max-width: 640px) {
  .metrics-4 { grid-template-columns: repeat(2, 1fr); }
  .sub-metrics { grid-template-columns: repeat(2, 1fr); }
  .hero h1 { font-size: 1.4rem; }
  .scene-grid { grid-template-columns: 1fr; }
  /* date-row をブロック表示に変更。
     flex コンテナをやめることで .input-group が銘柄選択と同じ
     ブロックコンテキストに入り、width:100% が完全に一致する */
  .date-row { display: block; }
  .date-row .input-group { margin-bottom: 1rem; }
  .date-arrow { display: none; }
  /* input[type="date"] はインライン置換要素のため display:block を明示。
     16px 未満は iOS フォーカス時の自動ズームを誘発するため 1rem */
  .date-input { display: block; width: 100%; font-size: 1rem; padding: .5rem .6rem; }
  /* 売却日：flex をやめてブロック表示にすることで、購入日・銘柄選択と
     まったく同じコンテキストになり左端が完全に揃う。
     「今日」ボタンは margin-left:auto で右寄せ */
  .date-with-btn { display: block; }
  .today-btn { display: block; margin-top: .35rem; margin-left: auto; }
}

@media (max-width: 480px) {
  .amazon-grid { grid-template-columns: 1fr; }
  .metric-value { font-size: .95rem; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
}

/* ━━━ シミュレーションモードタブ ━━━ */
.sim-mode-tabs {
  display: flex;
  gap: .35rem;
  background: #f5f7fa;
  padding: .3rem;
  border-radius: 10px;
  border: 1px solid #e8eaf0;
  margin-bottom: 1.2rem;
}
.sim-mode-tab {
  flex: 1;
  min-width: 0;        /* flex itemがコンテンツ幅より小さくなれるよう */
  overflow: hidden;    /* テキストがボタン外にはみ出さないよう */
  padding: .5rem .25rem;
  background: transparent;
  border: none;
  border-radius: 7px;
  font-size: .875rem;
  font-weight: 600;
  color: #666;
  cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
  font-family: inherit;
  line-height: 1.4;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.sim-mode-tab.active {
  background: #fff;
  color: #1a73e8;
  box-shadow: 0 1px 4px rgba(0,0,0,.1);
}
.sim-mode-tab:not(.active):hover { background: #eef1f7; }

/* ━━━ 積立追加情報バー ━━━ */
.dca-extra {
  background: #fffbeb;
  border: 1.5px solid #fde68a;
  border-radius: 10px;
  padding: .75rem 1.1rem;
  margin-bottom: 1.5rem;
  font-size: .82rem;
  color: #78350f;
  line-height: 1.8;
}
