/* 道具のサイト（名前は未定）の共通の見た目。
   1段組・スマホ先・数字は等幅。色は墨と、押せる所の藍の2つだけ。注意は茶。 */
:root {
  --bg: #f6f7f8;
  --surface: #ffffff;
  --fg: #1c232b;
  --muted: #5a6570;
  --line: #d9dee3;
  --accent: #1f4f8f;
  --accent-soft: #e6eef8;
  --warn: #8a4a12;
  --warn-soft: #f8ede2;
  --ok: #24663f;
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", "Meiryo", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Menlo", "Consolas", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161a;
    --surface: #1a2026;
    --fg: #e4e9ee;
    --muted: #9ba7b2;
    --line: #2c353e;
    --accent: #8ab4ea;
    --accent-soft: #1d2b3c;
    --warn: #e8a873;
    --warn-soft: #2f241b;
    --ok: #7fcf9d;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.75;
}
a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.site-header, .site-footer, main {
  max-width: 760px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.site-header { padding-block: 12px; }
.brand { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; text-decoration: none; color: var(--fg); }
.brand-mark { flex: none; }
.brand strong { font-size: 18px; letter-spacing: 0.03em; }
.brand span { font-size: 12px; color: var(--muted); }
main { padding-block: 8px 40px; display: flex; flex-direction: column; gap: 32px; }
.site-footer {
  padding-block: 20px 32px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.site-footer nav { display: flex; gap: 16px; flex-wrap: wrap; }

h1 { font-size: 26px; line-height: 1.35; margin: 8px 0 0; text-wrap: balance; }
h2 { font-size: 19px; line-height: 1.4; margin: 0; padding-bottom: 6px; border-bottom: 1px solid var(--line); text-wrap: balance; }
h3 { font-size: 16px; margin: 0; }
p { margin: 0; }
section { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
ul, ol { margin: 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: 4px; }
.lead { color: var(--muted); }
.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; vertical-align: top; padding: 8px 12px; border-bottom: 1px solid var(--line); }
th { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.n { text-align: right; white-space: nowrap; font-family: var(--mono); font-variant-numeric: tabular-nums; }

.formula {
  font-family: var(--mono);
  font-size: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 14px;
  overflow-x: auto;
  white-space: pre;
}

.note { background: var(--warn-soft); border-radius: 6px; padding: 12px 14px; }
.note strong { color: var(--warn); }

/* ── 道具の入力と結果 ── */
.tool { display: flex; flex-direction: column; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .label { font-size: 14px; font-weight: 600; }
.field .hint { font-size: 13px; color: var(--muted); }
textarea, input[type="number"], input[type="text"], select {
  font: inherit;
  font-size: 16px; /* iPhone で拡大されないように16px */
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  width: 100%;
  min-width: 0;
}
textarea { font-family: var(--mono); min-height: 9.5em; resize: vertical; line-height: 1.6; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .field { flex: 1 1 180px; }
.choices { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.choices label { display: inline-flex; gap: 6px; align-items: center; font-weight: 400; }

.results { display: flex; flex-direction: column; gap: 10px; }
.result { border: 1px solid var(--line); border-radius: 6px; padding: 12px; display: flex; flex-direction: column; gap: 8px; background: var(--bg); min-width: 0; }
.result .raw { font-family: var(--mono); font-weight: 600; overflow-wrap: anywhere; }
.result .what { font-size: 14px; color: var(--muted); }
.result .figures { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 15px; }
.result .figures b { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.result.warn { border-color: var(--warn); }
.result .message { font-size: 14px; color: var(--warn); }
.result .inputs { display: flex; flex-wrap: wrap; gap: 8px 12px; }
.result .inputs label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); flex: 1 1 120px; }
.result .candidates { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.result .candidates label { display: flex; gap: 8px; align-items: baseline; }

.totals { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.totals .grand { font-size: 18px; font-weight: 700; font-family: var(--mono); font-variant-numeric: tabular-nums; }

.app-link { display: flex; flex-direction: column; gap: 8px; background: var(--accent-soft); border-radius: 8px; padding: 14px 16px; }
.app-link a { font-weight: 600; }

/* ── トップ: アイコンの棚（ホーム画面）と、職種ごとの一覧（App Store の行）── */
main:has(> .hero) { padding-top: 0; }
.hero { gap: 14px; padding-block: 18px 22px; }
.hero h1 { font-size: 28px; line-height: 1.3; margin: 0; }
.launcher { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 16px 8px; margin-top: 6px; }
.launcher a { display: flex; flex-direction: column; align-items: center; gap: 6px; text-decoration: none; color: var(--fg); font-size: 12px; font-weight: 600; line-height: 1.3; text-align: center; }
.launcher img { width: 64px; height: 64px; border-radius: 15px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18); }
.trade { gap: 10px; }
.trade h2 { display: flex; align-items: center; gap: 8px; border-bottom: 0; padding-bottom: 0; font-size: 17px; }
.trade h2::before { content: ""; width: 6px; height: 1.1em; border-radius: 3px; background: var(--trade, var(--accent)); flex: none; }
.tool-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.tool-list a { display: flex; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; text-decoration: none; color: var(--fg); }
.tool-list .tool-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.tool-list .tool-text strong { font-size: 16px; line-height: 1.4; }
.tool-list .tool-text > span { font-size: 13px; color: var(--muted); line-height: 1.5; }
.tool-list .ph { display: inline-block; }
.tool-list a img { border-radius: 13px; flex: none; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18); }
.tool-list .open { flex: none; background: var(--tint, var(--accent)); color: #FFFFFF; font-weight: 700; font-size: 14px; border-radius: 999px; padding: 4px 14px; }

/* ── 道具のページ＝1つのアプリ（2026-10-18 発注者「それぞれのアプリをアプリっぽく別にして欲しい」）──
   肌は iPhone の現場計算の本と同じ（電線管の肌）: 地 #FDFCFA・白い角丸のカード・状態の3色（緑＝入る／橙＝注意／朱＝入らない）。
   アプリの色（--tint）は道具ごと＝page.mjs の tint（帯・見出し・選んでいる物・リンク）。 */
body.is-app {
  --bg: #FDFCFA;
  --surface: #FFFFFF;
  --line: rgba(20, 23, 26, 0.10);
  --accent: var(--tint);
  --accent-soft: color-mix(in srgb, var(--tint) 10%, #FFFFFF);
  --ok: #2A7A55;
  --ok-soft: #E3F1E9;
  --warn: #B8791E;
  --warn-soft: #FBF0DC;
  --ng: #CF4520;
  --ng-soft: #FBE6DE;
  --field: #F7F5F1;
  background: var(--bg);
}
@media (prefers-color-scheme: dark) {
  body.is-app {
    --bg: #12161a;
    --surface: #1b2127;
    --line: rgba(255, 255, 255, 0.10);
    --accent: color-mix(in srgb, var(--tint) 55%, #FFFFFF);
    --accent-soft: color-mix(in srgb, var(--tint) 22%, #12161a);
    --ok: #7fcf9d; --ok-soft: #1c2e24;
    --warn: #e8b36a; --warn-soft: #2e2618;
    --ng: #f08a6c; --ng-soft: #33201b;
    --field: #232a31;
  }
}

.app-bar {
  background: var(--tint);
  color: #FFFFFF;
  padding-top: env(safe-area-inset-top, 0px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}
.app-bar > * {
  max-width: 760px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.app-bar-home {
  display: flex;
  align-items: center;
  gap: 6px;
  color: rgba(255, 255, 255, 0.88);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding-block: 8px 0;
}
.app-bar-home:hover { color: #FFFFFF; }
.app-bar-title { display: flex; align-items: center; gap: 12px; padding-block: 6px 12px; }
.app-bar-title img { border-radius: 10px; background: #FFFFFF; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); flex: none; }
.app-bar-title span, .app-bar-title h1 { font-size: 19px; font-weight: 700; line-height: 1.3; text-wrap: balance; margin: 0; color: inherit; }

body.is-app main { padding-block: 14px 40px; gap: 28px; }
/* 帯の下の1文（何をする道具か）。本文の h1 は帯へ移してある */
body.is-app main > section:first-child .lead { font-size: 14px; margin: 0; }
body.is-app .tool {
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  padding: 18px 16px;
  gap: 16px;
}
body.is-app .tool > h2 { color: var(--accent); border-bottom: 0; padding-bottom: 0; font-size: 18px; }
body.is-app input[type="radio"], body.is-app input[type="checkbox"] { accent-color: var(--accent); }
body.is-app textarea, body.is-app input[type="number"], body.is-app input[type="text"], body.is-app select {
  background: var(--field);
  border-radius: 10px;
}
body.is-app .result { background: var(--surface); border-radius: 14px; }
body.is-app .result.warn { border-color: var(--warn); background: var(--warn-soft); }
body.is-app .result .message { color: var(--warn); }
body.is-app .ok, body.is-app .is-ok { color: var(--ok); }
body.is-app .ng, body.is-app .is-ng { color: var(--ng); }
body.is-app .app-link { background: var(--accent-soft); border-radius: 20px; }
body.is-app .app-link a {
  display: inline-block;
  align-self: flex-start;
  background: #14171A;
  color: #FFFFFF;
  text-decoration: none;
  border-radius: 999px;
  padding: 8px 18px;
}
/* 道具の画面のあとの読み物（使い方・計算式・出典）。畳まない＝Google が読む */
body.is-app .tool + section:not(.tool):not(.app-link) {
  margin-top: 8px;
  padding-top: 22px;
  border-top: 1px dashed var(--line);
  position: relative;
}
body.is-app .tool + section:not(.tool):not(.app-link)::before {
  content: "使い方と計算式";
  position: absolute;
  top: -0.8em;
  left: 0;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: var(--bg);
  padding-right: 8px;
}

@media (max-width: 480px) {
  h1 { font-size: 22px; }
  .app-bar-title span, .app-bar-title h1 { font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
