/* =====================================================================
 * style.css — 料金概算ツール 共通スタイル
 * ---------------------------------------------------------------------
 * フォント（各HTMLの <head> で読み込む）:
 *   <link rel="preconnect" href="https://fonts.googleapis.com">
 *   <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
 *   <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;700&family=Zen+Maru+Gothic:wght@500;700&display=swap" rel="stylesheet">
 *
 * クラス一覧と使い方
 * ------------------------------------------------------------------
 * .fe-page           ページ全体のラッパー（最大幅・左右余白）。<body> 直下に1つ
 * .fe-header         タイトル部。中に <h1 class="fe-title"> と <p class="fe-lead">
 * .fe-title / .fe-lead  ページ見出し・リード文
 * .fe-card           白いカード（入力のまとまりごと）。<h2 class="fe-card__title"> を先頭に
 * .fe-card__title    カード見出し
 * .fe-grid           フォーム項目を並べる（スマホ1列、640px以上で2列）
 * .fe-field          1項目のまとまり。<label class="fe-label"> or <legend class="fe-label"> + 入力
 *   .fe-label        項目名。<span class="fe-hint"> で補足を添えられる
 *   .fe-hint         小さめの補足文
 *   .fe-input / .fe-select   数値入力・セレクト（高さ48px）
 *   .fe-field--full  .fe-grid の中で横幅いっぱいにする
 * .fe-segment        ラジオをボタン風に並べる。<fieldset class="fe-segment"> の中に
 *                      <label><input type="radio" name="x" value="1"><span>1割</span></label>
 *                    を並べる（input は視覚的に隠し、span がボタンになる）
 *   .fe-segment--wrap  選択肢が多いとき（要介護度・7区分など）に折り返し、均等幅をやめる
 * .fe-check          チェックボックス行（44px以上のタップ領域）
 *                      <label class="fe-check"><input type="checkbox"><span>緊急時訪問看護加算<small>月600単位</small></span></label>
 * .fe-stepper        回数入力（− [数値] ＋）。<div class="fe-stepper"><button class="fe-btn fe-btn--icon">−</button><input class="fe-input" type="number"><button ...>＋</button></div>
 * .fe-tabs           保険の種類タブ。<div class="fe-tabs" role="tablist"><button class="fe-tab" role="tab" aria-selected="true">介護保険</button>…</div>
 *   .fe-tab[aria-selected="true"] が選択中の見た目
 * .fe-panel          タブの中身。非表示は hidden 属性で
 * .fe-visit          詳細版の「訪問パターン」1行分のカード。.fe-visit__head に行番号と削除ボタン
 * .fe-result         結果表示（大きく目立つ）。
 *                      <section class="fe-result" aria-live="polite">
 *                        <p class="fe-result__label">月の自己負担の目安（1割）</p>
 *                        <p class="fe-result__amount">8,866<span>円</span></p>
 *                        <p class="fe-result__sub">月の利用料総額（10割） 88,655円</p>
 *                      </section>
 *   .fe-result--sticky  スマホで画面下に結果を固定表示したいとき（任意）
 * .fe-breakdown      内訳（<details class="fe-breakdown"><summary>内訳を見る</summary><table>…</table></details>）
 *                      表は <table class="fe-table">。数値セルに class="num"、合計行は <tr class="is-total">
 *                      スマホでは表の各行がカード状に縦積み（td に data-label="単価" を付けると見出しが出る）
 * .fe-warning        計算結果の warnings を出す箱（オレンジ枠）。<ul class="fe-warning"><li>…</li></ul>
 * .fe-notice         注意書き（概算である旨など）。<div class="fe-notice"><ul><li>…</li></ul></div>
 * .fe-btn            ボタン。 .fe-btn--primary（ブランドグラデ）/ .fe-btn--ghost（枠のみ）/ .fe-btn--icon（正方形）
 * .fe-actions        ボタンを横に並べる行（印刷・詳細版へ 等）
 * .fe-contact        問い合わせ導線（電話番号を大きく）。<a class="fe-tel" href="tel:…">042-713-4917</a>
 * .fe-footer         フッター（事業所名・事業所番号・医療機関コード）
 * .fe-choice         index.html の「簡易版／詳細版」選択リンク（大きなカード型リンク）
 * .fe-ref-table      保険外の参考表（.fe-table と併用）
 * .fe-no-print       印刷時に隠す / .fe-print-only 印刷時だけ表示
 * .fe-sr-only        画面には出さず読み上げにだけ出す
 * 状態: [disabled] や .is-disabled で薄く表示（要支援のターミナルケア加算など）
 *
 * 印刷: 入力UIは .fe-no-print を付けるか、印刷時は選ばれた値だけを
 *       .fe-print-only の要約で出すと簡潔になります。内訳(details)は印刷時に自動で開いた見た目になります
 *       （details の open 属性は JS の beforeprint で付けるのが確実です）。
 * ===================================================================== */

:root {
  --fe-bg: #F4EEE3;
  --fe-card: #FFFDF6;
  --fe-brand: #FFAE00;
  --fe-brand-light: #F9E866;
  --fe-grad: linear-gradient(135deg, #FFAE00 0%, #F9E866 100%);
  --fe-grad-soft: linear-gradient(135deg, #FFE9A3 0%, #FFF3C4 100%);
  --fe-brand-deep: #E09600;
  --fe-text: #2B2620;
  --fe-text-sub: #4A433B;
  --fe-text-muted: #6F675D;
  --fe-accent: #B54A00;
  --fe-accent-dark: #6E5000;
  --fe-border: #F2DF8A;
  --fe-border-soft: #FBF0A8;
  --fe-bg-soft: #FFF8E0;
  --fe-shadow: 0 6px 22px rgba(43, 38, 32, 0.06);
  --fe-r-card: 20px;
  --fe-r-ctrl: 14px;
  --fe-font-body: "Noto Sans JP", "Hiragino Sans", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  --fe-font-heading: "Zen Maru Gothic", "Noto Sans JP", "Hiragino Maru Gothic ProN", sans-serif;
  --fe-tap: 48px;
}

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--fe-bg);
  color: var(--fe-text);
  font-family: var(--fe-font-body);
  font-size: 17px;
  line-height: 1.8;
  letter-spacing: 0.02em;
  overflow-wrap: anywhere;
}

/* iframe 埋め込み時は背景を透過させたい場合に <body class="is-embedded"> */
body.is-embedded { background: transparent; }

img, svg { max-width: 100%; height: auto; }

a { color: var(--fe-accent); text-underline-offset: 3px; }
a:hover { color: var(--fe-accent-dark); }

:focus-visible {
  outline: 3px solid var(--fe-accent);
  outline-offset: 2px;
}

h1, h2, h3 {
  font-family: var(--fe-font-heading);
  font-weight: 700;
  line-height: 1.5;
  letter-spacing: 0.06em;
  margin: 0;
}

/* ---------- レイアウト ---------- */
.fe-page {
  max-width: 880px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.fe-header { margin-bottom: 20px; }
.fe-title { font-size: 26px; }
.fe-lead { margin: 8px 0 0; color: var(--fe-text-sub); }

@media (min-width: 640px) {
  .fe-page { padding: 40px 24px 64px; }
  .fe-title { font-size: 32px; }
}

/* ---------- カード ---------- */
.fe-card {
  background: var(--fe-card);
  border: 2px solid var(--fe-border);
  border-radius: var(--fe-r-card);
  box-shadow: var(--fe-shadow);
  padding: 20px 16px;
  margin: 0 0 20px;
}
.fe-card__title {
  font-size: 20px;
  margin: 0 0 14px;
  padding-left: 12px;
  border-left: 6px solid var(--fe-brand);
}
@media (min-width: 640px) {
  .fe-card { padding: 28px 28px; }
}

/* ---------- フォーム ---------- */
.fe-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}
@media (min-width: 640px) {
  .fe-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 24px; }
  .fe-grid > .fe-field--full { grid-column: 1 / -1; }
}

.fe-field { min-width: 0; margin: 0; padding: 0; border: 0; }
fieldset.fe-field { min-inline-size: 0; }

.fe-label {
  display: block;
  font-weight: 700;
  font-size: 17px;
  margin: 0 0 8px;
  padding: 0;
  color: var(--fe-text);
}
.fe-hint {
  display: block;
  font-weight: 400;
  font-size: 15px;
  color: var(--fe-text-muted);
  line-height: 1.6;
}

.fe-input,
.fe-select {
  display: block;
  width: 100%;
  min-height: var(--fe-tap);
  padding: 8px 14px;
  font: inherit;
  font-size: 18px;
  color: var(--fe-text);
  background: #fff;
  border: 2px solid var(--fe-border);
  border-radius: var(--fe-r-ctrl);
}
.fe-select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 44px;
  background-image: linear-gradient(45deg, transparent 50%, var(--fe-text-sub) 50%), linear-gradient(135deg, var(--fe-text-sub) 50%, transparent 50%);
  background-position: calc(100% - 22px) 50%, calc(100% - 16px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}
.fe-input:focus, .fe-select:focus { border-color: var(--fe-brand-deep); outline: none; box-shadow: 0 0 0 3px rgba(224, 150, 0, 0.3); }
.fe-input[type="number"] { text-align: right; }

/* ---------- セグメント（ラジオをボタン風に） ---------- */
.fe-segment {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
  min-inline-size: 0;
}
.fe-segment > legend { margin-bottom: 8px; }
.fe-segment > label { flex: 1 1 0; min-width: 0; position: relative; display: flex; }
.fe-segment--wrap > label { flex: 0 1 auto; }
.fe-segment input {
  position: absolute;
  opacity: 0;
  width: 1px; height: 1px;
  margin: 0;
}
.fe-segment input + span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: var(--fe-tap);
  padding: 8px 16px;
  text-align: center;
  line-height: 1.4;
  font-weight: 500;
  background: #fff;
  color: var(--fe-text);
  border: 2px solid var(--fe-border);
  border-radius: var(--fe-r-ctrl);
  cursor: pointer;
  transition: background-color .15s, border-color .15s;
}
.fe-segment input + span:hover { border-color: var(--fe-brand); }
.fe-segment input:checked + span {
  background: var(--fe-grad);
  border-color: var(--fe-brand-deep);
  font-weight: 700;
  box-shadow: inset 0 0 0 1px var(--fe-brand-deep);
}
.fe-segment input:checked + span::before { content: "✓"; margin-right: 6px; }
.fe-segment input:focus-visible + span { outline: 3px solid var(--fe-accent); outline-offset: 2px; }
.fe-segment input:disabled + span { opacity: .45; cursor: not-allowed; }

/* ---------- チェックボックス ---------- */
.fe-check {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: var(--fe-tap);
  padding: 10px 14px;
  background: #fff;
  border: 2px solid var(--fe-border);
  border-radius: var(--fe-r-ctrl);
  cursor: pointer;
}
.fe-check + .fe-check { margin-top: 8px; }
.fe-check input {
  flex: none;
  width: 24px; height: 24px;
  margin: 3px 0 0;
  accent-color: var(--fe-brand-deep);
  cursor: pointer;
}
.fe-check span { flex: 1; min-width: 0; line-height: 1.6; }
.fe-check small { display: block; font-size: 15px; color: var(--fe-text-muted); }
.fe-check:has(input:checked) { background: var(--fe-bg-soft); border-color: var(--fe-brand); }
.fe-check:has(input:disabled), .is-disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 回数入力 ---------- */
.fe-stepper { display: flex; align-items: stretch; gap: 6px; max-width: 240px; }
.fe-stepper .fe-input { flex: 1; min-width: 0; text-align: center; }

/* ---------- ボタン ---------- */
.fe-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--fe-tap);
  padding: 10px 22px;
  font: inherit;
  font-weight: 700;
  font-size: 17px;
  color: var(--fe-text);
  background: #fff;
  border: 2px solid var(--fe-border);
  border-radius: 999px;
  text-decoration: none;
  cursor: pointer;
  line-height: 1.4;
}
.fe-btn:hover { border-color: var(--fe-brand); color: var(--fe-text); }
.fe-btn--primary { background: var(--fe-grad); border-color: var(--fe-brand-deep); }
.fe-btn--primary:hover { filter: brightness(1.03); }
.fe-btn--ghost { background: transparent; }
.fe-btn--icon { width: var(--fe-tap); padding: 0; flex: none; font-size: 22px; border-radius: var(--fe-r-ctrl); }
.fe-btn:disabled { opacity: .45; cursor: not-allowed; }

.fe-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 16px 0; }
.fe-actions > .fe-btn { flex: 1 1 200px; }

/* ---------- タブ ---------- */
.fe-tabs {
  display: flex;
  gap: 8px;
  margin: 0 0 20px;
  padding: 6px;
  background: var(--fe-card);
  border: 2px solid var(--fe-border);
  border-radius: 999px;
}
.fe-tab {
  flex: 1 1 0;
  min-height: 52px;
  padding: 8px 12px;
  font: inherit;
  font-family: var(--fe-font-heading);
  font-weight: 700;
  font-size: 18px;
  color: var(--fe-text-sub);
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}
.fe-tab[aria-selected="true"] { background: var(--fe-grad); color: var(--fe-text); box-shadow: 0 2px 8px rgba(224, 150, 0, 0.3); }
.fe-panel[hidden] { display: none; }

/* ---------- 訪問パターン（詳細版） ---------- */
.fe-visit {
  border: 2px dashed var(--fe-border);
  border-radius: var(--fe-r-card);
  padding: 16px;
  margin: 0 0 14px;
  background: #fff;
}
.fe-visit__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  font-family: var(--fe-font-heading);
  font-weight: 700;
  font-size: 18px;
}

/* ---------- 結果 ---------- */
.fe-result {
  background: var(--fe-grad-soft);
  border: 3px solid var(--fe-brand);
  border-radius: var(--fe-r-card);
  padding: 20px 16px;
  margin: 0 0 20px;
  text-align: center;
  box-shadow: var(--fe-shadow);
}
.fe-result__label {
  margin: 0;
  font-family: var(--fe-font-heading);
  font-weight: 700;
  font-size: 18px;
}
.fe-result__amount {
  margin: 4px 0;
  font-family: var(--fe-font-heading);
  font-weight: 700;
  font-size: 48px;
  line-height: 1.2;
  color: var(--fe-accent);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
.fe-result__amount span { font-size: 24px; margin-left: 4px; color: var(--fe-text); }
.fe-result__sub { margin: 6px 0 0; color: var(--fe-text-sub); font-size: 17px; }
.fe-result__sub strong { font-size: 20px; color: var(--fe-text); }
@media (min-width: 640px) {
  .fe-result { padding: 28px; }
  .fe-result__amount { font-size: 60px; }
}
.fe-result--sticky {
  position: sticky;
  bottom: 8px;
  z-index: 10;
}

/* ---------- 内訳 ---------- */
.fe-breakdown {
  background: var(--fe-card);
  border: 2px solid var(--fe-border);
  border-radius: var(--fe-r-card);
  margin: 0 0 20px;
  overflow: hidden;
}
.fe-breakdown > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 12px 20px;
  font-family: var(--fe-font-heading);
  font-weight: 700;
  font-size: 18px;
  cursor: pointer;
  list-style: none;
}
.fe-breakdown > summary::-webkit-details-marker { display: none; }
.fe-breakdown > summary::after { content: "＋"; font-size: 22px; color: var(--fe-brand-deep); }
.fe-breakdown[open] > summary::after { content: "－"; }
.fe-breakdown > summary:hover { background: var(--fe-bg-soft); }
.fe-breakdown__body { padding: 0 16px 16px; }

.fe-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
  line-height: 1.6;
}
.fe-table caption { text-align: left; font-weight: 700; padding: 8px 0; }
.fe-table th, .fe-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--fe-border-soft);
  text-align: left;
  vertical-align: top;
}
.fe-table thead th { font-size: 15px; color: var(--fe-text-muted); font-weight: 500; border-bottom: 2px solid var(--fe-border); }
.fe-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.fe-table .note { display: block; font-size: 14px; color: var(--fe-text-muted); }
.fe-table tr.is-total th, .fe-table tr.is-total td { font-weight: 700; border-top: 2px solid var(--fe-border); background: var(--fe-bg-soft); }
.fe-table tr.is-strong td { color: var(--fe-accent); font-size: 18px; }

/* スマホ：表の行をカード状に縦積み（横スクロールなし） */
@media (max-width: 559px) {
  .fe-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .fe-table, .fe-table tbody, .fe-table tfoot, .fe-table tr, .fe-table th, .fe-table td { display: block; width: 100%; }
  .fe-table tr { padding: 10px 0; border-bottom: 1px solid var(--fe-border); }
  .fe-table th, .fe-table td { border: 0; padding: 2px 0; }
  .fe-table td.num { display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .fe-table td[data-label]::before { content: attr(data-label); color: var(--fe-text-muted); font-weight: 400; text-align: left; }
  .fe-table tr.is-total { padding: 10px 8px; }
}

/* ---------- 警告・注意書き ---------- */
.fe-warning {
  margin: 0 0 20px;
  padding: 14px 16px 14px 40px;
  background: #FFF4E5;
  border: 2px solid var(--fe-brand-deep);
  border-radius: var(--fe-r-ctrl);
  color: var(--fe-text);
  list-style: none;
  position: relative;
}
.fe-warning li { position: relative; }
.fe-warning li + li { margin-top: 6px; }
.fe-warning li::before { content: "!"; position: absolute; left: -26px; top: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--fe-brand-deep); color: #fff; font-weight: 700; font-size: 14px; line-height: 20px; text-align: center; }
.fe-warning:empty { display: none; }

.fe-notice {
  margin: 0 0 20px;
  padding: 16px;
  background: var(--fe-bg-soft);
  border-radius: var(--fe-r-ctrl);
  color: var(--fe-text-sub);
  font-size: 16px;
  line-height: 1.75;
}
.fe-notice ul { margin: 0; padding-left: 1.3em; }
.fe-notice li + li { margin-top: 4px; }
.fe-notice strong { color: var(--fe-text); }

/* ---------- 問い合わせ ---------- */
.fe-contact {
  text-align: center;
  background: var(--fe-card);
  border: 2px solid var(--fe-border);
  border-radius: var(--fe-r-card);
  padding: 20px 16px;
  margin: 0 0 20px;
}
.fe-contact p { margin: 0 0 6px; }
.fe-tel {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 8px 28px;
  font-family: var(--fe-font-heading);
  font-weight: 700;
  font-size: 26px;
  color: var(--fe-text);
  background: var(--fe-grad);
  border-radius: 999px;
  text-decoration: none;
  letter-spacing: 0.04em;
}
.fe-tel:hover { color: var(--fe-text); filter: brightness(1.03); }

/* ---------- 選択ページ（index.html） ---------- */
.fe-choice {
  display: block;
  padding: 22px 20px;
  margin: 0 0 16px;
  background: var(--fe-card);
  border: 2px solid var(--fe-border);
  border-radius: var(--fe-r-card);
  color: var(--fe-text);
  text-decoration: none;
  box-shadow: var(--fe-shadow);
}
.fe-choice:hover { border-color: var(--fe-brand); color: var(--fe-text); }
.fe-choice strong { display: block; font-family: var(--fe-font-heading); font-size: 22px; }
.fe-choice span { display: block; color: var(--fe-text-sub); }

/* ---------- フッター ---------- */
.fe-footer {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 2px solid var(--fe-border);
  color: var(--fe-text-muted);
  font-size: 15px;
  line-height: 1.7;
}
.fe-footer p { margin: 0; }

/* ---------- ユーティリティ ---------- */
.fe-sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.fe-print-only { display: none; }
.fe-mt-0 { margin-top: 0 !important; }
.fe-text-muted { color: var(--fe-text-muted); }

/* ---------- 印刷 ---------- */
/* ---------- スマホ幅の調整（サイト側で追加） ----------
 * 埋め込み先のページにも左右の余白があるため、外側の余白を詰めて横幅を確保する。
 * 選択ボタンの文字（「なし」など）が縦に割れないようにし、金額と「円」を同じ行に保つ。 */
@media (max-width: 559px) {
  .fe-page { padding: 8px 4px 32px; }
  .fe-card { padding: 18px 14px; }
  .fe-segment input + span { padding: 8px 10px; white-space: nowrap; }
  .fe-result__sub strong { white-space: nowrap; }
  .fe-title, .fe-card__title { word-break: auto-phrase; text-wrap: balance; }
}

@media print {
  @page { margin: 12mm; }
  body { background: #fff; font-size: 11pt; line-height: 1.6; }
  .fe-page { max-width: none; padding: 0; }
  .fe-no-print, .fe-tabs, .fe-actions, .fe-btn, .fe-stepper button, .fe-contact .fe-tel { display: none !important; }
  .fe-print-only { display: block !important; }
  .fe-card, .fe-breakdown, .fe-result, .fe-contact, .fe-notice, .fe-visit { box-shadow: none; break-inside: avoid; border-width: 1px; }
  .fe-result { background: #fff; border-color: #999; }
  .fe-result__amount { font-size: 32pt; }
  /* 印刷時：入力はチェックされた／選ばれたものだけを簡潔に */
  .fe-segment label:has(input:not(:checked)) { display: none; }
  .fe-segment input + span { border: 0; background: none; padding: 0; min-height: 0; justify-content: flex-start; }
  .fe-segment input:checked + span::before { content: ""; margin: 0; }
  .fe-check:not(:has(input:checked)) { display: none; }
  .fe-check { border: 0; background: none; padding: 0; min-height: 0; }
  .fe-input, .fe-select { border: 0; padding: 0; min-height: 0; background: none; text-align: left; }
  .fe-breakdown > summary::after { content: ""; }
  .fe-breakdown:not([open]) > *:not(summary) { display: block; }
  .fe-table thead { position: static; width: auto; height: auto; clip: auto; }
  .fe-table { display: table; }
  .fe-table thead { display: table-header-group; }
  .fe-table tbody { display: table-row-group; }
  .fe-table tr { display: table-row; }
  .fe-table th, .fe-table td { display: table-cell; padding: 4px 6px; border-bottom: 1px solid #ccc; }
  .fe-table td[data-label]::before { content: none; }
  a { color: inherit; text-decoration: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
