/* 電設計算ノート ── 共通スタイル
   設計方針：現場でスマホ片手に使う。入力欄は大きく、結果は即時、ダークモード対応。 */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --text: #16181d;
  --text-muted: #5b6472;
  --border: #d7dce4;
  --accent: #0b63ce;
  --accent-weak: #e7f0fc;
  --ok: #0f7b46;
  --warn: #a8560a;
  --warn-bg: #fdf3e6;
  --danger: #b3261e;
  --danger-bg: #fdecea;
  --radius: 10px;
  --maxw: 780px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1c1f25;
    --surface-2: #23272f;
    --text: #e8eaee;
    --text-muted: #a2abba;
    --border: #333944;
    --accent: #6ea8f5;
    --accent-weak: #1d2836;
    --ok: #5fd39b;
    --warn: #e0a45c;
    --warn-bg: #2c2417;
    --danger: #f2857c;
    --danger-bg: #2e1c1a;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.75;
}

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 16px 64px;
}

/* ---------- ヘッダー / フッター ---------- */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header .wrap {
  padding: 12px 16px;
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.site-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: .02em;
}

.site-title a { color: var(--text); text-decoration: none; }

.site-tagline {
  font-size: .8rem;
  color: var(--text-muted);
  margin: 0;
}

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 24px 0;
  font-size: .85rem;
  color: var(--text-muted);
}

.site-footer .wrap { padding-bottom: 24px; }
.site-footer a { color: var(--text-muted); }
.site-footer nav { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }

/* ---------- 文字組み ---------- */

h1 { font-size: 1.5rem; line-height: 1.45; margin: 28px 0 8px; }
h2 { font-size: 1.2rem; margin: 36px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
h3 { font-size: 1.02rem; margin: 24px 0 6px; }
p { margin: 0 0 14px; }
a { color: var(--accent); }
small { color: var(--text-muted); }

.lead { color: var(--text-muted); margin-bottom: 24px; }

code, .mono {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Courier New", monospace;
  font-size: .92em;
}

.formula {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 0 0 14px;
  overflow-x: auto;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: .92rem;
}

/* ---------- パンくず ---------- */

.crumbs { font-size: .82rem; color: var(--text-muted); margin: 14px 0 0; }
.crumbs a { color: var(--text-muted); }

/* ---------- 計算カード ---------- */

.calc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin: 20px 0 28px;
}

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-weight: 600;
  font-size: .92rem;
  margin-bottom: 6px;
}

.field .hint {
  display: block;
  font-weight: 400;
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* 入力欄は現場での指操作を前提に大きく取る。16px未満にするとiOSで拡大されるので下げない */
input[type="number"],
input[type="text"],
select {
  width: 100%;
  padding: 12px 12px;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 48px;
}

input:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.field-row {
  display: flex;
  gap: 10px;
}
.field-row > * { flex: 1; min-width: 0; }

/* ---------- 結果表示 ---------- */

.result {
  background: var(--accent-weak);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 4px;
}

.result-main {
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.3;
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.result-main .unit { font-size: .95rem; font-weight: 600; margin-left: 4px; }

.result-label {
  font-size: .82rem;
  color: var(--text-muted);
  margin: 0 0 2px;
}

.result-sub {
  margin: 10px 0 0;
  font-size: .9rem;
  font-variant-numeric: tabular-nums;
}

.result-sub dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; }
.result-sub dt { color: var(--text-muted); }
.result-sub dd { margin: 0; text-align: right; }

.judge { font-weight: 700; }
.judge-ok { color: var(--ok); }
.judge-ng { color: var(--danger); }

/* ---------- 注意書き ---------- */

.note {
  border-left: 3px solid var(--border);
  padding: 10px 14px;
  margin: 0 0 16px;
  background: var(--surface-2);
  border-radius: 0 8px 8px 0;
  font-size: .9rem;
}

.note-warn {
  border-left-color: var(--warn);
  background: var(--warn-bg);
}

.note strong { display: block; margin-bottom: 2px; }

.disclaimer {
  border: 1px solid var(--border);
  border-left: 3px solid var(--danger);
  background: var(--danger-bg);
  border-radius: 0 8px 8px 0;
  padding: 12px 14px;
  margin: 28px 0 0;
  font-size: .88rem;
}
.disclaimer strong { display: block; margin-bottom: 4px; }

/* ---------- 表 ---------- */

.table-scroll { overflow-x: auto; margin: 0 0 16px; }

table {
  border-collapse: collapse;
  width: 100%;
  font-size: .9rem;
  font-variant-numeric: tabular-nums;
}
th, td {
  border: 1px solid var(--border);
  padding: 7px 10px;
  text-align: left;
  white-space: nowrap;
}
th { background: var(--surface-2); font-weight: 600; }

/* ---------- ツール一覧カード ---------- */

.tool-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 12px;
}

@media (min-width: 620px) {
  .tool-list { grid-template-columns: 1fr 1fr; }
}

.tool-list a {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-decoration: none;
  color: var(--text);
  height: 100%;
}

.tool-list a:hover, .tool-list a:focus-visible {
  border-color: var(--accent);
  background: var(--accent-weak);
}

.tool-list .name { display: block; font-weight: 700; margin-bottom: 2px; }
.tool-list .desc { display: block; font-size: .85rem; color: var(--text-muted); line-height: 1.6; }

/* ---------- 広告(PR)表記：リンクがある時だけJSで表示する ---------- */

.pr-label {
  font-size: .78rem;
  color: var(--text-muted);
  background: var(--surface-2);
  border-radius: 6px;
  padding: 5px 10px;
  margin: 12px 0 0;
}

[hidden] { display: none !important; }
