:root {
  --primary: #1c3553;
  --accent: #0e6b63;
  --emergency: #b3261e;
  --emergency-bg: #fdf1f0;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --ink: #14181f;
  --ink-2: #3d4553;
  --muted: #5d6675;
  --line: #d9dde3;
  --soft: #e9eef4;
  --ok: #1d6b3a;
  --warn: #8a5a00;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", "Meiryo", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 17px; line-height: 1.75; letter-spacing: .01em;
}
a { color: var(--primary); text-underline-offset: 3px; }
h1, h2, h3 { line-height: 1.4; margin: 0 0 .5em; letter-spacing: .02em; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
img { max-width: 100%; }
svg { width: 1.2em; height: 1.2em; flex: 0 0 auto; vertical-align: -0.2em; }
.call119 svg { width: 28px; height: 28px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid #f0b429; outline-offset: 2px; }

.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: #fff; padding: 8px 12px; z-index: 99; }
.loading, .empty { color: var(--muted); padding: 24px 16px; text-align: center; }

/* ── 枠組み ── */
.topbar {
  background: var(--primary); color: #fff; padding: 10px 16px;
  display: flex; align-items: center; gap: 12px;
}
.topbar a { color: #fff; text-decoration: none; }
.topbar .brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar .brand img { height: 30px; }
.topbar .brand small { display: block; font-size: .72rem; opacity: .82; line-height: 1.3; }
.topbar .brand strong { display: block; font-size: 1.02rem; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .right { margin-left: auto; font-size: .85rem; white-space: nowrap; }
.topbar .right button { background: none; border: 1px solid rgba(255,255,255,.5); color: #fff; border-radius: 8px; padding: 4px 10px; cursor: pointer; }

.ebar {
  position: sticky; top: 0; z-index: 20; display: flex; gap: 8px; padding: 8px 16px;
  background: var(--emergency); color: #fff;
}
.ebar a { color: #fff; text-decoration: none; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 6px; border-radius: 8px; min-height: 44px; }
.ebar .call { flex: 0 0 auto; background: #fff; color: var(--emergency); padding: 0 16px; font-size: 1.05rem; }
.ebar .info { flex: 1; border: 2px solid rgba(255,255,255,.7); }

main { max-width: 760px; margin: 0 auto; padding: 16px 16px 110px; }
.wide main, main.wide { max-width: 1080px; }
footer.foot { max-width: 760px; margin: 0 auto; padding: 0 16px 120px; color: var(--muted); font-size: .8rem; }

.bnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface);
  border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(6, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
}
.bnav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 9px; font-size: .74rem; color: var(--ink-2); text-decoration: none; min-height: 56px; }
.bnav a svg { width: 24px; height: 24px; }
.bnav a[aria-current="page"] { color: var(--primary); font-weight: 700; box-shadow: inset 0 3px 0 var(--primary); }
.bnav a.em { color: var(--emergency); }

/* ── 部品 ── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card > :last-child { margin-bottom: 0; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 22px 0 10px; }
.section-title h2 { margin: 0; }
.section-title a { font-size: .9rem; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.pill { display: inline-block; font-size: .78rem; padding: 1px 10px; border-radius: 999px; background: var(--soft); color: var(--ink-2); font-weight: 600; white-space: nowrap; }
.pill.red { background: var(--emergency-bg); color: var(--emergency); }
.pill.green { background: #e7f4ec; color: var(--ok); }
.pill.yellow { background: #fbf1dc; color: var(--warn); }
.pill.blue { background: #e6eef8; color: var(--primary); }
.note { background: #fbf6e8; border: 1px solid #ecdcae; border-radius: 10px; padding: 10px 12px; font-size: .9rem; color: #5b4300; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px;
  padding: 0 18px; border-radius: 10px; border: 1px solid var(--primary); background: var(--primary); color: #fff;
  font-weight: 700; text-decoration: none; cursor: pointer;
}
.btn.ghost { background: var(--surface); color: var(--primary); }
.btn.block { display: flex; width: 100%; }
.btn.small { min-height: 38px; padding: 0 12px; font-size: .9rem; }
.btn:disabled { opacity: .55; cursor: wait; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* 緊急時ボックス */
.emergency { border: 2px solid var(--emergency); border-radius: var(--radius); background: var(--surface); overflow: hidden; margin-bottom: 18px; }
.emergency > h2 { background: var(--emergency); color: #fff; margin: 0; padding: 10px 16px; font-size: 1.1rem; }
.emergency .inner { padding: 14px 16px; }
.call119 { display: flex; align-items: center; justify-content: center; gap: 10px; background: var(--emergency); color: #fff; text-decoration: none; font-size: 1.3rem; font-weight: 800; border-radius: 12px; min-height: 64px; margin-bottom: 14px; }
.em-block { border-top: 1px solid var(--line); padding: 12px 0; }
.em-block:first-of-type { border-top: 0; padding-top: 0; }
.em-block h3 { font-size: .95rem; color: var(--emergency); margin-bottom: 6px; }
.contact { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.contact + .contact { border-top: 1px dashed var(--line); }
.contact .who { flex: 1; min-width: 0; }
.contact .who strong { display: block; }
.contact .who span { font-size: .85rem; color: var(--muted); }
.tel { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; min-height: 46px; padding: 0 14px; border-radius: 10px; background: var(--emergency-bg); color: var(--emergency); border: 1px solid #f0c6c2; font-weight: 800; text-decoration: none; }
.unset { color: var(--muted); font-size: .85rem; }
ol.flow { list-style: none; padding: 0; margin: 0; counter-reset: f; }
ol.flow li { counter-increment: f; position: relative; padding: 8px 0 8px 40px; }
ol.flow li + li { border-top: 1px dashed var(--line); }
ol.flow li::before { content: counter(f); position: absolute; left: 0; top: 10px; width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: #fff; font-size: .85rem; font-weight: 700; display: grid; place-items: center; }
ol.flow strong { display: block; }
ol.flow span { font-size: .88rem; color: var(--ink-2); }

.mayottara { background: #fff8e6; border: 2px solid #e5b300; border-radius: var(--radius); padding: 14px 16px; margin-bottom: 18px; }
.mayottara h2 { font-size: 1.05rem; color: #5b4300; display: flex; gap: 8px; align-items: center; }
.mayottara ul { margin: 0; padding-left: 1.1em; }
.mayottara li { margin: 6px 0; }
.mayottara li b { color: var(--emergency); }

/* メニュー */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tile { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; min-height: 64px; text-decoration: none; color: var(--ink); font-weight: 700; box-shadow: var(--shadow); }
.tile svg { width: 26px; height: 26px; color: var(--accent); flex: 0 0 auto; }
.tile small { display: block; font-weight: 400; font-size: .78rem; color: var(--muted); }
.tile.staff svg { color: var(--primary); }

.list { list-style: none; padding: 0; margin: 0; }
.list > li > a, .list > li > .row { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; text-decoration: none; color: var(--ink); box-shadow: var(--shadow); }
.list .meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .82rem; color: var(--muted); margin-bottom: 2px; }
.list strong { display: block; }

.points { background: #eaf5f3; border-left: 5px solid var(--accent); border-radius: 8px; padding: 12px 14px; margin: 14px 0; }
.points h3 { color: var(--accent); font-size: 1rem; }
.points ul { margin: 0; padding-left: 1.1em; }
.prose p { white-space: pre-wrap; }
.refs { font-size: .85rem; color: var(--ink-2); border-top: 1px solid var(--line); margin-top: 16px; padding-top: 10px; }
.refs ul { padding-left: 1.1em; margin: 4px 0 0; }

.frame { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #111; border-radius: 10px; overflow: hidden; margin: 10px 0; }
.frame.slides { aspect-ratio: 16 / 9.6; }
.frame.map { aspect-ratio: 4 / 3; background: var(--soft); }
.frame.note { aspect-ratio: auto; height: 300px; max-width: 520px; background: transparent; }
.tel-btn { background: var(--emergency); border-color: var(--emergency); font-size: 1.05rem; }
.frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.quiz fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin: 0 0 12px; }
.quiz legend { font-weight: 700; padding: 0 4px; }
.quiz label { display: flex; gap: 10px; align-items: center; padding: 8px 0; min-height: 44px; }
.quiz input { width: 22px; height: 22px; }
.quiz .result { margin-top: 6px; font-size: .92rem; }

/* フォーム */
.form label { display: block; font-weight: 700; font-size: .92rem; margin: 12px 0 4px; }
.form input, .form select, .form textarea { width: 100%; border: 1px solid #b9c0ca; border-radius: 8px; padding: 10px 12px; background: #fff; min-height: 46px; }
.form textarea { min-height: 110px; }
.form .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.form .help { font-weight: 400; color: var(--muted); font-size: .8rem; }
.form .quiz-c, .quiz label input[type=radio] { width: 22px; height: 22px; min-height: 0; flex: 0 0 auto; margin: 0; padding: 0; }
.form.quiz label { display: flex; gap: 12px; align-items: center; padding: 8px 0; min-height: 44px; font-weight: 400; font-size: 1rem; margin: 0; }
[hidden] { display: none !important; }
.msg { margin-top: 10px; font-size: .92rem; }
.msg.err { color: var(--emergency); }
.msg.ok { color: var(--ok); }

/* タブ */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin: 0 -16px 16px; padding: 0 16px; scrollbar-width: none; }
.tabs a { flex: 0 0 auto; padding: 10px 12px; text-decoration: none; color: var(--ink-2); font-size: .92rem; border-bottom: 3px solid transparent; }
.tabs a[aria-current="page"] { color: var(--primary); border-bottom-color: var(--primary); font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chips button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 14px; cursor: pointer; font-size: .88rem; min-height: 38px; }
.chips button[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }

/* 記録 */
dl.fields { display: grid; grid-template-columns: 7.5em 1fr; gap: 6px 12px; margin: 0; }
dl.fields dt { color: var(--muted); font-size: .88rem; padding-top: 2px; }
dl.fields dd { margin: 0; white-space: pre-wrap; }
.question { background: #fff8e6; border: 1px solid #ecd28c; border-radius: 10px; padding: 10px 12px; margin-top: 12px; }
.comment { border-left: 4px solid var(--accent); background: #f3f8f7; border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
.comment .by { font-size: .8rem; color: var(--muted); }
.comment p { white-space: pre-wrap; margin: 4px 0; }

/* 数字と図 */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.stat b { display: block; font-size: 1.6rem; line-height: 1.2; color: var(--ink); font-variant-numeric: tabular-nums; }
.stat span { font-size: .78rem; color: var(--muted); }
.hbars { display: grid; gap: 6px; }
.hbar { display: grid; grid-template-columns: 6.5em 1fr 2.6em; align-items: center; gap: 8px; font-size: .88rem; padding: 2px 4px; border-radius: 6px; }
.hbar:hover { background: var(--soft); }
.hbar .lab { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.hbar .track { height: 16px; }
.hbar .fill { display: block; height: 100%; background: var(--primary); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }
.vbars { display: flex; align-items: flex-end; gap: 4px; height: 160px; border-bottom: 1px solid #aab2bd; padding-top: 18px; }
.vbar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; position: relative; }
.vbar .fill { width: 70%; max-width: 34px; background: var(--primary); border-radius: 4px 4px 0 0; min-height: 1px; }
.vbar .v { font-size: .72rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.vbar:hover .fill { background: var(--accent); }
.vlabels { display: flex; gap: 4px; }
.vlabels span { flex: 1; text-align: center; font-size: .72rem; color: var(--muted); }
details.table { margin-top: 10px; font-size: .88rem; }
details.table summary { cursor: pointer; color: var(--primary); }
table.t { width: 100%; border-collapse: collapse; font-size: .88rem; margin-top: 6px; }
table.t th, table.t td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
table.t th { background: var(--soft); font-weight: 700; }
table.t td.n { text-align: right; font-variant-numeric: tabular-nums; }
.scroll-x { overflow-x: auto; }
.multiples { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }

/* 管理 */
.alerts .alert { border-left: 5px solid #e5b300; background: #fff8e6; border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.teamcard { display: grid; gap: 6px; }
.teamcard .links { display: flex; flex-wrap: wrap; gap: 8px; }
.timeline { position: relative; height: 34px; background: var(--soft); border-radius: 6px; margin: 6px 0 2px; }
.timeline .span { position: absolute; top: 6px; bottom: 6px; background: #b8c7da; border-radius: 4px; }
.timeline .mark { position: absolute; top: 0; bottom: 0; width: 3px; background: var(--emergency); }
.timeline .today { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink); }
.months { display: grid; grid-template-columns: repeat(12, 1fr); font-size: .68rem; color: var(--muted); text-align: center; }

@media (min-width: 720px) {
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .bnav { max-width: 760px; margin: 0 auto; border: 1px solid var(--line); border-bottom: 0; border-radius: 14px 14px 0 0; }
}
@media (max-width: 380px) {
  body { font-size: 16px; }
  .form .grid2 { grid-template-columns: 1fr; }
  dl.fields { grid-template-columns: 1fr; }
  dl.fields dt { padding-top: 6px; }
}

/* ── 印刷（PDFとして保存） ── */
.report { background: #fff; }
.report .sheet { background: #fff; padding: 8mm 4mm; }
.report h1 { font-size: 1.3rem; border-bottom: 2px solid var(--primary); padding-bottom: 6px; }
.print-only { display: none; }
@media print {
  @page { size: A4; margin: 14mm 12mm; }
  body { background: #fff; font-size: 11pt; }
  .topbar, .ebar, .bnav, .tabs, .no-print, footer.foot { display: none !important; }
  main { max-width: none; padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
  .print-only { display: block; }
  details.table { display: block; }
  details.table > summary { display: none; }
  .hbar .fill, .vbar .fill { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .page-break { break-before: page; }
}
