:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --border: #d9dde3;
  --text: #1b1f24;
  --muted: #5b6672;
  --accent: #15607a;
  --accent-weak: #e3eff3;
  --warn: #8a5300;
  --warn-weak: #fdf1dc;
  --danger: #9b2226;
  --danger-weak: #fbe6e6;
  --ok: #1f6b3a;
  --ok-weak: #e4f2e8;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Meiryo UI", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.7;
}

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

header.site {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  /* 右端は切り替えボタンの場所。重ならないよう空けておく */
  padding: 8px 118px 8px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  /* 既定は固定。**本文に使える高さを削りすぎないよう上限を画面の1/5にする** */
  position: sticky; top: 0; z-index: 40;
  max-height: 20vh; overflow-y: auto;
  flex-wrap: wrap;
}
header.site h1 { font-size: 15px; margin: 0; white-space: nowrap; }
header.site h1 a { text-decoration: none; color: inherit; }
header.site .ai-label {
  font-size: 12px;
  color: var(--warn);
  background: var(--warn-weak);
  border: 1px solid #e8d5ae;
  border-radius: 999px;
  padding: 2px 10px;
}
header.site .ai-label.real { color: var(--ok); background: var(--ok-weak); border-color: #bcdcc8; }
header.site nav { margin-left: auto; font-size: 13px; white-space: nowrap; }

main { max-width: 960px; margin: 0 auto; padding: 20px 20px 64px; }
/* 業務フローと内容を見る画面は、横を広く使う */
main.wide { max-width: 1480px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 20px;
}
.panel > h2 { margin: 0 0 4px; font-size: 16px; }
.panel > h2 + .hint { margin-top: 0; }

.hint { color: var(--muted); font-size: 13px; margin: 4px 0 14px; }

/* 段階表示 */
ol.steps { list-style: none; display: flex; gap: 8px; padding: 0; margin: 0 0 20px; flex-wrap: wrap; }
ol.steps li {
  flex: 1 1 180px;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--muted);
}
ol.steps li .no { font-weight: 700; margin-right: 6px; }
ol.steps li .label { margin-right: 6px; }
/* 状態の印。押せる操作ではないので、ボタンらしい見た目にしない */
ol.steps li .state {
  float: right; font-size: 11px; font-weight: 700;
  padding: 1px 7px; border-radius: 9px; border: 1px solid currentColor; opacity: .9;
}
ol.steps li.current { border-color: var(--accent); background: var(--accent-weak); color: var(--text); font-weight: 600; }
ol.steps li.done { color: var(--ok); border-color: #bcdcc8; background: var(--ok-weak); }
ol.steps li.todo { opacity: .55; }

label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 4px; }
input[type="text"], textarea, select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  background: #fff;
  color: var(--text);
}
textarea { resize: vertical; line-height: 1.7; }
.field { margin-bottom: 18px; }

button, .btn {
  font: inherit;
  font-weight: 600;
  padding: 9px 20px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button.secondary, .btn.secondary {
  background: #fff;
  color: var(--accent);
}
button.small, .btn.small { padding: 4px 12px; font-size: 12px; font-weight: 500; }

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f1f3f5;
  color: var(--muted);
  white-space: nowrap;
}
.badge.ai { background: var(--warn-weak); border-color: #e8d5ae; color: var(--warn); }
.badge.ok { background: var(--ok-weak); border-color: #bcdcc8; color: var(--ok); }
.badge.danger { background: var(--danger-weak); border-color: #eec4c4; color: var(--danger); }
.badge.cat { background: var(--accent-weak); border-color: #c3dbe3; color: var(--accent); }

.item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
  background: #fcfdfe;
}
.item h4 { margin: 0 0 6px; font-size: 14px; }
.item .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.item .detail { font-size: 14px; }
.item .evidence { font-size: 12px; color: var(--muted); margin-top: 6px; }
.item .review { margin-top: 10px; border-top: 1px dashed var(--border); padding-top: 10px; }
.item .review label.inline { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.item .review input[type="checkbox"] { width: auto; }
.item.trusted { border-left: 3px solid var(--ok); }
.item.unconfirmed { border-left: 3px solid var(--warn); }

h3.cat { font-size: 14px; margin: 22px 0 8px; padding-bottom: 4px; border-bottom: 1px solid var(--border); }
h3.cat:first-of-type { margin-top: 8px; }

.question {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 12px;
  background: #fcfdfe;
}
.question .q { font-weight: 600; margin: 6px 0; }
.question .why { font-size: 13px; color: var(--muted); margin-bottom: 8px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; }

ul.risks { margin: 0; padding-left: 1.2em; }
ul.risks li { margin-bottom: 4px; }

pre.doc {
  background: #f8f9fa;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 460px;
}

.notice { border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; font-size: 14px; }
.notice.warn { background: var(--warn-weak); border: 1px solid #e8d5ae; color: var(--warn); }
.notice.err { background: var(--danger-weak); border: 1px solid #eec4c4; color: var(--danger); }
.notice.info { background: var(--accent-weak); border: 1px solid #c3dbe3; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.counts { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.count { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 14px; background: #fcfdfe; }
.count .n { font-size: 19px; font-weight: 700; display: block; }
.count .l { font-size: 11px; color: var(--muted); }

footer.site { color: var(--muted); font-size: 12px; text-align: center; padding: 20px; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15181c;
    --panel: #1d2126;
    --border: #333a42;
    --text: #e6e9ec;
    --muted: #99a3ad;
    --accent: #6fc3dd;
    --accent-weak: #1c2f36;
    --warn: #e0b06a;
    --warn-weak: #30271a;
    --danger: #e98b8e;
    --danger-weak: #331e1f;
    --ok: #86cfa0;
    --ok-weak: #1b2a21;
  }
  :root:not([data-theme="light"]) input[type="text"],
  :root:not([data-theme="light"]) textarea,
  :root:not([data-theme="light"]) select { background: #14171a; }
  :root:not([data-theme="light"]) .item,
  :root:not([data-theme="light"]) .question,
  :root:not([data-theme="light"]) .count { background: #191d21; }
  :root:not([data-theme="light"]) pre.doc { background: #14171a; }
  :root:not([data-theme="light"]) .badge { background: #262c33; }
  :root:not([data-theme="light"]) button.secondary,
  :root:not([data-theme="light"]) .btn.secondary { background: #1d2126; }
}

/* 引継ぎ項目の通し番号・項目ラベル（2026-11-28 代表の確認による追加） */
.badge.num { font-weight: 700; letter-spacing: .02em; }
/* 1項目の中の各行。ラベルを左に揃えて、どの行が何かを示す */
.item .field {
  display: grid; grid-template-columns: 7.5em 1fr; gap: 10px;
  align-items: baseline; margin: 6px 0; font-size: 14px; font-weight: normal;
}
.item h4.field { margin: 2px 0 6px; }
.item h4.field .field-value { font-weight: 700; }
.field-label {
  font-size: 11px; font-weight: 700; opacity: .7; letter-spacing: .04em;
  text-align: right; white-space: nowrap;
}
.field-label.edited { color: var(--ok); opacity: 1; }
.field-value { min-width: 0; overflow-wrap: anywhere; }
.field-value .same { font-size: 11px; font-weight: normal; opacity: .6; margin-left: 6px; }
.item .note {
  border-left: 3px solid var(--ok);
  background: var(--ok-weak); border-radius: 0 4px 4px 0; padding: 6px 10px;
}
@media (max-width: 560px) {
  .item .field { grid-template-columns: 1fr; gap: 2px; }
  .field-label { text-align: left; }
}
form.inline { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
form.inline .hint { margin: 0; }

/* 元の業務説明をどこからでも開くボタンとポップアップ */
.src-fab {
  position: fixed; right: 18px; bottom: 18px; z-index: 50;
  padding: 10px 16px; border-radius: 22px; font-size: 13px; font-weight: 700;
  box-shadow: 0 4px 14px rgba(0,0,0,.35); cursor: pointer;
}
.src-dialog {
  width: min(760px, 92vw); max-height: 80vh; border: 1px solid var(--border);
  border-radius: 10px; background: var(--panel); color: var(--text); padding: 0;
}
.src-dialog::backdrop { background: rgba(0,0,0,.55); }
.src-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--panel);
}
.src-head .hint { margin: 0; flex: 1 1 auto; }
.src-body {
  margin: 0; padding: 18px; white-space: pre-wrap; overflow-wrap: anywhere;
  font-size: 14px; line-height: 1.8; max-height: calc(80vh - 60px); overflow: auto;
}
@media (max-width: 560px) { .src-fab { right: 10px; bottom: 10px; padding: 8px 12px; } }

/* 項目の並べ替えと追加（2026-11-29） */
.hidden-form { display: none; }
.meta .move { margin-left: auto; display: inline-flex; gap: 4px; }
.meta .move button { padding: 2px 9px; line-height: 1.4; min-width: 32px; }
.meta .move button[disabled] { opacity: .3; cursor: default; }
.item .meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.add-item .field-grid {
  display: grid; grid-template-columns: 6em 1fr; gap: 10px 12px;
  align-items: start; margin-bottom: 12px;
}
.add-item .field-grid > label { text-align: right; padding-top: 7px; margin: 0; }
@media (max-width: 560px) {
  .add-item .field-grid { grid-template-columns: 1fr; }
  .add-item .field-grid > label { text-align: left; padding-top: 0; }
}

/* 業務フロー（2026-11-29）。
   引継ぎ資料の読み方を示す図であって、Workflowの実行定義ではない。 */

/* 左40% : 右60%。狭い画面では縦に積む */
.split { display: grid; grid-template-columns: 1fr; gap: 20px; align-items: start; }
@media (min-width: 980px) {
  .split { grid-template-columns: 40% 60%; gap: 24px; }
  .split.single { grid-template-columns: 1fr; }
  .split-left { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; }
}
.split-left > .panel, .split-right > .panel { margin-top: 0; }

ol.flow { list-style: none; padding: 0; margin: 0; }
ol.flow > li { display: flex; flex-direction: column; }

/* 工程の箱。大きさ・余白・間隔をそろえる */
.flow-step {
  display: flex; align-items: center; gap: 10px; text-decoration: none;
  border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; min-height: 44px; box-sizing: border-box;
  background: var(--panel); color: var(--text); transition: border-color .12s, background .12s;
}
.flow-step:hover, .flow-step:focus { border-color: var(--accent); background: var(--accent-weak); }
.flow-no {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
  background: var(--accent); color: #fff;
}
/* 名称は最大2行。あふれたら省略する */
.flow-label {
  font-weight: 600; font-size: 14px; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; overflow-wrap: anywhere;
}

/* 工程と工程をつなぐ矢印 */
.flow-arrow {
  align-self: center; color: var(--muted); font-size: 18px; line-height: 1;
  margin: 4px 0; user-select: none;
}

/* 補足情報（判断基準・時期・例外など）はコンパクトに */
ul.flow-branches { list-style: none; margin: 6px 0 0 34px; padding: 0; }
ul.flow-branches > li { position: relative; padding-left: 14px; margin-top: 3px; }
ul.flow-branches > li::before {
  content: ""; position: absolute; left: 0; top: 10px; width: 9px;
  border-top: 1px solid var(--border);
}
.flow-branch {
  display: flex; align-items: center; gap: 6px; text-decoration: none;
  color: var(--text); font-size: 12px; opacity: .9; padding: 1px 0;
}
.flow-branch:hover { text-decoration: underline; opacity: 1; }
.flow-cat {
  flex: none; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 8px;
  border: 1px solid var(--border); opacity: .85; white-space: nowrap;
}
.flow-btext { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.flow-aside-head { font-size: 13px; margin: 18px 0 4px; }
ul.flow-aside-list { list-style: none; padding: 0; margin: 0; }
ul.flow-aside-list > li { margin-top: 3px; }
ul.flow-aside-list a {
  display: flex; align-items: center; gap: 6px; font-size: 12px;
  color: var(--text); text-decoration: none; opacity: .9;
}
ul.flow-aside-list a:hover { text-decoration: underline; }

/* 移動先の項目を目立たせる */
.item:target { outline: 2px solid var(--accent); outline-offset: 3px; }
.item { scroll-margin-top: 16px; }

/* ---------------------------------------- 出力とプレビュー（2026-11-29） */
.tabs { gap: 6px; border-bottom: 1px solid var(--border); padding-bottom: 0; }
.tab {
  display: inline-block; padding: 9px 18px; border: 1px solid var(--border);
  border-bottom: none; border-radius: 8px 8px 0 0; text-decoration: none;
  color: var(--muted); background: transparent; font-size: 14px;
  position: relative; top: 1px;
}
.tab:hover { color: var(--fg); }
.tab.on {
  color: var(--fg); font-weight: 600; background: var(--panel);
  border-color: var(--border); border-bottom: 1px solid var(--panel);
}

.pdf-preview {
  width: 100%; height: 70vh; min-height: 420px; border: 1px solid var(--border);
  border-radius: 8px; background: #fff;
}

/* Excelのプレビュー。表はそのままだと横に伸びるので囲みの中で送る */
.sheet-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
table.sheet { border-collapse: collapse; width: 100%; font-size: 13px; }
table.sheet th, table.sheet td {
  border: 1px solid var(--border); padding: 6px 10px; text-align: left;
  vertical-align: top; white-space: pre-wrap;
}
table.sheet th { background: var(--panel2, rgba(127,127,127,.12)); font-weight: 600; }
table.sheet td:first-child, table.sheet th:first-child { width: 48px; }

/* PowerPointのプレビュー。1枚を1枠として並べる */
.slides { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .slides { grid-template-columns: 1fr 1fr; } }
.slide {
  border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px;
  position: relative; background: var(--panel);
}
.slide-no {
  position: absolute; top: 10px; right: 12px; font-size: 12px; color: var(--muted);
}
.slide h3 { margin: 0 0 8px; font-size: 15px; padding-right: 28px; }
.slide ul { margin: 0; padding-left: 20px; }
.slide li { font-size: 13px; line-height: 1.7; }

/* ------------------------------- ヘッダーの固定／非表示（2026-11-29） */
/* 「隠す」を選んだときは表題の行ごと畳む。切り替えのボタンだけ残す */
html[data-header="hidden"] header.site { display: none; }

.hdr-toggle {
  position: fixed; top: 6px; right: 10px; z-index: 50;
  padding: 3px 10px; font-size: 11px; font-weight: 500;
  border-radius: 999px; border: 1px solid var(--border);
  background: var(--panel); color: var(--muted); cursor: pointer;
  opacity: .65;
}
.hdr-toggle:hover { opacity: 1; color: var(--fg); }

/* ヘッダーの中に入れる進捗。**表題の行をそのまま使う** */
ol.steps.compact {
  margin: 0; gap: 6px; flex: 1 1 auto; min-width: 0;
  justify-content: flex-start;
}
ol.steps.compact li {
  flex: 0 1 auto; padding: 3px 10px; font-size: 11px; line-height: 1.5;
  display: flex; align-items: center; gap: 6px; white-space: nowrap;
  min-width: 0; overflow: hidden; text-overflow: ellipsis;
}
ol.steps.compact li .no { margin-right: 0; font-size: 11px; }
ol.steps.compact li .label { margin-right: 0; overflow: hidden; text-overflow: ellipsis; }
ol.steps.compact li .state { float: none; font-size: 10px; padding: 0 6px; }
/* 狭い画面では段階名を省いて STEP番号と状態だけにする */
@media (max-width: 760px) {
  ol.steps.compact li .label { display: none; }
  header.site h1 { font-size: 13px; }
}

/* -------------------------- ボタンの説明（ポインタを当てると出る） */
/* 何のためのボタンかが分からない、という指摘への対応。
   ブラウザ標準の title は出るまで時間がかかるので、自前で出す。 */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute; left: 0; top: calc(100% + 8px); z-index: 60;
  width: max-content; max-width: 320px;
  padding: 8px 11px; border-radius: 8px;
  background: var(--panel); color: var(--fg);
  border: 1px solid var(--border);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
  font-size: 12px; font-weight: 400; line-height: 1.6; text-align: left;
  white-space: normal; pointer-events: none;
  opacity: 0; visibility: hidden; transition: opacity .12s ease .25s, visibility 0s linear .37s;
}
[data-tip]:hover::after, [data-tip]:focus-visible::after {
  opacity: 1; visibility: visible; transition-delay: .25s, 0s;
}
/* 右端のボタンは吹き出しが画面からはみ出すので、右そろえにする */
.row > [data-tip]:last-child::after { left: auto; right: 0; }

/* ------------------------------- 操作バー（代表の要望 2026-11-29） */
/* 操作は画面の上にまとめる。下まで送らないと押せない状態をなくす。
   ヘッダーと**ひとまとまりで**貼り付けるので、ヘッダーを隠してもずれない。 */
.topstack {
  position: sticky; top: 0; z-index: 40;
  background: var(--bg);
  /* **ここで切り取らない。** 切り取るとドロップダウンが隠れる。
     高さは中のヘッダー側で抑える */
  overflow: visible;
}
/* 表題と進捗の行。**本文の高さを削りすぎないよう上限を設ける** */
header.site { position: static; max-height: 14vh; overflow-y: auto; }

.actionbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 8px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.actionbar .btn, .actionbar button, .actionbar summary {
  font-size: 13px; padding: 7px 14px; margin: 0;
}
.actionbar form.inline { display: inline; margin: 0; }
.actionbar .bar-label { font-size: 12px; color: var(--muted); margin-right: 2px; }
.actionbar .bar-sep {
  width: 1px; align-self: stretch; background: var(--border); margin: 0 4px;
}
.actionbar .tabs { border: none; padding: 0; gap: 4px; display: flex; }
.actionbar .tab {
  border-radius: 7px; border: 1px solid var(--border); top: 0;
  padding: 6px 13px; font-size: 13px;
}
.actionbar .tab.on {
  border-color: var(--accent); background: var(--accent-weak);
  color: var(--text); font-weight: 600;
}

/* まとめて置くとバーが長くなるものは、ドロップダウンに畳む */
details.menu { position: relative; }
details.menu > summary { list-style: none; cursor: pointer; display: inline-block; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu > .menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 70;
  width: min(340px, calc(100vw - 24px)); padding: 6px; box-sizing: border-box;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
}
details.menu > .menu-list a {
  display: block; padding: 8px 10px; border-radius: 7px; text-decoration: none;
  color: var(--fg);
}
details.menu > .menu-list a:hover { background: var(--accent-weak); }
details.menu > .menu-list a strong { display: block; font-size: 13px; }
details.menu > .menu-list a span {
  display: block; font-size: 12px; color: var(--muted); line-height: 1.6; margin-top: 2px;
}

/* 操作バーの中では、吹き出しが上に隠れないよう下に出す */
.actionbar [data-tip]::after { top: calc(100% + 6px); }
.actionbar > :last-child[data-tip]::after,
.actionbar details.menu [data-tip]::after { left: auto; right: 0; }

@media (max-width: 760px) {
  /* 狭い画面で操作バーが画面を埋めてしまうのを避ける */
  .topstack { position: static; max-height: none; }
}

/* 引継ぎの予定（日付の入力） */
input[type="date"].date { width: auto; min-width: 170px; }
.inline-label { display: inline-block; margin: 0 2px 0 0; font-size: 13px; }

/* 一括確認（STEP2）。原文に根拠のある項目だけが対象 */
.bulkbar { margin: 10px 0 14px; padding: 10px 12px; border: 1px solid var(--line, #d9dee3); border-radius: 8px; background: var(--accent-weak, #eef6f8); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.bulkbar #bulk-count { font-weight: 600; }
h3.cat .bulk-cat { margin-left: 10px; font-weight: 400; vertical-align: middle; }

.nowrap { white-space: nowrap; }
