:root {
  --bg: #f6f7f6;
  --surface: #ffffff;
  --surface-2: #f0f3f2;
  --field-bg: #ffffff;
  --text: #1c2321;
  --muted: #5b6764;
  --line: #d9e0de;
  --field-line: #8a9693; /* 入力欄の枠は背景と 3:1 以上 */
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #e3f3f1;
  --warn: #b45309;
  --warn-soft: #fdf3e4;
  --error: #b91c1c;
  --radius: 12px;
  --tap: 44px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 2px 8px rgb(0 0 0 / 0.04);
  --font: system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Noto Sans Mono CJK JP", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121615;
    --surface: #1a201f;
    --surface-2: #222a28;
    --field-bg: #222a28;
    --text: #e6ecea;
    --muted: #9aa8a4;
    --line: #2f3a38;
    --field-line: #5f6f6b;
    --accent: #2dd4bf;
    --accent-ink: #062320;
    --accent-soft: #15302d;
    --warn: #fbbf24;
    --warn-soft: #2b2416;
    --error: #f87171;
    --shadow: none;
    color-scheme: dark;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.8;
  overflow-wrap: break-word;
  line-break: strict;
}

/* 日本語の見出し・説明は文節の切れ目で折り返す（対応ブラウザのみ） */
h1, h2, h3, .lead, .tool-list span, .faq summary { word-break: auto-phrase; text-wrap: balance; }

a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }

.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }

.skip-link { position: absolute; left: 8px; top: -60px; z-index: 10; background: var(--accent); color: var(--accent-ink); padding: 10px 14px; border-radius: 8px; font-weight: 700; text-decoration: none; }
.skip-link:focus { top: 8px; }
main:focus { outline: none; }

/* ヘッダー */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-header > .wrap { display: flex; align-items: center; min-height: 56px; }
.logo { display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); color: var(--text); text-decoration: none; font-weight: 700; font-size: 1.15rem; }
.logo svg { color: var(--accent); }
.logo small { color: var(--muted); font-weight: 500; font-size: 0.8rem; letter-spacing: 0.02em; }
.site-nav { border-top: 1px solid var(--line); }
.site-nav .wrap { display: flex; gap: 4px; overflow-x: auto; padding-top: 4px; padding-bottom: 4px; scrollbar-width: none; }
.site-nav .wrap::-webkit-scrollbar { display: none; }
.site-nav a { flex: none; display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 12px; border-radius: 999px; color: var(--muted); text-decoration: none; font-size: 0.9rem; white-space: nowrap; }
.site-nav a:hover { background: var(--surface-2); color: var(--text); }
.site-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 700; }

/* 本文 */
main { padding-bottom: 48px; }
.crumbs { margin-top: 16px; font-size: 0.85rem; color: var(--muted); }
.crumbs a { color: var(--muted); }
h1 { font-size: 1.6rem; line-height: 1.4; margin: 20px 0 8px; }
.lead { color: var(--muted); margin: 0 0 20px; }
h2 { font-size: 1.25rem; line-height: 1.5; margin: 40px 0 12px; padding-bottom: 6px; border-bottom: 2px solid var(--line); }
h3 { font-size: 1.05rem; margin: 28px 0 8px; }
p, ul, ol { margin: 0 0 14px; }
li { margin-bottom: 4px; }
code { font-family: var(--mono); font-size: 0.92em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
pre { background: var(--surface-2); padding: 12px 14px; border-radius: 8px; overflow-x: auto; line-height: 1.6; }
pre code { background: none; padding: 0; }
.note { font-size: 0.88rem; color: var(--muted); }
.meta { font-size: 0.85rem; color: var(--muted); margin-top: 32px; }
.callout { background: var(--warn-soft); border-left: 4px solid var(--warn); padding: 10px 14px; border-radius: 6px; font-size: 0.93rem; margin: 16px 0; }
.sources ul { font-size: 0.92rem; }
.contact-mail { font-size: 1.2rem; font-weight: 700; }

/* 余白のユーティリティ（style 属性を使わないため） */
.mt-0 { margin-top: 0 !important; }
.mt-s { margin-top: 8px; }
.mt-m { margin-top: 12px; }

table { width: 100%; border-collapse: collapse; margin: 0 0 16px; font-size: 0.95rem; }
th, td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
th { background: var(--surface-2); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; margin-bottom: 16px; position: relative; }
.table-scroll table { margin: 0; }

/* ツールのカード */
.tool { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin: 0 0 20px; }
.tool > h2:first-child { margin-top: 0; font-size: 1.1rem; border: 0; padding: 0; }
.tool-hint { font-size: 0.88rem; color: var(--muted); margin: -4px 0 12px; }
.tool-hint.mt-m { margin: 12px 0 8px; }

label { font-size: 0.9rem; color: var(--muted); }
input[type="text"], input[type="time"], select {
  font: inherit;
  font-size: 1.1rem;
  color: var(--text);
  background: var(--field-bg);
  border: 1px solid var(--field-line);
  border-radius: 8px;
  padding: 8px 10px;
  min-height: var(--tap);
  width: 100%;
  font-variant-numeric: tabular-nums;
}
input::placeholder { color: var(--muted); opacity: 0.6; }
input:focus-visible, select:focus-visible, button:focus-visible, summary:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[aria-invalid="true"] { border-color: var(--error); box-shadow: 0 0 0 1px var(--error); }
.field { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.unit-input { display: flex; align-items: center; gap: 6px; }
.unit-input input { text-align: right; }
.unit-input span { flex: none; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; align-items: end; }
.hm { display: flex; flex-direction: column; gap: 2px; }
.hm .grid-2 { gap: 12px; }
@media (max-width: 480px) { .grid-3.stack-sm { grid-template-columns: 1fr 1fr; } }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); font-size: 0.92rem; color: var(--text); cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

.btn {
  font: inherit;
  font-size: 0.95rem;
  border-radius: 8px;
  border: 1px solid var(--field-line);
  background: var(--surface);
  color: var(--text);
  padding: 8px 14px;
  min-height: var(--tap);
  cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* 次のステップ（ツールの下に1つだけ出す案内） */
.next-step { background: var(--accent-soft); border-left: 4px solid var(--accent); border-radius: 8px; padding: 12px 16px; margin: 0 0 20px; }
.next-step-label { margin: 0; font-size: 0.8rem; font-weight: 700; color: var(--accent); letter-spacing: 0.04em; }
.next-step-text { margin: 4px 0 10px; }
.next-step-cta { display: inline-flex; align-items: center; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; text-decoration: none; }
.next-step-cta:hover { background: var(--accent); filter: brightness(1.1); }
.icon-btn { font: inherit; border: 0; background: none; color: var(--muted); cursor: pointer; padding: 6px; min-width: var(--tap); min-height: var(--tap); border-radius: 8px; }
.icon-btn:hover { background: var(--surface-2); color: var(--error); }

/* 結果 */
.result { margin-top: 16px; background: var(--accent-soft); border-radius: 10px; padding: 14px 16px; }
.result:empty { min-height: 72px; }
.result-main { font-size: 2.2rem; font-weight: 700; line-height: 1.25; font-variant-numeric: tabular-nums; color: var(--text); }
.result-main small { display: inline-block; font-size: 0.95rem; font-weight: 500; color: var(--muted); margin-left: 8px; }
.result dl { display: grid; grid-template-columns: fit-content(60%) minmax(0, 1fr); gap: 4px 14px; margin: 10px 0 0; padding-top: 10px; border-top: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); font-size: 0.95rem; }
.result dt { color: var(--muted); }
.result dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 600; min-width: 0; }
.result dd small { display: block; font-weight: 400; font-size: 0.82rem; color: var(--muted); }
.result .err { color: var(--error); font-weight: 600; font-size: 1rem; }
.result-empty { margin: 0; color: var(--muted); }
.result-actions { display: flex; justify-content: flex-end; margin-top: 10px; }
.copy-btn { font-size: 0.9rem; }

/* 時間計算（行入力） */
.time-rows { display: flex; flex-direction: column; gap: 8px; }
.time-rows:empty { min-height: 96px; }
.time-row { display: grid; grid-template-columns: var(--tap) 1fr 1fr auto; gap: 8px; align-items: center; }
.time-row.with-sec { grid-template-columns: var(--tap) 1fr 1fr 1fr auto; }
.sign-btn { font: inherit; font-size: 1.3rem; font-weight: 700; width: var(--tap); height: var(--tap); border-radius: 8px; border: 1px solid var(--field-line); background: var(--surface-2); color: var(--accent); cursor: pointer; line-height: 1; }
.sign-btn[aria-pressed="true"] { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.sec-field { display: none; }
.with-sec .sec-field { display: flex; }

/* 勤務表 */
.kinmu-table { min-width: 560px; }
.kinmu-table td, .kinmu-table th { padding: 4px 6px; vertical-align: middle; }
.kinmu-table th { white-space: nowrap; }
.kinmu-table input { font-size: 1rem; padding: 4px 8px; text-align: center; }
.kinmu-table td.num { white-space: nowrap; }
.kinmu-table td.no { white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.kinmu-table tfoot td { font-weight: 700; background: var(--surface-2); }
.kinmu-table .brk { width: 72px; }
.badge { display: inline-block; margin-left: 4px; padding: 0 6px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 0.72rem; font-weight: 700; line-height: 1.7; vertical-align: middle; }
.badge[hidden] { display: none; }

/* スマホでは勤務表を1日1枚のカードにする（横スクロールさせない） */
@media (max-width: 600px) {
  .kinmu-table { min-width: 0; }
  .kinmu-table thead { display: none; }
  .kinmu-table, .kinmu-table tbody, .kinmu-table tfoot { display: block; }
  .kinmu-table tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 8px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-bottom: 8px; background: var(--surface); }
  .kinmu-table td { border: 0; padding: 0; background: none; }
  .kinmu-table td[data-label]::before { content: attr(data-label); display: block; font-size: 0.75rem; font-weight: 400; color: var(--muted); }
  .kinmu-table td.no { grid-row: 1; grid-column: 1 / 3; align-self: center; text-align: left; font-weight: 700; }
  .kinmu-table td.no .no-n::before { content: "No."; color: var(--muted); font-weight: 400; margin-right: 2px; }
  .kinmu-table td.del { grid-row: 1; grid-column: 3; justify-self: end; }
  .kinmu-table td.num { text-align: left; }
  .kinmu-table td[data-out]:empty::after { content: "—"; color: var(--muted); }
  .kinmu-table .brk { width: 100%; }
  .kinmu-table tfoot tr { background: var(--surface-2); }
  .kinmu-table tfoot td:first-child { grid-column: 1 / -1; }
  .kinmu-table tfoot td:last-child { display: none; }
  .table-scroll { overflow: visible; }
}

/* 電卓 */
.calc { max-width: 420px; margin: 0 auto; }
.calc-display { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; min-height: 104px; display: flex; flex-direction: column; justify-content: flex-end; text-align: right; font-variant-numeric: tabular-nums; }
.calc-expr { color: var(--muted); font-size: 1rem; min-height: 1.6em; word-break: break-all; }
.calc-main { font-size: 2.2rem; font-weight: 700; line-height: 1.25; word-break: break-all; }
.calc-sub { font-size: 0.9rem; color: var(--muted); min-height: 1.5em; }
.calc-err { color: var(--error); font-size: 0.88rem; min-height: 1.4em; text-align: right; margin-top: 4px; }
.keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 8px; }
.keys button { font: inherit; font-size: 1.3rem; min-height: 56px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; touch-action: manipulation; }
.keys button:active { transform: translateY(1px); }
.keys .k-unit { background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 1.1rem; }
.keys .k-op { background: var(--surface-2); font-weight: 700; }
.keys .k-eq { grid-column: 1 / -1; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.keys .k-clear { color: var(--error); font-weight: 700; }

/* 一覧・FAQ */
.tool-list { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.tool-list li { margin: 0; }
.tool-list a { display: block; height: 100%; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--text); }
.tool-list a:hover { border-color: var(--accent); }
.tool-list strong { display: block; color: var(--accent); }
.tool-list span { display: block; font-size: 0.86rem; color: var(--muted); line-height: 1.6; }
.faq details { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); margin-bottom: 8px; }
.faq summary { cursor: pointer; padding: 10px 14px; font-weight: 600; }
.faq details > div { padding: 0 14px 4px; }
details > summary { cursor: pointer; }
.tool details > summary { display: flex; align-items: center; min-height: var(--tap); color: var(--accent); font-size: 0.95rem; list-style: none; }
.tool details > summary::-webkit-details-marker { display: none; }
.tool details > summary::before { content: "▸"; margin-right: 6px; transition: transform 0.15s; }
.tool details[open] > summary::before { transform: rotate(90deg); }

.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding: 20px 0 28px; font-size: 0.88rem; color: var(--muted); }
.site-footer p { margin: 0 0 6px; }
.site-footer a { color: var(--muted); }
.footer-links { display: flex; flex-wrap: wrap; gap: 0 4px; }
.footer-links a { display: inline-flex; align-items: center; min-height: var(--tap); padding-right: 8px; }
.footer-links a + a::before { content: "・"; margin-right: 8px; color: var(--muted); }

@media (max-width: 480px) {
  h1 { font-size: 1.4rem; }
  .result-main, .calc-main { font-size: 1.9rem; }
  .time-row { gap: 6px; }
}

/* スマホでは「時間計算」の合計を画面下に固定する。入力中は合計の1行だけにする */
@media (max-width: 600px) {
  #sum-tool .result { position: sticky; bottom: 0; z-index: 2; box-shadow: 0 -4px 12px rgb(0 0 0 / 0.15); }
  #sum-tool:focus-within .result dl, #sum-tool:focus-within .result-actions { display: none; }
}

@media print {
  .site-header, .site-nav, .related, .site-footer, .btn-row, .icon-btn, .result-actions, .skip-link, .next-step { display: none !important; }
  body { background: #fff; }
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
kbd { font-family: var(--mono); font-size: 0.85em; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; background: var(--surface); }
