/* みくじ便利ツール 共通スタイル
   方針: A案（実務型）。装飾より読みやすさと操作しやすさを優先する。
   道具のHTMLはクラス参照だけなので、このファイルの差し替えで全ページの見た目が変わる。 */

:root {
  --bg: #ffffff;
  --fg: #16181d;
  --muted: #5a5f68;
  --line: #dfe2e7;
  --accent: #14539c;
  --accent-soft: #eef4fb;
  --card: #f7f8fa;
  --focus: #f0a202;
  --on-accent: #ffffff;   /* アクセント色の上に乗る文字 */
  --maxw: 700px;
  --radius: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171b;
    --fg: #e9eaee;
    --muted: #a4a9b2;
    --line: #2c3038;
    --accent: #86b6ec;

    --accent-soft: #1b2430;
    --card: #1c1f25;
    --focus: #ffc247;
    /* 明るいアクセントの上に白文字だと読めないので反転させる */
    --on-accent: #10151c;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans",
               "Noto Sans JP", "Yu Gothic UI", sans-serif;
  /* 本文は少し大きめ。計算結果を読み違えられると道具として意味がない */
  font-size: 17px;
  line-height: 1.8;
}

/* キーボード操作でも今どこにいるか分かるようにする */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

::selection { background: var(--accent-soft); }

/* ---- 上部 ---- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.topbar .home {
  color: var(--fg);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: .01em;
  padding: 6px 2px;
}
.topbar .home:hover { text-decoration: underline; }

.lang-switch a {
  display: inline-block;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 12px 15px;
  font-size: 13px;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}
.lang-switch a:hover { color: var(--fg); border-color: var(--fg); }

/* ---- 本文の枠 ---- */

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 20px 16px 56px; }

.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }
.crumbs span { margin: 0 2px; }

h1 {
  font-size: 1.7rem;
  line-height: 1.35;
  letter-spacing: -.01em;
  margin: 4px 0 6px;
}
h2 { font-size: 1.08rem; margin: 28px 0 8px; }
.lede { color: var(--muted); margin: 0 0 22px; }

/* ---- 道具本体 ---- */

.app {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 18px;
}

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 6px;
}

input[type="number"], input[type="text"], input[type="date"],
input[type="time"], select, textarea {
  width: 100%;
  /* 16px未満だとスマホでタップ時に勝手に拡大される */
  font-size: 16px;
  font-family: inherit;
  line-height: 1.5;
  padding: 11px 12px;
  min-height: 46px;            /* 指で押せる大きさを確保 */
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
}
input[type="number"] { font-variant-numeric: tabular-nums; }
textarea { min-height: 120px; resize: vertical; }
select { appearance: auto; }

input:hover, select:hover, textarea:hover { border-color: var(--muted); }

button.primary {
  background: var(--accent);
  color: var(--on-accent);
  border: 0;
  border-radius: 6px;
  padding: 13px 24px;
  min-height: 48px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}
button.primary:hover { filter: brightness(1.08); }
button.primary:active { filter: brightness(.94); }

/* ---- 計算結果 ---- */

/* 答えがどこかを迷わせない。左の縦線と背景で本体から切り離す */
.result {
  margin-top: 20px;
  padding: 14px 16px;
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 6px 6px 0;
}
.result .big {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}
.result .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }

/* ---- 内訳表 ---- */

.table-scroll { overflow-x: auto; margin-top: 12px; }
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
  font-weight: 400;
}
th { color: var(--muted); font-size: 14px; white-space: nowrap; }
/* 数字は右揃え＋等幅にして桁を比べやすくする */
td { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child th, tr:last-child td { border-bottom: 0; }

/* ---- ファイルの受け口（画像ツールなど） ---- */

.drop {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  background: var(--bg);
}
.drop:hover, .drop.is-over { border-color: var(--accent); background: var(--accent-soft); }
.drop input[type="file"] { display: none; }
.drop strong { display: block; color: var(--fg); font-size: 1.05rem; margin-bottom: 4px; }

/* 結果のプレビュー。画像は枠からはみ出させない */
.preview { margin-top: 16px; }
.preview img, .preview canvas {
  max-width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
}
.preview figcaption { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* 加工前と後を並べる */
.compare { display: grid; gap: 14px; margin-top: 16px; }
@media (min-width: 560px) { .compare { grid-template-columns: 1fr 1fr; } }

/* 保存ボタン。実行ボタンとは見た目を分ける */
button.secondary {
  background: var(--bg);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 12px 20px;
  min-height: 46px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
button.secondary:hover { background: var(--accent-soft); }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }

input[type="range"] { width: 100%; min-height: 44px; }

/* ---- よく使う値 ---- */

.presets { margin-top: 22px; }
.presets h2 { font-size: .95rem; margin: 0 0 8px; color: var(--muted); }
.preset-row { display: flex; flex-wrap: wrap; gap: 8px; }
.preset-row button {
  font: inherit;
  font-size: 15px;
  padding: 9px 15px;
  min-height: 42px;
  color: var(--accent);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.preset-row button:hover { border-color: var(--accent); background: var(--accent-soft); }

/* ---- 早見表 ---- */

.quicktable { margin-top: 30px; }
.quicktable h2 { margin-bottom: 4px; }
.quicktable thead th {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
  border-bottom: 1px solid var(--line);
}
.quicktable thead th:first-child { text-align: left; }
.quicktable td:first-child { text-align: left; }

/* ---- よくある質問 ---- */

.faq {
  margin-top: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.faq > summary {
  cursor: pointer;
  padding: 13px 16px;
  font-weight: 600;
  font-size: 15px;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.faq > summary::-webkit-details-marker { display: none; }
.faq > summary::before {
  content: "";
  width: 8px; height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform .15s ease;
  flex: none;
}
.faq[open] > summary::before { transform: rotate(45deg); }
.faq > summary:hover { color: var(--accent); }
.faq-body { padding: 4px 16px 14px; margin: 0; border-top: 1px solid var(--line); }
.faq-body dt { font-weight: 600; margin-top: 14px; }
.faq-body dd { margin: 4px 0 0; color: var(--fg); }

@media (prefers-reduced-motion: reduce) {
  .faq > summary::before { transition: none; }
}

/* ---- 説明（既定で閉じる） ---- */

.about {
  margin-top: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.about > summary {
  cursor: pointer;
  padding: 13px 16px;
  font-weight: 600;
  font-size: 15px;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.about > summary::-webkit-details-marker { display: none; }
.about > summary::before {
  content: "";
  width: 8px; height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform .15s ease;
  flex: none;
}
.about[open] > summary::before { transform: rotate(45deg); }
.about > summary:hover { color: var(--accent); }
.about-body { padding: 0 16px 14px; border-top: 1px solid var(--line); }
.about-body p { margin: 12px 0; }

@media (prefers-reduced-motion: reduce) {
  .about > summary::before { transition: none; }
}

.note { font-size: 13.5px; color: var(--muted); margin: 14px 2px 0; }

/* ---- 一覧のカード ---- */

.card-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.card-list a {
  display: block;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  background: var(--card);
}
.card-list a:hover { border-color: var(--accent); background: var(--accent-soft); }
.card-cat {
  display: inline-block;
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 9px;
  margin-bottom: 6px;
}
.card-title { display: block; font-weight: 700; font-size: 1.05rem; margin-bottom: 2px; }
.card-desc { display: block; font-size: 14px; color: var(--muted); line-height: 1.6; }

/* ---- 似た道具 ---- */

.related { margin-top: 30px; }
.related ul { list-style: none; margin: 0; padding: 0; }
.related li { border-bottom: 1px solid var(--line); }
.related li:first-child { border-top: 1px solid var(--line); }
.related li a {
  display: block;
  padding: 13px 2px;
  min-height: 46px;
  color: var(--accent);
  text-decoration: none;
}
.related li a:hover { text-decoration: underline; }

/* ---- 下部 ---- */

.site-footer {
  border-top: 1px solid var(--line);
  padding: 20px 16px 40px;
  text-align: center;
  font-size: 14px;
}
.site-footer a {
  color: var(--accent);
  display: inline-block;
  padding: 11px 12px;
}
.updated { color: var(--muted); font-size: 12px; margin: 10px 0 0; }

/* ---- 固定ページ（規約・プライバシー）は文章が主役なので幅を詰める ---- */

.wrap > h2 + p, .wrap > p { max-width: 34em; }

/* ---- 狭い画面 ---- */

@media (max-width: 480px) {
  body { font-size: 16.5px; }
  h1 { font-size: 1.5rem; }
  .result .big { font-size: 1.75rem; }
  .app { padding: 16px 14px; }
  button.primary { width: 100%; }
}
