:root {
  --bg: #f7f5f0;
  --card: #ffffff;
  --ink: #1b2430;
  --muted: #5b6573;
  --line: #e4dfd5;
  --primary: #0e6b63;
  --primary-dark: #0a4f49;
  --primary-soft: #e3f1ee;
  --accent: #e8a33d;
  --accent-soft: #fdf3df;
  --danger: #b4452f;
  --danger-soft: #fbe9e4;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(27, 36, 48, 0.05), 0 6px 18px rgba(27, 36, 48, 0.06);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Noto Sans JP", "Meiryo", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.8;
  letter-spacing: 0.01em;
}
a { color: var(--primary); text-underline-offset: 3px; }
a:hover { color: var(--primary-dark); }
img, svg { max-width: 100%; }
[hidden] { display: none !important; }

.wrap { width: min(1040px, 100% - 32px); margin-inline: auto; }

/* ---- header / footer ---- */
.site-header { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 58px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; color: var(--ink); text-decoration: none; letter-spacing: 0.02em; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 16px; font-weight: 800; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 8px; font-size: 14px; font-weight: 600; }
.nav a:hover { background: var(--primary-soft); color: var(--primary-dark); }

.site-footer { margin-top: 64px; background: #17302d; color: #cfe3df; padding: 40px 0 28px; font-size: 14px; }
.site-footer a { color: #e7f4f1; }
.footer-grid { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 28px; }
.footer-grid h3 { color: #fff; font-size: 14px; margin: 0 0 10px; letter-spacing: 0.06em; }
.footer-grid ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.copy { margin-top: 28px; padding-top: 18px; border-top: 1px solid rgba(255, 255, 255, 0.14); font-size: 12px; color: #9dbab5; }

/* ---- hero / index ---- */
.hero { padding: 52px 0 28px; }
.hero h1 { font-size: clamp(26px, 4.6vw, 40px); line-height: 1.35; margin: 0 0 14px; letter-spacing: 0.01em; }
.hero h1 em { font-style: normal; color: var(--primary); background: linear-gradient(transparent 62%, var(--accent-soft) 62%); }
.hero p { color: var(--muted); max-width: 640px; margin: 0 0 18px; font-size: 17px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--card); border: 1px solid var(--line); padding: 4px 12px; border-radius: 999px; font-size: 13px; color: var(--muted); }

.section-title { font-size: 22px; margin: 44px 0 6px; }
.section-sub { color: var(--muted); margin: 0 0 18px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.tool-card { display: flex; flex-direction: column; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; text-decoration: none; color: var(--ink); box-shadow: var(--shadow); transition: transform 0.15s, border-color 0.15s; }
.tool-card:hover { transform: translateY(-2px); border-color: var(--primary); color: var(--ink); }
.tool-card .no { font-size: 12px; font-weight: 800; color: var(--primary); letter-spacing: 0.1em; }
.tool-card h3 { margin: 0; font-size: 18px; line-height: 1.5; }
.tool-card p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.7; }
.tool-card .pain { margin-top: auto; padding-top: 8px; font-size: 13px; color: var(--primary-dark); font-weight: 600; }

.persona-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.persona { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.persona h3 { margin: 0 0 4px; font-size: 16px; }
.persona p { margin: 0; font-size: 14px; color: var(--muted); }

/* ---- tool page ---- */
.crumbs { font-size: 13px; color: var(--muted); padding: 18px 0 0; }
.crumbs a { color: var(--muted); }
.tool-head { padding: 10px 0 18px; }
.tool-head h1 { font-size: clamp(24px, 4vw, 34px); line-height: 1.4; margin: 6px 0 10px; }
.tool-head .lead { color: var(--muted); margin: 0; max-width: 760px; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; color: var(--primary-dark); background: var(--primary-soft); padding: 2px 10px; border-radius: 999px; }

.tool-layout { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); gap: 20px; align-items: start; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.panel h2 { font-size: 16px; margin: 0 0 14px; }
.panel + .panel { margin-top: 16px; }
.tool-layout > div { min-width: 0; }
.result-col { position: sticky; top: 74px; }

.field { margin-bottom: 14px; }
.field > label, .field > .lbl { display: block; font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.field > label.check { display: flex; font-weight: 400; font-size: 14px; margin: 6px 0; }
.field .hint { display: block; font-size: 12.5px; color: var(--muted); font-weight: 400; margin-top: 3px; line-height: 1.6; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

input[type="number"], input[type="text"], input[type="date"], select, textarea {
  width: 100%;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: #fff;
  border: 1.5px solid #d6d0c3;
  border-radius: 10px;
  padding: 9px 12px;
  min-height: 44px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
#out { min-height: 380px; }
textarea { min-height: 150px; line-height: 1.7; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(14, 107, 99, 0.18); }
.unit { position: relative; }
.unit input { padding-right: 44px; }
.unit .u { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 13px; color: var(--muted); pointer-events: none; }

.check { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; margin: 6px 0; }
.check input { margin-top: 6px; width: 18px; height: 18px; accent-color: var(--primary); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: inline-block; padding: 7px 14px; border: 1.5px solid #d6d0c3; border-radius: 999px; font-size: 14px; font-weight: 600; background: #fff; color: var(--muted); }
.seg input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.seg input:focus-visible + span { box-shadow: 0 0 0 3px rgba(14, 107, 99, 0.25); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-size: 14px; font-weight: 700; padding: 9px 16px; border-radius: 10px; border: 1.5px solid var(--primary); background: var(--primary); color: #fff; cursor: pointer; min-height: 40px; }
.btn:hover { background: var(--primary-dark); }
.btn.ghost { background: #fff; color: var(--primary-dark); }
.btn.ghost:hover { background: var(--primary-soft); }
.btn.small { padding: 5px 12px; min-height: 32px; font-size: 13px; }

.result-hero { background: var(--primary); color: #fff; border-radius: 12px; padding: 18px 20px; margin-bottom: 14px; }
.result-hero .label { font-size: 13px; opacity: 0.85; font-weight: 600; }
.result-hero .big { font-size: clamp(28px, 5vw, 38px); font-weight: 800; line-height: 1.25; letter-spacing: 0.01em; font-variant-numeric: tabular-nums; word-break: break-all; }
.result-hero .sub { font-size: 13px; opacity: 0.9; margin-top: 2px; }
.kv { margin: 0; padding: 0; list-style: none; }
.kv li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 15px; }
.kv li:last-child { border-bottom: none; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.kv li.total { border-top: 2px solid var(--ink); border-bottom: none; margin-top: 4px; font-size: 16px; }
.kv li.total .k { color: var(--ink); font-weight: 700; }

.note { background: var(--accent-soft); border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: 8px; font-size: 13.5px; line-height: 1.7; margin: 12px 0 0; }
.note.warn { background: var(--danger-soft); border-left-color: var(--danger); }
.note.ok { background: var(--primary-soft); border-left-color: var(--primary); }

table.simple { width: 100%; border-collapse: collapse; font-size: 14px; }
table.simple th, table.simple td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
table.simple th:first-child, table.simple td:first-child { text-align: left; }
table.simple td.nw, table.simple th.nw { white-space: nowrap; }
table.simple thead th { background: #faf8f3; font-size: 13px; color: var(--muted); }
table.simple tr.best td { background: var(--primary-soft); font-weight: 700; }
.table-scroll { overflow-x: auto; }

.verdicts { display: grid; gap: 10px; }
.verdict { border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px; background: #fff; }
.verdict h3 { margin: 0 0 4px; font-size: 15px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.verdict p { margin: 0; font-size: 14px; color: #36404d; line-height: 1.75; }
.tag { font-size: 12px; font-weight: 800; padding: 1px 9px; border-radius: 999px; color: #fff; }
.tag.must { background: var(--danger); }
.tag.rec { background: var(--primary); }
.tag.opt { background: #8a93a0; }
.verdict.must { border-color: var(--danger); background: #fffaf8; }
.verdict.rec { border-color: var(--primary); background: #f8fcfb; }

.outbox { width: 100%; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* ---- article ---- */
.article { margin-top: 36px; }
.article .panel { padding: 26px 28px; }
.article h2 { font-size: 21px; margin: 32px 0 10px; padding-left: 12px; border-left: 5px solid var(--primary); line-height: 1.5; }
.article h2:first-child { margin-top: 0; }
.article h3 { font-size: 17px; margin: 22px 0 6px; }
.article p { margin: 0 0 14px; }
.article ul, .article ol { margin: 0 0 14px; padding-left: 1.4em; }
.article li { margin-bottom: 4px; }
.faq details { border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; margin-bottom: 10px; background: #fff; }
.faq summary { cursor: pointer; font-weight: 700; }
.faq details[open] summary { margin-bottom: 8px; color: var(--primary-dark); }
.faq details p { margin: 0; color: #36404d; font-size: 15px; }
.meta-line { font-size: 12.5px; color: var(--muted); margin-top: 18px; }

.related { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.related a { display: block; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; text-decoration: none; color: var(--ink); font-weight: 700; font-size: 14px; line-height: 1.6; }
.related a small { display: block; color: var(--muted); font-weight: 400; font-size: 12.5px; }
.related a:hover { border-color: var(--primary); }

.disclaimer { font-size: 13px; color: var(--muted); background: #fff; border: 1px dashed #cfc8b8; border-radius: 10px; padding: 12px 16px; margin-top: 20px; }

.ad { margin: 24px 0; text-align: center; min-height: 0; }
.ad-label { font-size: 11px; color: #8a93a0; display: block; margin-bottom: 2px; }

.page-simple { padding: 28px 0 0; max-width: 780px; }
.page-simple h1 { font-size: 30px; line-height: 1.4; }
.page-simple h2 { font-size: 19px; margin-top: 30px; }

/* sub-rows (option lines etc.) */
.line-item { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.line-item.inv { grid-template-columns: 1.4fr 1fr 0.9fr auto; }
.icon-btn { width: 36px; height: 36px; border-radius: 8px; border: 1.5px solid #d6d0c3; background: #fff; cursor: pointer; font-size: 18px; line-height: 1; color: var(--muted); }
.icon-btn:hover { border-color: var(--danger); color: var(--danger); }

@media (max-width: 860px) {
  .tool-layout { grid-template-columns: minmax(0, 1fr); }
  .result-col { position: static; }
  .footer-grid { grid-template-columns: 1fr; }
  .article .panel { padding: 20px 18px; }
  .nav a.hide-sm { display: none; }
}
@media (max-width: 520px) {
  .row, .row3 { grid-template-columns: 1fr; }
  .line-item { grid-template-columns: 1fr 1fr auto; }
  .line-item.inv { grid-template-columns: 1fr 1fr; }
  body { font-size: 15.5px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
@media print {
  .site-header, .site-footer, .ad, .article, .related-wrap, .actions { display: none !important; }
  .tool-layout { grid-template-columns: 1fr; }
}

/* --- カテゴリ・検索・入力補助 --- */
.tool-search { margin: 14px 0 6px; display: grid; gap: 12px; }
.tool-search input[type=search] { width: 100%; padding: 12px 14px; font-size: 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.chip-link { text-decoration: none; color: var(--primary-dark); }
.chip-link:hover { border-color: var(--primary); }
.cat-block { margin-top: 28px; }
.cat-title { margin: 0 0 2px; font-size: 19px; }
.cat-title small { font-size: 12px; color: var(--muted); font-weight: 600; margin-left: 4px; }
.cat-desc { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.tool-card[hidden], .cat-block[hidden] { display: none; }
.readout { display: block; margin-top: 4px; font-size: 12.5px; color: var(--primary-dark); min-height: 1em; }
.tool-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.tool-actions .btn { font-size: 13px; }
@media print {
  .site-header, .site-footer, .ad, .tool-actions, .article, .related-wrap, .crumbs, .tool-head, .disclaimer { display: none !important; }
  body { background: #fff; }
  .tool-layout { display: block; }
}
@media print {
  /* 書類作成ツール: body.print-doc のとき、結果欄（プレビュー）だけを印刷する */
  body.print-doc main .wrap > *:not(.tool-layout) { display: none !important; }
  body.print-doc .tool-layout > div:first-child { display: none !important; }
  body.print-doc .tool-layout { display: block !important; }
  body.print-doc .result-col { position: static !important; }
  body.print-doc .result-col .panel { border: 0; box-shadow: none; padding: 0; }
  body.print-doc .no-print { display: none !important; }
}

/* 横はみ出しの保険（古い端末・iOSのdate入力など） */
body { overflow-x: hidden; }
input, select, textarea { max-width: 100%; min-width: 0; }
input[type=date], input[type=time], input[type=month] { -webkit-appearance: none; appearance: none; display: block; width: 100%; min-height: 44px; }

/* --- 広告枠 --- */
.ad { margin: 32px 0; text-align: center; clear: both; }
.ad-label { font-size: 11px; color: #8a93a0; display: block; margin-bottom: 4px; letter-spacing: 0.08em; }
.ad ins { display: block; width: 100%; }
.ad-result { margin-top: 28px; }              /* 直前のボタン類から十分に離す（誤クリック防止） */
.ad-inline { margin: 28px 0; }
.ad-dummy .ad-box { display: flex; align-items: center; justify-content: center; background: repeating-linear-gradient(45deg, #eef0f3, #eef0f3 10px, #f6f7f9 10px, #f6f7f9 20px); border: 1px dashed #b7bec9; color: #6b7480; font-size: 14px; border-radius: 8px; }
@media print { .ad { display: none !important; } }

/* --- 解説記事 --- */
.guide { max-width: 820px; margin: 0 auto; }
.guide-head h1 { font-size: clamp(24px, 4vw, 32px); line-height: 1.45; margin: 8px 0 12px; }
.guide .meta-line { color: var(--muted); font-size: 13px; }
.toc { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; margin: 18px 0; font-size: 14.5px; }
.toc ol { margin: 8px 0 0; padding-left: 1.4em; line-height: 1.9; }
.guide-body { font-size: 16.5px; line-height: 1.95; }
.guide-body h2 { font-size: 22px; margin: 2.2em 0 0.6em; padding-left: 12px; border-left: 5px solid var(--primary); line-height: 1.5; scroll-margin-top: 72px; }
.guide-body h3 { font-size: 18px; margin: 1.7em 0 0.4em; }
.guide-body table { border-collapse: collapse; width: 100%; font-size: 14.5px; margin: 1em 0; display: block; overflow-x: auto; }
.guide-body th, .guide-body td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.guide-body th { background: var(--primary-soft); white-space: nowrap; }
.guide-body .callout { background: var(--accent-soft); border-left: 4px solid var(--accent); padding: 12px 16px; border-radius: 8px; margin: 1.2em 0; font-size: 15px; line-height: 1.8; }
.guide-body .calc { background: #fff; border: 1px dashed var(--primary); border-radius: 10px; padding: 12px 16px; margin: 1.2em 0; font-size: 15px; line-height: 1.8; }
.guide-body .tool-link { display: block; margin: 1.2em 0; padding: 12px 16px; border: 1px solid var(--primary); border-radius: 10px; text-decoration: none; font-weight: 700; background: var(--primary-soft); }
.src-h { font-size: 16px; margin: 0 0 8px; }
.src-list { margin: 0; padding-left: 1.3em; font-size: 14px; line-height: 1.9; word-break: break-all; }

/* ヘッダー：スマホで折り返さない */
@media (max-width: 640px) {
  .site-header .wrap { gap: 8px; }
  .brand { font-size: 14.5px; white-space: nowrap; gap: 8px; }
  .nav { flex-wrap: nowrap; gap: 0; }
  .nav a { padding: 6px 8px; font-size: 13px; white-space: nowrap; }
}
@media (max-width: 360px) {
  .brand { font-size: 13px; }
  .brand-mark { display: none; }
}
