/* 色や余白をまとめて管理するための設定です。 */
:root {
  --navy: #183153;
  --green: #16a085;
  --green-dark: #117a68;
  --mint: #e9f8f4;
  --orange: #ff8a4c;
  --red: #d94b4b;
  --ink: #243447;
  --muted: #687386;
  --line: #dfe7ed;
  --surface: #ffffff;
  --background: #f4f7f8;
  --shadow: 0 14px 36px rgba(24, 49, 83, 0.09);
}

/* すべての要素で幅の計算方法をそろえます。 */
* {
  box-sizing: border-box;
}

/* ページ全体の基本デザインです。 */
body {
  margin: 0;
  color: var(--ink);
  background: var(--background);
  font-family: "Yu Gothic UI", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  line-height: 1.6;
}

/* ボタンと入力欄の文字を本文と同じにします。 */
button,
input {
  font: inherit;
}

/* キーボード操作中の場所を分かりやすくします。 */
button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(255, 138, 76, 0.45);
  outline-offset: 2px;
}

/* 内容が画面いっぱいに広がりすぎないようにします。 */
.container {
  width: min(1080px, calc(100% - 32px));
  margin-inline: auto;
}

/* ページ上部の帯です。 */
.site-header {
  background: var(--navy);
  color: white;
}

/* ロゴと案内を横並びにします。 */
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
}

/* ロゴの見た目です。 */
.logo {
  color: white;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-decoration: none;
}

/* ヘッダー右側の小さな表示です。 */
.header-note {
  padding: 4px 12px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  font-size: 0.78rem;
}

/* ヘッダー内の別アプリへのリンクから下線を消します。 */
.header-link {
  color: white;
  text-decoration: none;
}

/* 別アプリへのリンクにマウスを重ねた時だけ背景を付けます。 */
.header-link:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* メイン部分の上下に余白を作ります。 */
.page-layout {
  padding-block: 64px 48px;
}

/* 最初の説明部分を中央寄せにします。 */
.intro {
  max-width: 720px;
  margin: 0 auto 36px;
  text-align: center;
}

/* 見出し上の小さな文字です。 */
.eyebrow {
  margin: 0 0 8px;
  color: var(--green-dark);
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

/* ページの大見出しです。 */
h1 {
  margin: 0;
  color: var(--navy);
  font-size: clamp(2rem, 5vw, 3.35rem);
  line-height: 1.2;
  letter-spacing: -0.03em;
}

/* 大見出しの下の説明文です。 */
.lead {
  margin: 16px auto 0;
  color: var(--muted);
  font-size: 1rem;
}

/* 解説ページ内のリンクを横並びにします。 */
.guide-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 22px;
}

/* 解説ページ内リンクを小さなボタンのように見せます。 */
.guide-nav a {
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--navy);
  background: var(--surface);
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none;
}

/* マウスを重ねたリンクを緑色にします。 */
.guide-nav a:hover {
  border-color: var(--green);
  color: var(--green-dark);
  background: var(--mint);
}

/* 入力カードと結果カードを2列に並べます。 */
.calculator-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.92fr);
  gap: 24px;
  align-items: start;
}

/* 白いカードの共通デザインです。 */
.card {
  border: 1px solid rgba(223, 231, 237, 0.8);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

/* 入力カードの内側に余白を付けます。 */
.input-card,
.result-card {
  padding: 28px;
}

/* 番号と小見出しを横並びにします。 */
.section-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

/* 小見出しの文字を整えます。 */
.section-heading h2 {
  margin: 0;
  color: var(--navy);
  font-size: 1.2rem;
}

/* 手順番号を丸で囲みます。 */
.step-number {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--green);
  font-size: 0.85rem;
  font-weight: 800;
}

/* 入力欄の名前を見やすくします。 */
.field-label {
  display: block;
  margin: 18px 0 7px;
  color: var(--navy);
  font-size: 0.9rem;
  font-weight: 700;
}

/* 「任意」の文字を控えめにします。 */
.optional {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
}

/* 金額入力欄を記号と数字の横並びにします。 */
.money-input,
.percent-input {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 50px;
  padding-inline: 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fbfcfd;
  transition: border-color 0.2s, box-shadow 0.2s;
}

/* 入力中の欄を緑色で目立たせます。 */
.money-input:focus-within,
.percent-input:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(22, 160, 133, 0.11);
}

/* 入力欄そのものの枠線を消します。 */
.money-input input,
.percent-input input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 1.05rem;
  font-weight: 700;
}

/* 手数料率の入力欄を少し短くします。 */
.percent-input {
  max-width: 180px;
}

/* 手数料の選択ボタンを横並びにします。 */
.preset-buttons {
  display: flex;
  gap: 8px;
  margin-top: 9px;
}

/* 手数料ボタンの通常の見た目です。 */
.preset-button {
  padding: 6px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: white;
  cursor: pointer;
}

/* 選択中の手数料ボタンを緑色にします。 */
.preset-button.active {
  border-color: var(--green);
  color: var(--green-dark);
  background: var(--mint);
  font-weight: 700;
}

/* 送料と仕入れ値を2列にします。 */
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* すべての大きなボタンに共通する見た目です。 */
.primary-button,
.secondary-button {
  width: 100%;
  min-height: 48px;
  margin-top: 22px;
  border-radius: 11px;
  font-weight: 800;
  cursor: pointer;
}

/* 履歴保存ボタンを緑色にします。 */
.primary-button {
  border: 0;
  color: white;
  background: var(--green);
}

/* 押せない保存ボタンを薄く表示します。 */
.primary-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* リセットボタンを白いボタンにします。 */
.secondary-button {
  border: 1px solid var(--line);
  color: var(--muted);
  background: white;
}

/* 結果カードの上側を濃い青にします。 */
.result-card {
  overflow: hidden;
  color: white;
  background: var(--navy);
}

/* 結果カード内の見出しを白にします。 */
.result-heading h2 {
  color: white;
}

/* 利益の数字を中央に配置します。 */
.profit-summary {
  padding: 14px 0 28px;
  text-align: center;
}

/* 利益の上にある説明文です。 */
.profit-summary p {
  margin: 0;
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.9rem;
}

/* 利益額を大きく表示します。 */
.profit-summary strong {
  display: block;
  margin: 4px 0 10px;
  font-size: clamp(2.7rem, 7vw, 4.2rem);
  line-height: 1.1;
  letter-spacing: -0.04em;
}

/* 利益の状態を表示する小さなラベルです。 */
.status-badge {
  display: inline-block;
  padding: 4px 11px;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.78);
  background: rgba(255, 255, 255, 0.1);
  font-size: 0.76rem;
}

/* 赤字のときにラベルを赤くします。 */
.status-badge.loss {
  color: #ffe4e4;
  background: rgba(217, 75, 75, 0.35);
}

/* 利益が出たときにラベルを緑色にします。 */
.status-badge.gain {
  color: #d9fff4;
  background: rgba(22, 160, 133, 0.35);
}

/* 金額の内訳を囲む箱です。 */
.breakdown {
  margin: 0;
  padding: 6px 18px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.07);
}

/* 内訳の名前と金額を左右に分けます。 */
.breakdown div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* 最後の内訳だけ下線を消します。 */
.breakdown div:last-child {
  border-bottom: 0;
}

/* 内訳の文字を少し控えめにします。 */
.breakdown dt {
  color: rgba(255, 255, 255, 0.68);
}

/* ブラウザ標準の余白を消します。 */
.breakdown dd {
  margin: 0;
  font-weight: 700;
}

/* 利益率部分の上下に余白を作ります。 */
.margin-area {
  margin-top: 22px;
}

/* 利益率の文字と数値を左右に分けます。 */
.margin-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.88rem;
}

/* 利益率の棒の背景です。 */
.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}

/* 利益率に合わせて伸びる棒です。 */
.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--orange);
  transition: width 0.25s ease;
}

/* 結果カード内の保存ボタンをオレンジ色にします。 */
.result-card .primary-button {
  color: var(--navy);
  background: var(--orange);
}

/* 履歴カードを計算カードの下に配置します。 */
.history-card {
  margin-top: 24px;
  padding: 26px 28px;
}

/* 履歴の見出しと削除ボタンを左右に分けます。 */
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

/* 履歴見出しの余白を調整します。 */
.history-header .section-heading {
  margin-bottom: 0;
}

/* 履歴削除ボタンを文字だけの見た目にします。 */
.text-button {
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* 履歴を横に並べ、画面が狭いと折り返します。 */
.history-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 22px;
}

/* 履歴1件分の見た目です。 */
.history-item {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcfd;
}

/* 履歴の日付を小さく表示します。 */
.history-item time {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
}

/* 履歴の利益額を目立たせます。 */
.history-item strong {
  display: block;
  margin-top: 4px;
  color: var(--green-dark);
  font-size: 1.25rem;
}

/* 赤字の履歴だけ赤い文字にします。 */
.history-item strong.loss {
  color: var(--red);
}

/* 履歴がないときの案内文です。 */
.empty-message {
  grid-column: 1 / -1;
  margin: 0;
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

/* 利益計算ガイド全体の上下に余白を作ります。 */
.guide-section {
  padding-top: 72px;
  scroll-margin-top: 24px;
}

/* ガイドの見出しを中央に配置します。 */
.guide-header {
  max-width: 680px;
  margin: 0 auto 30px;
  text-align: center;
}

/* ガイドの大見出しを整えます。 */
.guide-header h2,
.faq-heading h2 {
  margin: 0;
  color: var(--navy);
  font-size: clamp(1.7rem, 4vw, 2.35rem);
}

/* ガイド見出しの説明文を読みやすくします。 */
.guide-header > p:last-child {
  margin: 10px 0 0;
  color: var(--muted);
}

/* 解説カードを2列に並べます。 */
.guide-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

/* 解説カードの共通デザインです。 */
.guide-card {
  padding: 27px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(24, 49, 83, 0.05);
  scroll-margin-top: 24px;
}

/* 解説カードの番号を緑色で表示します。 */
.guide-number {
  color: var(--green-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

/* 解説カードの見出しを整えます。 */
.guide-card h3 {
  margin: 6px 0 12px;
  color: var(--navy);
  font-size: 1.2rem;
}

/* 解説カードの本文を読みやすくします。 */
.guide-card p {
  margin: 0 0 14px;
  color: var(--muted);
}

/* 計算式を目立つ箱の中に表示します。 */
.formula-box {
  padding: 16px;
  border-left: 4px solid var(--green);
  border-radius: 0 10px 10px 0;
  color: var(--navy);
  background: var(--mint);
  font-weight: 800;
}

/* 手数料の計算例を縦に並べます。 */
.example-calculation {
  display: grid;
  gap: 3px;
  margin-bottom: 14px;
  padding: 16px;
  border-radius: 11px;
  color: var(--navy);
  background: #f3f6f8;
}

/* 計算例の答えを大きく表示します。 */
.example-calculation strong {
  color: var(--green-dark);
  font-size: 1.15rem;
}

/* 補足説明を小さく表示します。 */
.guide-card .guide-note {
  margin: 14px 0 0;
  font-size: 0.82rem;
}

/* 最低販売価格カードを薄い緑色にします。 */
.accent-card {
  border-color: rgba(22, 160, 133, 0.3);
  background: linear-gradient(145deg, #ffffff, var(--mint));
}

/* 最低販売価格の名前と金額を左右に分けます。 */
.break-even-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 17px;
  border-radius: 12px;
  color: white;
  background: var(--navy);
}

/* 最低販売価格を大きく表示します。 */
.break-even-result output {
  color: var(--orange);
  font-size: 1.65rem;
  font-weight: 800;
  white-space: nowrap;
}

/* 使い方の番号付きリストを整えます。 */
.howto-list {
  margin: 0;
  padding-left: 1.4rem;
  color: var(--muted);
}

/* 使い方の各項目に余白を付けます。 */
.howto-list li + li {
  margin-top: 8px;
}

/* よくある質問をガイドの下に配置します。 */
.faq-area {
  margin-top: 56px;
  scroll-margin-top: 24px;
}

/* FAQの見出しを中央に配置します。 */
.faq-heading {
  margin-bottom: 22px;
  text-align: center;
}

/* FAQを読みやすい幅にします。 */
.faq-list {
  max-width: 820px;
  margin-inline: auto;
}

/* 質問1件分を白いカードにします。 */
.faq-list details {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

/* 2件目以降の質問に上の余白を付けます。 */
.faq-list details + details {
  margin-top: 10px;
}

/* クリックできる質問部分を整えます。 */
.faq-list summary {
  padding: 17px 20px;
  color: var(--navy);
  font-weight: 800;
  cursor: pointer;
}

/* 開いた質問の回答を整えます。 */
.faq-list details p {
  margin: 0;
  padding: 0 20px 18px;
  color: var(--muted);
}

/* ページ下部の注意書きです。 */
.site-footer {
  padding: 28px 16px;
  color: var(--muted);
  text-align: center;
  font-size: 0.78rem;
}

/* ページ下部の案内リンクを横並びにします。 */
.footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; margin-bottom: 8px; }

/* ページ下部のリンクを本文になじむ色にします。 */
.footer-links a { color: inherit; }

/* タブレット以下の画面ではカードを縦に並べます。 */
@media (max-width: 760px) {
  .page-layout {
    padding-block: 42px 36px;
  }

  .calculator-grid {
    grid-template-columns: 1fr;
  }

  .history-list {
    grid-template-columns: 1fr 1fr;
  }

  .guide-grid {
    grid-template-columns: 1fr;
  }
}

/* 小さなスマートフォンでは入力欄と履歴を1列にします。 */
@media (max-width: 480px) {
  .container {
    width: min(100% - 22px, 1080px);
  }

  .input-card,
  .result-card,
  .history-card {
    padding: 21px 18px;
    border-radius: 16px;
  }

  .field-row,
  .history-list {
    grid-template-columns: 1fr;
  }

  .header-note {
    display: none;
  }

  .guide-section {
    padding-top: 52px;
  }

  .guide-card {
    padding: 22px 18px;
  }

  .break-even-result {
    align-items: flex-start;
    flex-direction: column;
  }
}
