/* 計算ツールの共通の型（static/tool.js と対。素の CSS、外部依存無し）
   型（A4）: STEP1 条件を入れる / STEP2 結果 / STEP3 内訳 の3段＋下に「仕組み・使い分け・よくある質問」。
   色はサイト共通の CSS 変数だけを使う（static/style.css の :root）。
   2026-11-01 キボキャンプ繁栄値計算機の専用 CSS から切り出した（2 本目のガチャ天井計算機で型にした）。 */

.tool-kicker {
  display: inline-block;
  margin: 0 0 0.4rem;
  padding: 0.2rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-radius: 999px;
}

.tool-lead {
  max-width: 40rem;
  color: var(--muted);
}

.tk-tool {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas:
    "input result"
    "breakdown breakdown";
  gap: 1.25rem;
  margin: 1.5rem 0;
}

@media (max-width: 700px) {
  .tk-tool {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "input"
      "result"
      "breakdown";
  }
}

.tk-step {
  min-width: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 6px 18px var(--shadow);
  padding: 1rem 1.1rem 1.25rem;
}

.tk-step-input { grid-area: input; }
.tk-step-result { grid-area: result; }
.tk-step-breakdown { grid-area: breakdown; }

.tk-step-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0 0 0.9rem;
}

.tk-step-num {
  flex: 0 0 auto;
  width: 1.6rem;
  height: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
}

.tk-step-title {
  flex: 1 1 auto;
  margin: 0;
  font-size: 1rem;
}

.tk-step-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 0.5rem;
}

.tk-btn {
  flex: 0 0 auto;
  font-size: 0.82rem;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--accent-soft);
  color: var(--accent-dark);
  cursor: pointer;
  touch-action: manipulation;
}

.tk-btn:hover {
  background: var(--border);
}

.tk-share-fallback {
  margin-top: 0.75rem;
}

.tk-share-fallback label {
  display: block;
  margin: 0 0 0.3rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.tk-share-fallback input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.5rem;
  font-size: 0.82rem;
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  background: var(--bg-alt);
  color: var(--fg);
}

.tk-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.tk-form .field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.tk-form label {
  font-weight: 700;
  font-size: 0.92rem;
}

.stepper {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
}

.stepper-btn {
  flex: 0 0 auto;
  width: 2.75rem;
  height: 2.75rem;
  font-size: 1.5rem;
  line-height: 1;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--accent-soft);
  color: var(--fg);
  cursor: pointer;
  touch-action: manipulation;
}

.stepper-btn:active {
  background: var(--border);
}

.stepper-input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  height: 2.75rem;
  font-size: 1.25rem;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--card-bg);
  color: var(--fg);
  box-sizing: border-box;
  font-variant-numeric: tabular-nums;
}

.tk-result-main {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 0.75rem;
}

.tk-result-tile {
  min-width: 0;
  padding: 0.8rem 0.9rem;
  background: var(--accent-soft);
  border-radius: 0.75rem;
}

.tk-result-label {
  margin: 0 0 0.3rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.tk-result-num {
  margin: 0;
  font-size: clamp(1.2rem, 6vw, 1.6rem);
  font-weight: 700;
  color: var(--accent-dark);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.tk-goal {
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
}

.tk-goal-line {
  margin: 0 0 0.45rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.tk-goal-bar {
  height: 0.55rem;
  border-radius: 999px;
  background: var(--accent-soft);
  overflow: hidden;
}

.tk-goal-bar-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.2s ease;
}

.tk-goal-pct {
  margin: 0.4rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.tk-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tk-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.tk-table th,
.tk-table td {
  padding: 0.5rem 0.55rem;
  border-bottom: 1px solid var(--border);
  text-align: right;
  white-space: nowrap;
}

.tk-table th:first-child,
.tk-table td:first-child {
  text-align: left;
  white-space: normal;
}

.tk-table td {
  font-variant-numeric: tabular-nums;
}

.tk-table tfoot th,
.tk-table tfoot td {
  border-top: 2px solid var(--border);
  border-bottom: none;
  font-weight: 700;
}

.tk-table-note {
  margin: 0.7rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.tool-scope {
  max-width: 42rem;
  margin: 2rem 0 1rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-alt);
  font-size: 0.9rem;
}

.tool-scope h2 {
  margin: 0 0 0.3rem;
  font-size: 1rem;
}

.tool-scope-sub {
  margin: 0.9rem 0 0.3rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
}

.tool-scope ul {
  margin: 0;
  padding-left: 1.1rem;
}

.tool-scope li {
  margin: 0.2rem 0;
}

.tool-error {
  max-width: 34rem;
  padding: 0.85rem 1rem;
  color: var(--fg);
  background: var(--yellow-soft);
  border: 1px solid var(--yellow);
  border-radius: var(--radius);
}

@media (max-width: 480px) {
  .stepper-btn,
  .stepper-input {
    height: 3rem;
  }
  .stepper-btn {
    width: 3rem;
    font-size: 1.75rem;
  }
  .tk-step {
    padding: 0.9rem 0.85rem 1.1rem;
  }
  .tk-table {
    font-size: 0.78rem;
  }
  .tk-table th,
  .tk-table td {
    padding: 0.4rem 0.32rem;
  }
}

/* ---- 選択肢（ガチャの種類など。1 つだけ選ぶ） ---- */
.tk-choice { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0; padding: 0; border: 0; min-width: 0; }
.tk-choice legend { width: 100%; margin: 0 0 0.35rem; padding: 0; font-weight: 700; font-size: 0.92rem; }
.tk-choice label { flex: 1 1 8.5rem; min-width: 0; position: relative; }
.tk-choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.tk-choice span { display: block; height: 100%; box-sizing: border-box; padding: 0.55rem 0.7rem; border: 1px solid var(--border); border-radius: 0.6rem;
  background: var(--card-bg); font-size: 0.9rem; font-weight: 700; line-height: 1.35; }
.tk-choice span small { display: block; font-weight: 400; font-size: 0.78rem; color: var(--muted); }
.tk-choice input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); box-shadow: inset 0 0 0 1px var(--accent); }
.tk-choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.tk-hint { margin: 0.1rem 0 0; font-size: 0.8rem; color: var(--muted); }
.tk-add { align-self: flex-start; }

/* ---- 結果の言い切り（STEP2 の一番上の 1 行） ---- */
.tk-verdict { margin: 0 0 0.8rem; padding: 0.75rem 0.9rem; border-radius: 0.75rem; font-weight: 800; font-size: 1.05rem; line-height: 1.45;
  background: var(--accent-soft); color: var(--accent-dark); }
.tk-verdict small { display: block; margin-top: 0.2rem; font-weight: 400; font-size: 0.85rem; color: var(--fg); }
.tk-verdict.is-ok { background: #e3f4ea; color: #187a4c; }
.tk-verdict.is-short { background: var(--yellow-soft); color: #7a5600; }
.tk-sub { margin: 0.9rem 0 0; padding-top: 0.8rem; border-top: 1px solid var(--border); font-size: 0.9rem; }
.tk-sub p { margin: 0.3rem 0; }

/* ---- 計算機の下の読み物（仕組み・使い分け・よくある質問） ---- */
.tool-guide { max-width: 46rem; }
.tool-faq details { margin: 0.5rem 0; padding: 0.7rem 0.9rem; border: 1px solid var(--border); border-radius: 0.6rem; background: var(--card-bg); }
.tool-faq summary { font-weight: 700; cursor: pointer; }
.tool-faq details p { margin: 0.5rem 0 0; }
.tk-form [hidden] { display: none; }
.tk-table tr.tk-row-have td { background: var(--accent-soft); font-weight: 700; }

/* ---- 属性の選択肢（短い札を横に並べる） ---- */
.tk-choice-el label { flex: 0 1 3.4rem; }
.tk-choice-el span { padding: 0.5rem 0.2rem; text-align: center; }

/* ---- 倍率の色（上がる＝緑・下がる＝黄） ---- */
.tk-chart th, .tk-chart td { text-align: center !important; }
.tk-chart td.is-up, .tk-rank tr.is-ok td { background: #e3f4ea; color: #187a4c; font-weight: 700; }
.tk-chart td.is-down, .tk-rank tr.is-short td { background: var(--yellow-soft); color: #7a5600; }
.tk-each td { text-align: left !important; white-space: normal !important; }

/* ---- 名前で探す ---- */
.tk-search { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.6rem; }
.tk-search label { font-weight: 700; font-size: 0.92rem; }
.tk-search-input { height: 2.75rem; padding: 0 0.8rem; font-size: 1rem; border: 1px solid var(--border); border-radius: 0.5rem; background: var(--card-bg); color: var(--fg); box-sizing: border-box; width: 100%; }
.tk-hits { list-style: none; margin: 0 0 0.6rem; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tk-kibo-h { margin: 0.4rem 0 0.5rem; font-weight: 700; }
.tk-chart { font-size: 0.85rem; }
.tk-chart th:first-child { white-space: nowrap !important; }
@media (max-width: 480px) {
  .tk-chart { font-size: 0.74rem; }
  .tk-chart th, .tk-chart td { padding: 0.35rem 0.1rem !important; }
}
