/*
 * 損益分岐点の計算ツール（/apps/break-even/）
 * apps.css・style.css の変数（--red-primary 等）の上に重ねる。カードは 1px の淡い線＋ごく淡い影まで、角は 4px まで。
 * 黒字は文字色（濃い灰）と薄い灰の面、赤字は赤の薄い面で見せる（指定外の色を足さない）。
 */

.be-hero { padding: clamp(88px, 9vw, 108px) 0 clamp(56px, 8vw, 96px); background: linear-gradient(180deg, var(--white) 0%, #f6f6f6 100%); }
/* 1画面目は 道具の名前 → 損益分岐点の数字 → 意味の一言 → グラフ → 入力 の順。h1 は小さめにしてツールを押し下げない */
.be-title { max-width: 1180px; margin: 0 auto clamp(16px, 2vw, 22px); font-family: var(--font-ja); font-size: clamp(1.5rem, 3vw, 2.125rem); font-weight: 800; line-height: 1.35; text-align: center; word-break: keep-all; overflow-wrap: break-word; }
.be-hero.is-crumb { padding-top: clamp(12px, 2vw, 20px); }
.be-about { max-width: 820px; margin: clamp(24px, 3vw, 32px) auto 0; text-align: center; }
.be-lead { font-size: 0.9375rem; line-height: 1.85; color: var(--text-secondary); word-break: keep-all; overflow-wrap: break-word; }

/* サイト共通の style.css は html・body に overflow-x: hidden をかけていて、そのままだと右のグラフの追従（sticky）が効かない。
   このページだけ clip に替える（横スクロールを出さない点は同じ。clip を知らない古いブラウザでは追従しないだけ） */
html, body { overflow-x: clip; }

/* ツール本体：左に入力、右に動くグラフ（右は追従する） */
.be-app { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.25fr); gap: 24px; align-items: start; max-width: 1180px; margin: 0 auto; }
.be-inputs, .be-viz, .be-metrics {
  background: var(--white); border: 1px solid #e6e6e6; border-radius: 4px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); min-width: 0;
}
.be-inputs { padding: 20px 22px 22px; }
.be-right { position: sticky; top: 88px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.be-viz { padding: 18px 20px 14px; border-top-color: var(--red-primary); }

.be-tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: 4px; background: #f1f1f1; margin-bottom: 14px; }
.be-tab { min-height: 40px; padding: 6px 8px; border: 0; border-radius: 3px; background: transparent; font-family: var(--font-ja-body); font-size: 0.8125rem; font-weight: 700; line-height: 1.4; color: var(--text-secondary); cursor: pointer; word-break: keep-all; transition: background 0.2s, color 0.2s; }
.be-tab[aria-selected="true"] { background: var(--white); color: var(--text-primary); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }
.be-tab:focus-visible { outline: 2px solid var(--red-primary); outline-offset: 1px; }


.be-field { display: grid; grid-template-columns: minmax(0, 1fr) 170px; align-items: center; gap: 4px 12px; padding: 12px 0; border-bottom: 1px solid #f0f0f0; }
.be-label { font-size: 0.875rem; font-weight: 700; line-height: 1.5; }
.be-hint { display: block; font-size: 0.75rem; font-weight: 400; color: var(--text-light); word-break: keep-all; }
.be-input { display: flex; align-items: center; border: 1px solid #cfcfcf; border-radius: 4px; background: var(--white); transition: border-color 0.2s, background 0.2s; }
.be-input:focus-within { border-color: var(--red-primary); background: #fffafa; }
.be-input input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; padding: 9px 6px 9px 12px; font-family: var(--font-ja-body); font-size: 1.125rem; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; color: var(--text-primary); }
.be-unit { padding-right: 12px; font-size: 0.8125rem; color: var(--text-secondary); }
.be-field.is-plain { border-bottom: 0; }

/* スライダー：押さえた所まで赤で埋める */
.be-range { grid-column: 1 / -1; width: 100%; height: 28px; margin: 2px 0 0; background: transparent; -webkit-appearance: none; appearance: none; cursor: pointer; --fill: 0%; }
.be-range::-webkit-slider-runnable-track { height: 6px; border-radius: 9999px; background: linear-gradient(90deg, var(--red-primary) var(--fill), #e4e4e4 var(--fill)); }
.be-range::-moz-range-track { height: 6px; border-radius: 9999px; background: #e4e4e4; }
.be-range::-moz-range-progress { height: 6px; border-radius: 9999px; background: var(--red-primary); }
.be-range::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -8px; border-radius: 50%; background: var(--white); border: 1px solid #cfcfcf; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); transition: transform 0.15s; }
.be-range::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--white); border: 1px solid #cfcfcf; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }
.be-range:active::-webkit-slider-thumb { transform: scale(1.15); }
.be-range:focus-visible { outline: 2px solid var(--red-primary); outline-offset: 2px; border-radius: 4px; }

.be-try { margin-top: 14px; padding: 14px; border-radius: 4px; background: #f6f6f6; }
.be-try-label { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 0.875rem; font-weight: 700; }
.be-try-label .lucide { width: 18px; height: 18px; color: var(--red-primary); }
.be-try-label span { font-size: 0.75rem; font-weight: 400; color: var(--text-light); }
.be-try-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.be-chip { min-height: 40px; padding: 0 16px; border: 1px solid #cfcfcf; border-radius: 9999px; background: var(--white); font-size: 0.875rem; font-weight: 700; color: var(--text-primary); cursor: pointer; transition: all 0.2s; }
.be-chip:hover { border-color: var(--red-primary); color: var(--red-primary); }
.be-chip[aria-pressed="true"] { border-color: var(--red-primary); background: var(--red-primary); color: var(--white); }
.be-chip:focus-visible { outline: 2px solid var(--red-primary); outline-offset: 2px; }
.be-try-out { margin-top: 10px; font-size: 0.8125rem; line-height: 1.7; color: var(--text-secondary); word-break: keep-all; overflow-wrap: break-word; }
.be-try-out b { color: var(--red-primary); }

/* 右：数字とグラフ */
.be-kpi-label { font-size: 0.8125rem; font-weight: 700; color: var(--text-secondary); }
.be-kpi-num { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; color: var(--red-primary); }
.be-kpi-num b { font-size: clamp(2.25rem, 4.5vw, 3rem); font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.be-kpi-num span { font-size: 1.0625rem; font-weight: 700; }
.be-kpi-num small { font-size: 0.875rem; font-weight: 700; color: var(--text-primary); }
.be-status { margin-top: 4px; min-height: 1.7em; font-size: 0.9375rem; font-weight: 700; line-height: 1.7; color: var(--text-secondary); word-break: keep-all; overflow-wrap: break-word; }
.be-status.is-loss { color: var(--red-dark); }
.be-badge { display: inline-block; margin-right: 8px; padding: 1px 10px; border-radius: 9999px; font-size: 0.75rem; font-weight: 800; line-height: 1.7; vertical-align: 1px; }
.be-badge.is-profit { background: var(--text-primary); color: var(--white); }
.be-badge.is-loss { background: var(--red-primary); color: var(--white); }
.be-status.is-profit { color: var(--text-primary); }

.be-chart { display: block; width: 100%; height: auto; margin-top: 10px; touch-action: none; user-select: none; cursor: ew-resize; }
.be-chart text { font-family: var(--font-ja-body); }
.be-chart .c-grid { stroke: #efefef; stroke-width: 1; }
.be-chart .c-tick { font-size: 11px; fill: var(--text-light); font-variant-numeric: tabular-nums; }
.be-chart .c-empty { font-size: 14px; fill: var(--text-light); }
.be-chart .c-loss { fill: rgba(204, 0, 0, 0.1); }
.be-chart .c-profit { fill: rgba(17, 17, 17, 0.07); }
.be-chart .c-fixed { stroke: #bdbdbd; stroke-width: 1.5; stroke-dasharray: 5 5; }
.be-chart .c-cost { stroke: var(--text-primary); stroke-width: 2.5; }
.be-chart .c-sales { stroke: var(--red-primary); stroke-width: 2.5; }
.be-chart .c-ghost { stroke: #9e9e9e; stroke-width: 1.5; stroke-dasharray: 3 4; opacity: 0.8; }
.be-chart .c-ghost-dot { fill: var(--white); stroke: #9e9e9e; stroke-width: 1.5; }
.be-chart .c-line-label { font-size: 12px; font-weight: 700; fill: var(--text-primary); }
.be-chart .c-line-label.is-sales { fill: var(--red-primary); }
.be-chart .c-line-label.is-light { fill: var(--text-light); font-weight: 400; }
.be-chart .c-target { stroke: #9e9e9e; stroke-width: 1; stroke-dasharray: 2 4; }
.be-chart .c-target-label { font-size: 11px; fill: var(--text-light); }
.be-chart .c-now { stroke: var(--text-primary); stroke-width: 1; stroke-dasharray: 4 3; opacity: 0.55; }
.be-chart .c-gap { stroke-width: 5; stroke-linecap: round; }
.be-chart .c-gap.is-profit { stroke: rgba(17, 17, 17, 0.55); }
.be-chart .c-gap.is-loss { stroke: rgba(204, 0, 0, 0.55); }
.be-chart .c-now-tag rect { fill: var(--white); stroke: #e0e0e0; }
.be-chart .c-now-tag text { font-size: 11px; fill: var(--text-secondary); }
.be-chart .c-now-tag text.is-strong { font-size: 13px; font-weight: 800; }
.be-chart .c-now-tag.is-profit text.is-strong { fill: var(--text-primary); }
.be-chart .c-now-tag.is-loss text.is-strong { fill: var(--red-primary); }
.be-chart .c-handle { fill: var(--white); stroke: var(--text-primary); stroke-width: 2; cursor: grab; }
.be-chart .c-bep-guide { stroke: var(--red-primary); stroke-width: 1; stroke-dasharray: 3 3; }
.be-chart .c-bep { fill: var(--red-primary); stroke: var(--white); stroke-width: 2; }
.be-chart .c-bep-pulse { fill: rgba(204, 0, 0, 0.35); transform-box: fill-box; transform-origin: center; animation: bePulse 1.8s ease-out infinite; }
.be-chart .c-bep-label { font-size: 13px; font-weight: 800; fill: var(--red-primary); paint-order: stroke; stroke: var(--white); stroke-width: 4px; stroke-linejoin: round; }
@keyframes bePulse { from { transform: scale(1); opacity: 0.9; } to { transform: scale(3.2); opacity: 0; } }
.be-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; margin-top: 2px; font-size: 0.6875rem; color: var(--text-secondary); }
.be-legend span { display: inline-flex; align-items: center; gap: 5px; }
.be-legend span::before { content: ''; display: inline-block; width: 14px; height: 2px; background: var(--text-primary); }
.be-legend .is-sales::before { background: var(--red-primary); }
.be-legend .is-fixed::before { height: 0; background: none; border-top: 1px dashed #9e9e9e; }
.be-legend .is-bep::before { width: 8px; height: 8px; border: 0; border-radius: 50%; background: var(--red-primary); }
.be-drag-hint { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 4px; font-size: 0.75rem; color: var(--text-light); }
.be-drag-hint .lucide { width: 14px; height: 14px; }

.be-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin: 0; overflow: hidden; }
.be-metrics > div { padding: 12px 14px; border-right: 1px solid #f0f0f0; border-bottom: 1px solid #f0f0f0; min-width: 0; }
.be-metrics > div:nth-child(4) { border-right: 0; }
.be-metrics > div.is-wide { grid-column: 1 / -1; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; border-right: 0; border-bottom: 0; }
.be-metrics dt { font-size: 0.75rem; font-weight: 700; color: var(--text-secondary); line-height: 1.5; }
.be-metrics dd { margin-top: 2px; font-size: 1.125rem; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--text-primary); white-space: nowrap; }
.be-metrics dd.is-loss { color: var(--red-primary); }
.be-metrics > div.is-wide dd { margin: 0; }
.be-disclaimer { margin: 8px auto 0; font-size: 0.8125rem; line-height: 1.8; color: var(--text-light); text-align: center; word-break: keep-all; overflow-wrap: break-word; }

/* 本文 */
.be-h3 { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; margin: 2.5rem 0 0.75rem; font-family: var(--font-ja); font-size: clamp(1.125rem, 2.2vw, 1.3125rem); font-weight: 700; line-height: 1.55; word-break: keep-all; overflow-wrap: break-word; }
.be-h3 .lucide { flex: none; width: 20px; height: 20px; color: var(--red-primary); }
.be-text { font-size: 1rem; line-height: 1.9; color: var(--text-secondary); word-break: keep-all; overflow-wrap: break-word; }
.be-text code { padding: 1px 6px; border-radius: 4px; background: #ececec; font-size: 0.9375em; color: var(--text-primary); }
.be-nb { white-space: nowrap; }
.app-section p { text-wrap: pretty; }

.be-table-wrap { overflow-x: auto; background: var(--white); border: 1px solid #e6e6e6; border-radius: 4px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }
.be-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.be-table th, .be-table td { padding: 12px 16px; border-bottom: 1px solid #efefef; text-align: right; white-space: nowrap; font-size: 0.9375rem; line-height: 1.6; }
.be-table thead th { background: #f6f6f6; font-size: 0.8125rem; font-weight: 700; color: var(--text-secondary); }
.be-table th:first-child { text-align: left; }
.be-table tbody th { font-weight: 700; color: var(--text-primary); }
.be-table tbody th .lucide { width: 16px; height: 16px; margin-right: 6px; vertical-align: -3px; color: var(--red-primary); }
.be-table td.is-wrap { white-space: normal; text-align: left; min-width: 12em; word-break: keep-all; }
.be-table tbody tr:last-child th, .be-table tbody tr:last-child td { border-bottom: 0; }

.be-fig { margin: 0; padding: 24px; background: var(--white); border: 1px solid #e6e6e6; border-radius: 4px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }
.be-fig svg { display: block; width: 100%; height: auto; }
.be-fig text { font-family: var(--font-ja-body); }
.be-fig .fig-axis { stroke: #cfcfcf; stroke-width: 1; }
.be-fig .fig-loss { fill: rgba(204, 0, 0, 0.1); }
.be-fig .fig-profit { fill: rgba(17, 17, 17, 0.07); }
.be-fig .fig-fixed { stroke: #bdbdbd; stroke-width: 1.5; stroke-dasharray: 5 5; }
.be-fig .fig-cost { stroke: var(--text-primary); stroke-width: 2.5; }
.be-fig .fig-sales { stroke: var(--red-primary); stroke-width: 2.5; }
.be-fig .fig-guide { stroke: var(--red-primary); stroke-width: 1; stroke-dasharray: 3 3; }
.be-fig .fig-dot { fill: var(--red-primary); stroke: var(--white); stroke-width: 2; }
.be-fig .fig-t { font-size: 15px; font-weight: 700; fill: var(--text-primary); }
.be-fig .fig-t.is-red { fill: var(--red-primary); font-weight: 800; }
.be-fig .fig-t.is-light { fill: var(--text-light); font-weight: 400; font-size: 13px; }
.be-fig .fig-t.is-loss { fill: var(--red-dark); font-size: 16px; }
.be-fig .fig-t.is-profit { fill: var(--text-primary); font-size: 16px; }
.be-fig.is-bar { margin: 20px 0; padding: 16px 20px; }
.be-fig svg.is-sp { display: none; }
.be-fig .fig-s { font-size: 13px; font-weight: 700; fill: var(--text-primary); }
.be-fig .fig-s.is-red { fill: var(--red-primary); font-weight: 800; }
.be-fig .fig-s.is-light { fill: var(--text-light); font-weight: 400; font-size: 12px; }
.be-fig .fig-s.is-on-dark { fill: var(--white); }
.be-fig .fig-bar-loss { fill: var(--text-primary); }
.be-fig .fig-bar-safe { fill: rgba(17, 17, 17, 0.1); }
.be-fig .fig-bar-fixed { fill: var(--text-primary); }
.be-fig .fig-bar-target { fill: var(--red-primary); }
.be-fig .fig-bar-var { fill: rgba(17, 17, 17, 0.1); }
.be-fig .fig-t.is-on-dark { fill: var(--white); font-size: 14px; }
.be-fig figcaption { margin-top: 16px; display: flex; flex-direction: column; gap: 6px; }
.be-fig .cfig-cap-title { font-weight: 700; font-size: 1rem; }
.be-fig .cfig-cap-text { font-size: 0.875rem; line-height: 1.85; color: var(--text-secondary); }

.be-split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.be-split-col { padding: 18px 20px; background: var(--white); border: 1px solid #e6e6e6; border-radius: 4px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }
.be-split-title { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-weight: 700; }
.be-split-title .lucide { width: 18px; height: 18px; color: var(--red-primary); }
.be-split-col p:last-child { font-size: 0.9375rem; line-height: 1.85; color: var(--text-secondary); word-break: keep-all; overflow-wrap: break-word; }

.be-article, .be-article * { text-decoration: none; }
.be-article { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 20px; align-items: center; padding: 16px; background: var(--white); border: 1px solid #e6e6e6; border-radius: 4px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); transition: border-color 0.3s; }
.be-article:hover { border-color: var(--red-primary); }
.be-article img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; }
.be-article-body { display: flex; flex-direction: column; gap: 6px; }
.be-article-cat { font-size: 0.75rem; font-weight: 700; color: var(--red-primary); }
.be-article-title { font-family: var(--font-ja); font-size: 1.0625rem; font-weight: 700; line-height: 1.6; color: var(--text-primary); }
.cta .cta-button .lucide { width: 18px; height: 18px; }
.be-cta-text { max-width: 720px; margin: -1.5rem auto 2.25rem; font-size: 0.9375rem; line-height: 1.9; color: rgba(255, 255, 255, 0.75); word-break: keep-all; overflow-wrap: break-word; }

/* タブレット以下：グラフを上に追従させ、入力をその下で動かす */
@media (max-width: 960px) {
  .be-app { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .be-right { display: contents; }
  .be-viz { position: sticky; top: 60px; z-index: 5; order: -1; padding: 12px 14px 8px; }
  .be-metrics { order: 2; }
  .be-inputs { order: 1; }
  .be-kpi-label { font-size: 0.75rem; }
  .be-kpi-num b { font-size: 1.625rem; }
  .be-status { margin-top: 0; font-size: 0.75rem; line-height: 1.6; min-height: 0; }
  .be-chart { margin-top: 4px; }
  .be-drag-hint { display: none; }
}
@media (max-width: 768px) {
  .be-hero { padding-top: 76px; }
  .be-hero.is-crumb { padding-top: 8px; }
  .be-title { font-size: 1.375rem; margin-bottom: 12px; }
  .be-lead { font-size: 0.875rem; line-height: 1.8; text-align: left; }
  .be-disclaimer { text-align: left; }
  .be-inputs { padding: 14px 14px 16px; }
  .be-field { grid-template-columns: minmax(0, 1fr) 150px; padding: 10px 0; }
  .be-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .be-metrics > div:nth-child(2) { border-right: 0; }
  .be-metrics > div:nth-child(4) { border-right: 0; }
  .be-metrics > div.is-wide { flex-direction: column; gap: 2px; }
  .be-split { grid-template-columns: minmax(0, 1fr); }
  .be-article { grid-template-columns: minmax(0, 1fr); }
  .be-fig { padding: 16px; }
  .be-fig svg.is-pc { display: none; }
  .be-fig svg.is-sp { display: block; }
  .be-table th, .be-table td { padding: 10px 8px; font-size: 0.8125rem; }
  .be-table thead th { white-space: normal; word-break: keep-all; vertical-align: bottom; }
  /* 下げる方法の表は、1行を1枚のカードにする */
  .be-table.is-cards thead { display: none; }
  .be-table.is-cards tr { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid #efefef; }
  .be-table.is-cards tbody tr:last-child { border-bottom: 0; }
  .be-table.is-cards th, .be-table.is-cards td { border: 0; text-align: left; padding: 4px 12px; }
  .be-table.is-cards th { grid-column: 1 / -1; padding-top: 12px; }
  .be-table.is-cards td.is-wrap { grid-column: 1 / -1; color: var(--text-secondary); }
  .be-table.is-cards td:last-child { padding-bottom: 12px; }
  .be-table.is-cards td[data-label]:not(.is-wrap)::before { content: attr(data-label); display: block; font-size: 0.6875rem; color: var(--text-light); }
  .be-table td.is-wrap { min-width: 0; }
  .be-table tbody th .lucide { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .be-chart .c-bep-pulse { animation: none; opacity: 0; }
}
