/* sokutool — DESIGN.md のトークンだけで組む。hex は :root のみ */
:root {
  --bg: #f6f4f0;
  --surface: #ffffff;
  --border: #d8d3cb;
  --text-primary: #1f1d19;
  --text-secondary: #5f5a52;
  --accent: #0b6a98;
  --on-accent: #ffffff;
  --result: #eef4f8;

  --font-display: 'Hiragino Sans', 'Noto Sans JP', 'Yu Gothic Medium', 'Yu Gothic', sans-serif;
  --font-body: 'Hiragino Sans', 'Noto Sans JP', 'Yu Gothic Medium', 'Yu Gothic', sans-serif;
  --font-mono: 'SF Mono', Menlo, Consolas, 'Noto Sans Mono', monospace;

  --radius-small: 6px;
  --radius-large: 10px;

  --space: 8px;
  --space-section: 40px;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --duration-fast: 160ms;
  --duration-ui: 200ms;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
}

/* .container: 本文16px で全角40字(=672px)に収まる幅 + 16px の左右余白 */
.container {
  width: 100%;
  max-width: 672px;
  margin-inline: auto;
  padding-inline: 16px;
}

img, svg, table { max-width: 100%; }

h1, h2, h3 { font-family: var(--font-display); font-weight: 700; line-height: 1.4; }
h1 { font-size: 28px; margin: 24px 0 8px; }
h2 { font-size: 22px; margin: 32px 0 8px; }
h3 { font-size: 18px; margin: 24px 0 8px; }

a { color: var(--accent); }

:where(a, button, input, textarea, select, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-small);
}

/* ヘッダー: surface 地・下 1px 罫・高さ 56px */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.site-header .container {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0;
}
.site-header nav { display: flex; gap: 16px; }
.site-header nav a {
  font-size: 14px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 2px;
}
.site-header nav a:hover, .brand:hover { text-decoration: underline; }

/* パンくず: 13px / text-secondary / 区切りは › */
.breadcrumb {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 16px 0 0;
}
.breadcrumb a { color: var(--text-secondary); }

.lead { font-size: 18px; color: var(--text-secondary); margin: 8px 0 24px; }

/* signature: 変換式ライン(h1 直下、mono 18px、1行で省略) */
.formula {
  font-family: var(--font-mono);
  font-size: 18px;
  color: var(--text-secondary);
  margin: 0 0 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.5;
}

/* 作業面(入力→結果)。ツール操作部は行間 1.5 に詰める */
.tool {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-large);
  padding: 16px;
  margin: 24px 0;
  line-height: 1.5;
}
.field { display: block; margin-bottom: 16px; }
.field > label, .tool label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
}
.tool textarea,
.tool input[type="text"],
.tool input[type="number"],
.tool input[type="date"],
.tool select {
  width: 100%;
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  padding: 12px;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  min-height: 44px;
}
.tool textarea { min-height: 120px; resize: vertical; }

/* 主ボタン(実行) */
.btn-primary, .btn {
  font-family: var(--font-body);
  font-size: 16px;
  min-height: 44px;
  padding: 10px 20px;
  border-radius: var(--radius-small);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0 8px 8px 0;
}
.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  border: 1px solid var(--accent);
  font-weight: 700;
}
/* 補助ボタン(コピー/クリア)。btn-primary と併記されたときは主ボタンを優先する */
.btn:not(.btn-primary) {
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--accent);
  font-size: 14px;
  font-weight: 400;
}
.btn-primary[disabled], .btn[disabled] { opacity: .5; cursor: default; }

@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover:not([disabled]) {
    background: color-mix(in srgb, var(--accent) 88%, var(--text-primary));
    border-color: color-mix(in srgb, var(--accent) 88%, var(--text-primary));
  }
  .btn:not(.btn-primary):hover:not([disabled]) { background: var(--result); }
  .card:hover { border-color: var(--accent); }
}
@media (prefers-reduced-motion: no-preference) {
  .btn-primary, .btn { transition: transform var(--duration-fast) var(--ease-out); }
  .btn-primary:active:not([disabled]), .btn:active:not([disabled]) { transform: scale(0.97); }
}

/* 結果欄: 3行分の高さを先に確保して CLS を防ぐ */
.result {
  display: block;
  width: 100%;
  background: var(--result);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  padding: 12px;
  margin: 16px 0 0;
  min-height: calc(1.5em * 3 + 24px);
  font-family: var(--font-mono);
  font-size: 16px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.result:empty::before { content: 'ここに結果が出ます'; color: var(--text-secondary); }

/* .ad-slot: 操作ボタンから上下 24px 以上離す(誤クリック防止)+ min-height で CLS 防止 */
.ad-slot {
  display: block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  min-height: 100px;
  margin: 40px 0;
  padding: 24px 8px 8px;
  position: relative;
}
.ad-slot::before {
  content: '広告';
  position: absolute;
  top: 6px;
  left: 8px;
  font-size: 13px;
  line-height: 1;
  color: var(--text-secondary);
}

/* カード(ツール一覧) */
.card-grid { display: grid; gap: 16px; grid-template-columns: 1fr; margin: 24px 0 40px; }
.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-large);
  padding: 16px;
  color: var(--text-primary);
  text-decoration: none;
}
.card h2 { font-size: 18px; margin: 0 0 4px; color: var(--accent); }
.card p { font-size: 14px; color: var(--text-secondary); margin: 0; line-height: 1.6; }

/* 解説(読み物) */
.guide { margin: 0 0 40px; }
.guide h2 { font-size: 22px; }
.guide h3 { font-size: 18px; }
.guide p, .guide li { font-size: 16px; line-height: 1.7; }
.guide ul, .guide ol { padding-left: 1.4em; }
.guide li { margin-bottom: 8px; }
.guide code {
  font-family: var(--font-mono);
  font-size: 14px;
  background: var(--result);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  padding: 1px 4px;
}
.guide pre {
  background: var(--result);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  padding: 12px;
  overflow-x: auto;
}
.guide pre code { border: 0; padding: 0; background: none; }
.guide table { border-collapse: collapse; width: 100%; }
.guide th, .guide td { border: 1px solid var(--border); padding: 8px; text-align: left; font-size: 14px; }

/* フッター */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  margin-top: 40px;
  padding: 16px 0;
}
.site-footer nav { display: flex; flex-wrap: wrap; gap: 8px 24px; }
.site-footer nav a {
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}
.site-footer p { font-size: 13px; color: var(--text-secondary); margin: 8px 0 0; }

@media (min-width: 768px) {
  h1 { font-size: 28px; }
  .card-grid { grid-template-columns: 1fr 1fr; }
  .tool { padding: 24px; }
}
