/* 作業カード（A案）: ロゴの青・大きな番号・「できた」で左の線が青くなる */
:root {
  --blue: #0858a8;
  --blue-press: #064785;
  --blue-glow: #1677d2;
  --on-blue: #ffffff;
  --ink: #13233b;
  --sub: #4b5a72;
  --rail: #cdd7e6;
  --wash: #eef3fa;
  --paper: #ffffff;
  --bar: #0858a8;
  --on-bar: #ffffff;
  --warn-bg: #fff4dc;
  --warn-ink: #6b4500;
  --danger: #b3261e;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --font: "BIZ UDPGothic", "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --blue: #6ea8ec;
    --blue-press: #8dbbf0;
    --blue-glow: #9fd8ff;
    --on-blue: #0b1a2e;
    --ink: #e8eef8;
    --sub: #a9b6ca;
    --rail: #2b3a52;
    --wash: #172234;
    --paper: #0f1724;
    --bar: #12325c;
    --on-bar: #e8eef8;
    --warn-bg: #3a2c0c;
    --warn-ink: #f3d692;
    --danger: #ff8a80;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.75;
  overflow-wrap: anywhere;
}
a { color: var(--blue); }
button, a { touch-action: manipulation; }
button { font: inherit; color: inherit; }
button, .bar a, .toc-item { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#app {
  max-width: 640px; margin: 0 auto; padding: 0 16px calc(48px + env(safe-area-inset-bottom, 0px));
  overflow-x: clip; /* 右から出てくる前の項目で、ページが横にずれないように（clip なので上のバーの固定は効いたまま） */
}

/* ---- 上のバー ---- */
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  margin: 0 -16px; padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: var(--bar); color: var(--on-bar);
  font-size: 15px;
}
.bar a, .bar button, .bar-title { color: var(--on-bar); text-decoration: none; }
.bar-back, .bar-lock { display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; }
.bar-title { font-weight: 700; }
.bar-progress { margin-left: auto; font-variant-numeric: tabular-nums; }
.bar-lock { margin-left: auto; background: none; border: 0; cursor: pointer; }
.bar-progress + .bar-lock { margin-left: 4px; }

/* ---- パスワード: 壁紙（光るBR）の上に入力欄。明るい設定でも暗い設定でも同じ夜の色 ---- */
#app.login {
  position: relative; isolation: isolate;
  max-width: none; margin: 0;
  min-height: 100svh; display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
  padding: env(safe-area-inset-top, 0px) 16px max(40px, calc(24px + env(safe-area-inset-bottom, 0px)));
  background: #020b1e;
  color: #e9f4ff;
}
/* 壁紙は別の層にして、開いたときにBRの光をふわっと灯す（夜の色は先に出ている） */
#app.login::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: url("/img/login-bg.jpg") center 32% / cover no-repeat;
  animation: login-glow 700ms var(--ease-out) both;
}
.login-card { animation: login-card 420ms var(--ease-out) 260ms both; }
@keyframes login-glow { from { opacity: 0; transform: scale(1.06); } }
@keyframes login-card { from { opacity: 0; transform: translateY(32px); } }
/* 縦長のスマホ: BRが切れないよう壁紙を上に置き、下の夜の色へなじませる */
@media (orientation: portrait) {
  #app.login::before {
    background:
      linear-gradient(to bottom, rgba(2, 11, 30, 0) 0, rgba(2, 11, 30, 0) min(33vh, 72vw), #020b1e min(46vh, 100vw)),
      url("/img/login-bg.jpg") center top / auto min(46vh, 100vw) no-repeat,
      #020b1e;
  }
}
.login-card {
  width: 100%; max-width: 380px; padding: 20px 18px 18px;
  background: rgba(2, 11, 30, 0.72); border: 1px solid rgba(110, 190, 255, 0.28); border-radius: 14px;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.login-title { font-size: 24px; line-height: 1.3; margin: 0 0 2px; color: #ffffff; }
.login-lead { color: #a9c7e6; margin: 0 0 16px; }
.login .field input { background: #ffffff; color: #13233b; border-color: transparent; }
.login .field input:focus { border-color: #38b6ff; }
.login .login-error { color: #ffb4ab; }
.login .btn-primary { background: #38b6ff; color: #031226; }
.login .btn-primary:active { background: #6ccaff; }
.login :focus-visible { outline-color: #6ccaff; }
@media (hover: hover) and (pointer: fine) { .login .btn-primary:hover { background: #6ccaff; } }

/* 上のバーのBR */
.bar-mark { display: block; height: 20px; width: auto; flex-shrink: 0; }
.field input {
  width: 100%; min-height: 52px; padding: 0 14px;
  font: inherit; font-size: 18px; color: var(--ink);
  background: var(--paper); border: 2px solid var(--rail); border-radius: 10px;
}
.field input:focus { outline: none; border-color: var(--blue); }
.login-error { min-height: 1.75em; margin: 8px 0; color: var(--danger); font-size: 15px; }
.btn-primary {
  width: 100%; min-height: 52px; border: 0; border-radius: 10px;
  background: var(--blue); color: var(--on-blue); font-size: 18px; font-weight: 700; cursor: pointer;
  transition: transform 120ms var(--ease-out), background-color 120ms;
}
.btn-primary:active { transform: scale(0.97); background: var(--blue-press); }
.btn-primary[disabled] { opacity: 0.7; }

/* ---- 目次 ---- */
.toc-title { font-size: 26px; line-height: 1.3; margin: 24px 0 12px; }
.toc-list { list-style: none; margin: 0; padding: 0; }
/* 目次の項目: ロゴの壁紙と同じ夜の黒から青へのグラデーション。左の線と右上の斜めの光は、BRの光の水色 */
.toc-item {
  position: relative; overflow: hidden;
  display: block; padding: 16px 16px 16px 18px; margin-bottom: 10px;
  border-left: 4px solid #38b6ff; border-radius: 0 12px 12px 0;
  background:
    linear-gradient(118deg, transparent 0 78%, rgba(56, 182, 255, 0.35) 78% 78.6%, transparent 78.6% 84%, rgba(56, 182, 255, 0.18) 84% 84.4%, transparent 84.4%),
    linear-gradient(115deg, #020b1e 0%, #04193f 45%, #0a3f94 100%);
  color: #e9f4ff; text-decoration: none;
  transition: transform 160ms var(--ease-out), box-shadow 200ms ease;
}
.toc-item:active { transform: scale(0.98); }
.toc-name {
  display: block; font-size: 19px; font-weight: 700; color: #ffffff;
  background: linear-gradient(90deg, #ffffff 0%, #bfe6ff 55%, #6ccaff 100%); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
@media (forced-colors: active) { .toc-name { -webkit-text-fill-color: currentColor; background: none; } }
/* 目次の一覧: そのタブで最初に開いたときだけ、上から順に左から出す */
/* 目次の一覧: カードは左右から交互に滑り込み、業務名と説明は少し遅れて追いかける */
.toc-item.is-enter { animation: toc-in 560ms var(--ease-out) both; animation-delay: calc(var(--i, 0) * 70ms); }
.toc-list > li:nth-child(even) .toc-item.is-enter { animation-name: toc-in-r; }
.toc-item.is-enter .toc-name { animation: rv-left 520ms var(--ease-out) calc(var(--i, 0) * 70ms + 140ms) both; }
.toc-item.is-enter .toc-sum, .toc-item.is-enter .toc-more { animation: rv-up 480ms var(--ease-out) calc(var(--i, 0) * 70ms + 240ms) both; }
@keyframes toc-in { from { opacity: 0; transform: translateX(-56px) scale(0.97); } }
@keyframes toc-in-r { from { opacity: 0; transform: translateX(56px) scale(0.97); } }
.toc-title.is-enter { animation: rv-down 520ms var(--ease-out) both; }
@keyframes rv-down { from { opacity: 0; transform: translateY(-16px); } }
.toc-sum { display: block; font-size: 15px; color: #b9d3ee; line-height: 1.6; }
/* まとめの行: 「4つから選ぶ」を業務名の下に小さく。左の線は2本にして、中にまだ一覧があることを示す */
.toc-item.is-group { border-left-style: double; border-left-width: 7px; }
.toc-more { display: inline-block; margin: 2px 0 2px; font-size: 13px; font-weight: 700; color: #6ccaff; }
.toc-lead { margin: -4px 0 16px; color: var(--sub); }

/* ---- マニュアル ---- */
.m-title { font-size: 26px; line-height: 1.35; margin: 24px 0 8px; }
.m-sec { margin: 28px 0; }
.m-sec > h2 { font-size: 15px; font-weight: 700; color: var(--sub); margin: 0 0 8px; }
.m-what p { margin: 0; font-size: 18px; }
.m-when dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; }
.m-when dl > div { display: contents; }
.m-when dt { color: var(--sub); }
.m-when dd { margin: 0; font-weight: 700; }
.list { margin: 0; padding-left: 1.2em; }
.list li + li { margin-top: 4px; }
.m-miss { background: var(--warn-bg); color: var(--warn-ink); padding: 14px 16px; border-radius: 10px; }
.m-miss > h2 { color: var(--warn-ink); }
.m-contact p { margin: 0; }

/* 作業の流れ（区切りの一覧）: 今やっている区切りだけ青い線、終わった区切りは薄く */
.flow { list-style: none; margin: 0 0 20px; padding: 0; counter-reset: none; }
.flow-item {
  display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; column-gap: 10px;
  min-height: 48px; padding: 6px 12px 6px 10px; margin-bottom: 2px;
  border-left: 4px solid var(--rail); color: var(--ink); text-decoration: none;
  transition: border-color 160ms var(--ease-out), background-color 160ms;
}
.flow-no {
  display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 3px; border-radius: 13px;
  align-self: start; margin-top: 2px; /* 名前が2行になっても1行目にそろえる */
  border: 2px solid var(--rail); color: var(--sub); font-size: 14px; font-weight: 700; line-height: 1;
}
.flow-name { font-weight: 700; line-height: 1.4; }
.flow-range { display: block; font-size: 13px; font-weight: 400; color: var(--sub); }
.flow-item .phase-count { font-size: 14px; color: var(--sub); font-variant-numeric: tabular-nums; white-space: nowrap; }
.flow-item.is-now { border-left-color: var(--blue); background: var(--wash); }
.flow-item.is-now .flow-no { border-color: var(--blue); background: var(--blue); color: var(--on-blue); }
.flow-item.is-finished .flow-name { color: var(--sub); }
.flow-item.is-finished .flow-no { border-color: var(--blue); color: var(--blue); }
.flow-item.is-finished .flow-no { font-size: 0; }
.flow-item.is-finished .flow-no::after { content: "✓"; font-size: 14px; }
.flow-item:active { background: var(--wash); }

/* 区切りの見出し（手順の間に入る） */
.phase {
  position: relative;
  display: flex; align-items: baseline; gap: 12px;
  margin: 28px 0 10px; padding: 10px 0 10px;
  scroll-margin-top: calc(72px + env(safe-area-inset-top, 0px));
}
/* 見出しの下の線（出てくるときに左から伸ばすので、枠線ではなく別の層にする） */
.phase::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: var(--blue); transform-origin: left center;
}
.phase.is-finished::after { background: var(--rail); }
.phase:first-of-type { margin-top: 8px; }
.phase-title { flex: 1; min-width: 0; margin: 0; font-size: 20px; line-height: 1.4; color: var(--blue); }
.phase-no {
  display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 3px; margin-right: 10px; border-radius: 13px;
  background: var(--blue); color: var(--on-blue); font-size: 14px; line-height: 1; vertical-align: 2px;
}
.phase.is-finished .phase-no { background: var(--sub); }
.phase > .phase-count { font-size: 14px; color: var(--sub); font-variant-numeric: tabular-nums; white-space: nowrap; }
.phase.is-finished .phase-title { color: var(--sub); }
.step { scroll-margin-top: calc(64px + env(safe-area-inset-top, 0px)); }

.steps { list-style: none; margin: 0; padding: 0; }
.step {
  display: grid; grid-template-columns: minmax(44px, auto) minmax(0, 1fr); column-gap: 12px;
  padding: 12px 0 16px 12px; margin-bottom: 8px;
  border-left: 4px solid var(--rail);
  transition: border-color 200ms ease;
}
/* ---- スクロールで出てくる動き（1回だけ）。data-rv で向きを変える ----
   up … 下から / left … 左から / right … 右から / pop … 少し小さいところから
   step … 手順の中身を順に: 番号は左から弾んで、題は右から、写真は左から右へ開き、本文とボタンは下から
   phase … 区切りの見出しは左から、下の線が左から伸びる */
.reveal[data-rv="up"], .reveal[data-rv="left"], .reveal[data-rv="right"], .reveal[data-rv="pop"] { opacity: 0; }
.reveal[data-rv="up"] { transform: translateY(32px); }
.reveal[data-rv="left"] { transform: translateX(-48px); }
.reveal[data-rv="right"] { transform: translateX(48px); }
.reveal[data-rv="pop"] { transform: scale(0.92); }
.reveal.is-in[data-rv] { opacity: 1; transform: none; }
.reveal.is-in[data-rv="up"], .reveal.is-in[data-rv="left"], .reveal.is-in[data-rv="right"], .reveal.is-in[data-rv="pop"] {
  transition: opacity 520ms var(--ease-out) var(--d, 0ms), transform 520ms var(--ease-out) var(--d, 0ms), border-color 160ms ease, background-color 160ms ease;
}

.reveal[data-rv="step"] .step-no,
.reveal[data-rv="step"] .step-title,
.reveal[data-rv="step"] .photo,
.reveal[data-rv="step"] .step-body,
.reveal[data-rv="step"] .done-btn { opacity: 0; }
.reveal.is-in[data-rv="step"] .step-no { opacity: 1; animation: rv-num 560ms var(--ease-out) var(--d, 0ms) both; }
.reveal.is-in[data-rv="step"] .step-title { opacity: 1; animation: rv-right 520ms var(--ease-out) calc(var(--d, 0ms) + 90ms) both; }
.reveal.is-in[data-rv="step"] .photo { opacity: 1; animation: rv-wipe 640ms var(--ease-in-out) calc(var(--d, 0ms) + 180ms) both; }
.reveal.is-in[data-rv="step"] .step-body { opacity: 1; animation: rv-up 480ms var(--ease-out) calc(var(--d, 0ms) + 260ms) both; }
.reveal.is-in[data-rv="step"] .done-btn { opacity: 1; animation: rv-up 480ms var(--ease-out) calc(var(--d, 0ms) + 340ms) both; }

.reveal[data-rv="phase"] .phase-title, .reveal[data-rv="phase"] .phase-count { opacity: 0; }
.reveal[data-rv="phase"]::after { transform: scaleX(0); }
.reveal.is-in[data-rv="phase"] .phase-title { opacity: 1; animation: rv-left 520ms var(--ease-out) var(--d, 0ms) both; }
.reveal.is-in[data-rv="phase"] .phase-count { opacity: 1; animation: rv-right 520ms var(--ease-out) calc(var(--d, 0ms) + 120ms) both; }
.reveal.is-in[data-rv="phase"]::after { transform: none; transition: transform 700ms var(--ease-in-out) calc(var(--d, 0ms) + 80ms), background-color 160ms ease; }

@keyframes rv-num { from { opacity: 0; transform: translateX(-24px) scale(0.6); } 60% { opacity: 1; transform: translateX(2px) scale(1.06); } }
@keyframes rv-left { from { opacity: 0; transform: translateX(-40px); } }
@keyframes rv-right { from { opacity: 0; transform: translateX(40px); } }
@keyframes rv-up { from { opacity: 0; transform: translateY(20px); } }
@keyframes rv-wipe { from { opacity: 0.4; clip-path: inset(0 100% 0 0 round 8px); } to { clip-path: inset(0 0 0 0 round 8px); } }
.step-no {
  grid-row: 1 / span 3; white-space: nowrap; /* 2けたの番号を2行に割らない */
  font-size: 34px; font-weight: 700; line-height: 1; color: var(--blue);
  font-variant-numeric: tabular-nums;
}
.step-title { font-size: 19px; line-height: 1.45; margin: 2px 0 10px; }
.step-body > :first-child { margin-top: 0; }
.step-body > :last-child { margin-bottom: 0; }
.step-body code { font-size: 0.92em; background: var(--wash); padding: 1px 4px; border-radius: 4px; }
.photo {
  display: block; width: 100%; max-width: 100%; margin: 0 0 10px; padding: 0;
  border: 1px solid var(--rail); border-radius: 8px; overflow: hidden;
  background: var(--wash); cursor: zoom-in;
}
.photo img { display: block; width: 100%; height: 100%; object-fit: contain; }
.photo-wait { display: grid; place-items: center; height: 100%; min-height: 80px; color: var(--sub); font-size: 14px; }
.done-btn {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; margin-top: 12px; padding: 0 16px;
  border: 2px solid var(--blue); border-radius: 10px; background: transparent; color: var(--blue);
  font-size: 16px; font-weight: 700; cursor: pointer;
  transition: transform 120ms var(--ease-out), background-color 120ms, color 120ms;
}
.done-btn:active { transform: scale(0.97); }
.done-box { width: 18px; height: 18px; border: 2px solid currentColor; border-radius: 4px; display: inline-grid; place-items: center; font-size: 13px; line-height: 1; }
.step.is-done { border-left-color: var(--blue); }
.step.is-done .step-no { color: var(--sub); }
.step.is-done .done-btn { background: var(--blue); color: var(--on-blue); }
.step.is-done .done-box::after { content: "✓"; animation: check-pop 280ms var(--ease-out); }
@keyframes check-pop { from { opacity: 0; transform: scale(0.3) rotate(-20deg); } 60% { opacity: 1; transform: scale(1.25); } }
.bar-progress { display: inline-block; }
.bar-progress.bump { animation: bump 300ms var(--ease-out); }
@keyframes bump { 40% { transform: scale(1.18); } }
.all-done { margin: 16px 0 0; padding: 14px 16px; background: var(--wash); border-radius: 10px; }
.all-done p { margin: 0 0 8px; font-weight: 700; }
.link-btn { min-height: 44px; padding: 0; border: 0; background: none; color: var(--blue); text-decoration: underline; cursor: pointer; }

.loading, .missing { margin: 32px 0; color: var(--sub); }

/* ---- 写真の拡大 ---- */
.zoom {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center;
  padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px);
  background: rgba(0, 0, 0, 0.88); overscroll-behavior: contain;
  animation: zoom-in 180ms var(--ease-out);
}
.zoom img { max-width: 100%; max-height: 100dvh; touch-action: pinch-zoom; }
.zoom-close {
  position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); right: 12px;
  min-height: 44px; padding: 0 16px; border: 0; border-radius: 10px;
  background: rgba(255, 255, 255, 0.92); color: #13233b; font-weight: 700;
}
@keyframes zoom-in { from { opacity: 0; } }
.zoom img { animation: zoom-img 240ms var(--ease-out); }
@keyframes zoom-img { from { opacity: 0; transform: scale(0.96); } }

/* 狭い画面（320px級）では番号の列を細くして本文の幅を空ける */
@media (max-width: 360px) {
  .step { grid-template-columns: minmax(30px, auto) minmax(0, 1fr); column-gap: 8px; padding-left: 8px; }
  .step-no { font-size: 26px; letter-spacing: -0.04em; }
}

@media (hover: hover) and (pointer: fine) {
  .toc-item:hover { box-shadow: 0 0 0 1px rgba(56, 182, 255, 0.6), 0 8px 24px rgba(10, 63, 148, 0.35); }
  .flow-item:hover { background: var(--wash); }
  .done-btn:hover { background: var(--wash); }
  .step.is-done .done-btn:hover { background: var(--blue-press); }
  .btn-primary:hover { background: var(--blue-press); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; animation: none !important; }
  /* 「動きを減らす」の人には、位置は動かさず、ふわっと出るだけにする */
  #app.login::before, .login-card, .toc-item.is-enter, .toc-title.is-enter, .zoom img { animation: fade-only 200ms ease both !important; }
  .toc-item.is-enter * { animation: none !important; }
  .reveal, .reveal *, .reveal::after { transform: none !important; clip-path: none !important; }
  .reveal.is-in, .reveal.is-in * { animation: fade-only 200ms ease both !important; }
}
@keyframes fade-only { from { opacity: 0; } }
