:root {
  --accent: #1f5fa8;
  --bg: #e9eaec;
  --bar: rgba(255, 255, 255, .94);
  --ink: #222;
  --sub: #666;
  --line: rgba(0, 0, 0, .1);
  --bar-h: 48px;
}

* { box-sizing: border-box; }
/* iPhone・iPad で、ダブルタップしたときに Safari が画面全体を拡大しないようにする（紙面の拡大はこちらで行う） */
html, body, button, a, input { touch-action: manipulation; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Meiryo, sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

#app { position: fixed; inset: 0; display: flex; flex-direction: column; }

/* ===== 上下のバー ===== */
.bar {
  height: var(--bar-h);
  flex: none;
  display: flex;
  align-items: center;
  background: var(--bar);
  z-index: 5;
}
.bar.top {
  justify-content: space-between;
  padding: 0 16px;
  padding-top: env(safe-area-inset-top);
  height: calc(var(--bar-h) + env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
#logo { height: 28px; width: auto; max-width: 140px; object-fit: contain; flex: none; }
.bar.top h1 { font-size: 15px; font-weight: 600; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#counter { font-size: 13px; color: var(--sub); font-variant-numeric: tabular-nums; flex: none; margin-left: 12px; }
/* ページ番号は押すと番号を入れて移動できる：押せることが分かるよう、枠を付ける */
#counter { cursor: pointer; padding: 4px 10px; border: 1px solid var(--line); border-radius: 14px; }
#counter:hover { color: var(--accent); border-color: var(--accent); }
.bar.bottom {
  justify-content: center;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  height: calc(var(--bar-h) + env(safe-area-inset-bottom));
}
.bar.bottom button {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 60px; height: 44px; border-radius: 8px; font-size: 10px; color: var(--sub);
}
.bar.bottom button:hover { background: rgba(0, 0, 0, .05); color: var(--accent); }
.bar.bottom button:disabled { opacity: .35; cursor: default; background: none; }

/* ===== 紙面 ===== */
#stage {
  position: relative;
  flex: 1;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
/* マウスでは、紙面の上で虫めがねの形にして「押すと拡大できる」ことを伝える（拡大中は「押すと戻る」） */
@media (pointer: fine) {
  #stage { cursor: zoom-in; }
  body.zoomed #stage { cursor: zoom-out; }
}
/* 拡大中だけ出る「全体に戻る」 */
.zoom-pill {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 6;
  display: flex; align-items: center; gap: 8px; padding: 8px 12px 8px 14px; border-radius: 20px;
  background: rgba(30, 30, 30, .82); color: #fff; font-size: 13px; font-weight: 600;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .25); cursor: pointer;
}
.zoom-pill[hidden] { display: none; }
.zoom-pill:hover { background: rgba(30, 30, 30, .95); }
.zoom-pill .zp-pct { font-variant-numeric: tabular-nums; opacity: .75; font-weight: 400; }
.zoom-pill svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 2.4; fill: none; }

#book {
  position: absolute;
  left: 0; top: 0;
  display: flex;
  transform-origin: 0 0;
  /* will-change は操作中だけ viewer.js が付ける（付けたままだと、拡大後も小さいときの絵を引き伸ばして表示し、ぼやける） */
}
#book.anim { transition: transform .28s ease-out, opacity .28s ease-out; }
#book.turn { transition: transform .22s cubic-bezier(.2, .7, .3, 1), opacity .22s ease-out; }
.page .hl.pulse { animation: hl-in .6s ease-out 2; }
.page {
  position: relative;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .15);
  overflow: hidden;
}
.page img {
  display: block;
  width: 100%; height: 100%;
  pointer-events: none;
  -webkit-user-drag: none;
}
/* 見開きの綴じ目に軽い影（ページは画面の左から順に並べている） */
.spread .page::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 24px; pointer-events: none;
}
.spread .page:first-child::after { right: 0; background: linear-gradient(to left, rgba(0, 0, 0, .10), transparent); }
.spread .page:last-child::after { left: 0; background: linear-gradient(to right, rgba(0, 0, 0, .10), transparent); }

/* ===== 紙をめくる動き ===== */
.flip-layer { position: absolute; inset: 0; z-index: 3; pointer-events: none; perspective: 2400px; }
.flip-static, .flip-leaf { position: absolute; }
.flip-leaf { transform-style: preserve-3d; }
.flip-leaf.go { transition: transform .6s cubic-bezier(.35, .05, .25, 1); }
.flip-face { position: absolute; inset: 0; background: #fff; overflow: hidden; -webkit-backface-visibility: hidden; backface-visibility: hidden; }
.flip-face img { display: block; width: 100%; height: 100%; }
.flip-face.back { transform: rotateY(180deg); }
/* めくっている紙に、うっすら影を付けて立体に見せる */
.flip-leaf .flip-face::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(to right, rgba(0, 0, 0, .12), rgba(0, 0, 0, 0) 30%); }
.flip-leaf .flip-face.back::after { background: linear-gradient(to left, rgba(0, 0, 0, .12), rgba(0, 0, 0, 0) 30%); }
.flip-leaf .flip-face.back:empty { background: #f4f4f4; }

/* ===== めくるボタン ===== */
.nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 44px; height: 72px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .8);
  color: var(--ink);
  box-shadow: 0 1px 6px rgba(0, 0, 0, .12);
  z-index: 4;
  transition: opacity .2s;
}
/* 矢印の下に「進む」「戻る」。右開きは左が「進む」、左開きは右が「進む」（viewer.js が入れる） */
.nav { flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; font-weight: 600; line-height: 1; letter-spacing: .05em; color: var(--sub); }
.nav:hover .nav-label { color: var(--accent); }
.nav-left { left: 0; border-radius: 0 8px 8px 0; }
.nav-right { right: 0; border-radius: 8px 0 0 8px; }
.nav:hover { color: var(--accent); background: #fff; }
.nav[disabled] { opacity: 0; pointer-events: none; }
.zoomed .nav { opacity: 0; pointer-events: none; }

/* ===== ページ一覧 ===== */
.panel {
  position: absolute; inset: 0;
  background: rgba(245, 245, 247, .98);
  z-index: 10;
  display: flex; flex-direction: column;
}
.panel[hidden] { display: none; }
.panel-head {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  height: var(--bar-h); padding: 0 8px 0 16px; padding-top: env(safe-area-inset-top);
  box-sizing: content-box;
  border-bottom: 1px solid var(--line); font-weight: 600; font-size: 15px;
}
.panel-head { gap: 8px; }
#thumbGrid {
  flex: 1; overflow-y: auto; padding: 16px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 16px 12px;
  align-content: start;
}
.thumb { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; color: var(--sub); }
.thumb img { width: 100%; height: auto; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .15); border: 2px solid transparent; }
.thumb.current img { border-color: var(--accent); }
.thumb.current { color: var(--accent); font-weight: 600; }

/* ===== 一覧のタブ・目次 ===== */
.tabs { display: flex; gap: 4px; }
.tabs button { height: 34px; padding: 0 14px; border-radius: 17px; font-size: 14px; font-weight: 600; color: var(--sub); }
.tabs button.on { background: var(--accent); color: #fff; }
.panel-head .close { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; flex: none; }
#thumbGrid[hidden], #tocList[hidden] { display: none; }
#tocList { flex: 1; overflow-y: auto; list-style: none; margin: 0; padding: 8px 16px 24px; }
#tocList button {
  width: 100%; display: flex; align-items: baseline; gap: 12px; text-align: left;
  padding: 14px 8px; border-bottom: 1px solid var(--line); font-size: 15px;
}
#tocList button:hover { background: rgba(0, 0, 0, .03); }
#tocList button.current { color: var(--accent); font-weight: 700; background: rgba(0, 0, 0, .04); box-shadow: inset 3px 0 0 var(--accent); }
.toc-title { flex: 1; }
.toc-page { color: var(--sub); font-size: 13px; font-variant-numeric: tabular-nums; }

/* ===== 文字検索 ===== */
.panel.side { left: auto; width: 360px; box-shadow: -4px 0 16px rgba(0, 0, 0, .12); }
.search-box { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 19px; background: #fff; }
.search-box svg { width: 18px; height: 18px; color: var(--sub); flex: none; }
.search-box input { flex: 1; min-width: 0; width: 100%; border: 0; outline: 0; font: inherit; font-size: 16px; background: none; -webkit-appearance: none; appearance: none; }
.search-box input::-webkit-search-decoration, .search-box input::-webkit-search-cancel-button, .search-box input::-webkit-search-results-button { -webkit-appearance: none; display: none; }
.search-box .clear { flex: none; width: 26px; height: 26px; margin-right: -6px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--sub); }
.search-box .clear[hidden] { display: none; }
.search-box .clear:hover { background: rgba(0, 0, 0, .06); }
.search-box .clear svg { width: 16px; height: 16px; }
.search-box:focus-within { border-color: var(--accent); }
.search-info { margin: 0; padding: 10px 16px; font-size: 13px; color: var(--sub); }
.results { flex: 1; overflow-y: auto; list-style: none; margin: 0; padding: 0 8px 24px; }
.results button { width: 100%; display: flex; align-items: baseline; gap: 10px; text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); font-size: 13px; line-height: 1.5; }
.results button:hover { background: rgba(0, 0, 0, .03); }
.res-page { flex: none; font-weight: 700; color: var(--accent); min-width: 34px; }
.res-text { flex: 1; min-width: 0; word-break: break-all; }
.res-text mark { background: #ffe066; color: inherit; padding: 0 1px; border-radius: 2px; }
.res-count { flex: none; color: var(--sub); font-size: 12px; }
/* 見つかった場所の印 */
.page .hl {
  position: absolute; pointer-events: none; z-index: 2;
  background: rgba(255, 214, 0, .35); outline: 2px solid rgba(240, 160, 0, .9); border-radius: 2px;
  animation: hl-in .6s ease-out;
}
@keyframes hl-in { from { outline-width: 8px; outline-color: rgba(240, 160, 0, .2); } }

/* ===== リンク（押せる場所） =====
   ・色はお客様の基本色ではなく、リンクとして一般的な青に固定する（赤い線が「取り消し・販売終了」に見えないように）
   ・線は文字の外側に引き、文字には重ねない
     文字のリンク：文字の下に細い点線／縦書き（ツメ）：文字の右に細い線／広い範囲（INDEXのカード）：線なし
   ・ページを開いた瞬間だけ、文字が読める薄さで青く光らせて知らせる */
:root { --link: #1a66d6; }
.page .lnk { position: absolute; z-index: 1; cursor: pointer; border-radius: 2px; animation: lnk-hint 2.2s ease-out; }
.page .lnk::after { content: ""; position: absolute; pointer-events: none; }
.page .lnk.text::after {
  left: 0; right: 0; top: 100%; margin-top: 1px; height: 0;
  border-bottom: 1.5px dotted var(--link);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .85); /* 灰色・青など色の付いた背景でも点線が埋もれないよう、白い縁を付ける */
}
/* 小さい文字のリンク（スマホで見る品番の表など）：線は細く、白い縁なし。下の行の文字を隠さない */
.page .lnk.text.small::after { border-bottom-width: 1px; box-shadow: none; margin-top: 0; }
/* ツメはページの端にあるので、線は外側ではなく内側の右端に引く（外側だと画面の外に出て見えない） */
.page .lnk.vert::after {
  top: 0; bottom: 0; right: 2px; width: 0;
  border-right: 1.5px dotted var(--link);
  box-shadow: 1px 0 0 rgba(255, 255, 255, .85);
}
/* 広い範囲（カード・配置ツールで囲んだ写真など）は一番下の層に。重なった品番などの文字のリンクを優先する */
.page .lnk.area { z-index: 0; }
.page .lnk:hover { background: rgba(26, 102, 214, .1); background: color-mix(in srgb, var(--link) 10%, transparent); }
.page .lnk.text:hover::after { border-bottom-style: solid; border-bottom-width: 1.5px; }
.page .lnk.area:hover { box-shadow: inset 0 0 0 1.5px rgba(26, 102, 214, .7); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--link) 70%, transparent); }
/* 囲んだ範囲（外のページ・ポップアップ）：ふだんから薄い点線の枠で知らせる */
.page .lnk.marked { outline: 1.5px dashed rgba(26, 102, 214, .55); outline: 1.5px dashed color-mix(in srgb, var(--link) 55%, transparent); outline-offset: -1.5px; }
.page .lnk.tapped { background: rgba(26, 102, 214, .22); background: color-mix(in srgb, var(--link) 22%, transparent); }
@keyframes lnk-hint { 0%, 40% { background: rgba(26, 102, 214, .2); } }
.zoomed .page .lnk { animation: none; }

/* ポップアップの目印：押せる文字の右端に、丸いアイコン（紙面より手前に浮かせて見せる） */
.page .pop-ico {
  position: absolute; left: 100%; top: 50%; z-index: 2;
  width: 18px; height: 18px; margin: -9px 0 0 3px; /* 文字の高さの真ん中に、アイコンの真ん中を合わせる */
  /* 拡大しても画面上の大きさは変えない（--zoom-inv は viewer.js が拡大率の逆数を入れる） */
  scale: var(--zoom-inv, 1); transform-origin: left center;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--link); color: #fff;
  box-shadow: 0 0 0 2px #fff, 0 1px 4px rgba(0, 0, 0, .35);
  animation: ico-pop 1.8s ease-out;
}
.page .pop-ico svg { width: 12px; height: 12px; stroke-width: 2.2; }
.page .pop-ico .fill { fill: currentColor; stroke: none; }
.page .pop-ico.youtube { background: #e62117; }
/* 広い範囲では、アイコンを範囲の内側の右上に置く（外側の文字にかからないように） */
.page .pop-ico.inside { left: auto; right: 6px; top: 6px; margin: 0; transform-origin: right top; }
.page .lnk:hover .pop-ico { transform: scale(1.15); }
@keyframes ico-pop { 0% { transform: scale(.4); opacity: 0; } 25% { transform: scale(1.25); opacity: 1; } 45% { transform: scale(1); } }
.zoomed .page .pop-ico { animation: none; }

/* ===== ポップアップ ===== */
.popup {
  position: absolute; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: rgba(0, 0, 0, .55);
  animation: fade-in .15s ease-out;
}
.popup[hidden] { display: none; }
@keyframes fade-in { from { opacity: 0; } }
.popup-box {
  width: min(720px, 100%); max-height: 100%; display: flex; flex-direction: column;
  background: #fff; border-radius: 14px; overflow: hidden; box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
.popup-head { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 4px 0 16px; height: 48px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 14px; }
.popup-head .close { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; }
.popup-body { flex: 1; min-height: 0; overflow: auto; }
.popup-box.image .popup-body { background: #111; display: flex; align-items: center; justify-content: center; }
.popup-box.image img { display: block; max-width: 100%; max-height: calc(100vh - 140px); object-fit: contain; }
.popup-box.youtube .popup-body { background: #000; }
.video { position: relative; width: 100%; aspect-ratio: 16 / 9; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.popup-box.audio { width: min(460px, 100%); }
/* 文字のコピー：ページの文字を並べ、選んでコピーする */
.popup-box.copy { width: min(640px, 100%); }
.copy-hint { margin: 12px 20px 8px; font-size: 13px; color: var(--sub); }
.popup-box.copy .popup-body { display: flex; flex-direction: column; }
.popup-box.copy .copy-text { flex: 1 1 auto; min-height: 120px; margin-bottom: 20px; }
.copy-text {
  margin: 0 20px; padding: 12px; max-height: min(52vh, 480px); overflow: auto;
  border: 1px solid var(--line); border-radius: 8px; background: #fafafa;
  white-space: pre-wrap; font-size: 14px; line-height: 1.7;
  -webkit-user-select: text; user-select: text;
}
.copy-actions { flex: none; display: flex; gap: 8px; margin: 0 20px 12px; }
.copy-actions button { flex: 1; padding: 11px; border-radius: 10px; font-weight: 700; }
.copy-actions .copy-sel { background: var(--link); color: #fff; }
.copy-actions .copy-all { background: rgba(0, 0, 0, .06); color: var(--ink); }
.copy-actions button.done { background: #1e8e3e; color: #fff; }
.popup-box.audio audio { display: block; width: calc(100% - 32px); margin: 24px 16px; }
.popup-box.web { width: min(1400px, 100%); height: 100%; }
.web-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px 8px 16px; font-size: 12px; color: var(--sub); background: #f6f6f8; border-bottom: 1px solid var(--line); }
.web-bar a { flex: none; padding: 7px 14px; border-radius: 16px; background: var(--link); color: #fff; text-decoration: none; font-size: 13px; font-weight: 600; }
.popup-box.web .popup-body { display: flex; flex-direction: column; }
iframe.web { flex: 1; width: 100%; min-height: 60vh; border: 0; }
.popup-box.map { width: min(460px, 100%); }
.map-card { display: flex; gap: 14px; padding: 20px 20px 8px; }
.map-card .pin { width: 32px; height: 32px; flex: none; color: #e53935; }
.map-name { margin: 2px 0 4px; font-size: 16px; font-weight: 700; }
.map-address { margin: 0; font-size: 14px; color: var(--sub); line-height: 1.6; }
.map-open { display: block; margin: 12px 20px 20px; padding: 12px; border-radius: 10px; background: var(--link); color: #fff; text-align: center; text-decoration: none; font-weight: 700; }
@media (max-width: 600px) {
  .popup { padding: 0; align-items: flex-end; }
  .popup-box { width: 100%; max-height: 92%; border-radius: 16px 16px 0 0; }
  .popup-box.web { height: 92%; }
}

/* ===== その他メニュー ===== */
.menu {
  position: absolute; right: 12px; bottom: calc(var(--bar-h) + env(safe-area-inset-bottom) + 8px); z-index: 12;
  min-width: 240px; padding: 6px; background: #fff; border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .18), 0 0 0 1px var(--line);
}
.menu[hidden] { display: none; }
.menu button, .menu a {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 8px;
  font-size: 14px; text-decoration: none; color: var(--ink); text-align: left;
}
.menu button:hover, .menu a:hover { background: rgba(0, 0, 0, .05); }
.menu svg { width: 20px; height: 20px; color: var(--sub); flex: none; }

/* ===== お知らせ ===== */
#toast {
  position: absolute; left: 50%; bottom: calc(var(--bar-h) + env(safe-area-inset-bottom) + 16px); z-index: 40; /* ポップアップより手前に */
  transform: translate(-50%, 10px); opacity: 0; pointer-events: none;
  background: rgba(30, 30, 30, .92); color: #fff; font-size: 13px; padding: 10px 16px; border-radius: 20px;
  transition: opacity .2s, transform .2s; white-space: nowrap;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===== 印刷 ===== */
#printArea { display: none; }
@media print {
  @page { margin: 8mm; }
  html, body { height: auto; overflow: visible; background: #fff; }
  #app { display: none !important; }
  #printArea { display: block; }
  #printArea img { display: block; width: 100%; height: auto; max-height: 100vh; object-fit: contain; page-break-after: always; break-after: page; }
  #printArea img:last-child { page-break-after: auto; break-after: auto; }
  /* 見開きで1枚：2ページを横に並べる */
  #printArea.spread { display: flex; gap: 0; align-items: flex-start; }
  #printArea.spread img { width: 50%; max-height: calc(100vh - 16mm); page-break-after: auto; break-after: auto; }
}

@media (max-width: 700px) {
  .panel.side { width: 100%; box-shadow: none; }
}
/* 広い画面では、目次・一覧・付箋を左に置いたまま、紙面をめくれる（下のバーは隠さない） */
@media (min-width: 900px) and (min-height: 500px) {
  body.side-open #thumbs {
    right: auto; width: 300px; bottom: calc(var(--bar-h) + env(safe-area-inset-bottom));
    box-shadow: 4px 0 16px rgba(0, 0, 0, .12); background: #fafafb;
  }
  body.side-open #stage { margin-left: 300px; }
  body.side-open .bar.top { padding-left: 316px; }
  body.side-open #thumbGrid { grid-template-columns: repeat(2, 1fr); padding: 12px; gap: 12px 10px; }
  body.side-open #thumbs .tabs button { padding: 0 10px; font-size: 13px; }
  body.side-open #tocList { padding: 4px 8px 16px; }
  body.side-open #tocList button { padding: 11px 10px; font-size: 14px; }
}
/* パソコンでは、検索欄を開いても紙面が隠れないよう、紙面を左に寄せる */
@media (min-width: 701px) {
  body.searching #stage { margin-right: 360px; }
  body.searching .bar.top { padding-right: 376px; }
}

/* スマホ・タブレット（指で操作）：めくるボタンは画面の下の角に置く。
   真ん中にあると、ページ右端のツメに重なって押せなくなるため（2026-10 Android の検証） */
@media (pointer: coarse) {
  .nav { top: auto; bottom: 10px; transform: none; height: 56px; }
}
@media (max-width: 600px) {
  .nav { width: 34px; height: 60px; background: rgba(255, 255, 255, .7); }
  .nav svg { width: 18px; height: 18px; }
  .nav-label { font-size: 10px; letter-spacing: 0; }
  #thumbGrid { grid-template-columns: repeat(3, 1fr); padding: 12px; gap: 12px 8px; }
}

/* ===== ペン ===== */
.page svg.ink {
  position: absolute; inset: 0; width: 100%; height: 100%; z-index: 3; pointer-events: none;
  fill: none; stroke-linecap: round; stroke-linejoin: round;
}
.page svg.ink .marker { opacity: .4; mix-blend-mode: multiply; } /* マーカーは下の文字が読める薄さ */
body.inking #stage { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M3 21l1.3-4.5L16 4.8l3.2 3.2L7.5 19.7z' fill='white' stroke='black' stroke-width='1.5' stroke-linejoin='round'/%3E%3Cpath d='M14 6.8l3.2 3.2' stroke='black' stroke-width='1.5'/%3E%3C/svg%3E") 3 21, crosshair; }
body.erasing #stage { cursor: cell; }
.bar.bottom button[aria-pressed="true"] { background: rgba(0, 0, 0, .06); background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
.toolbar {
  flex: none; position: relative; z-index: 5;
  background: #fff; border-top: 1px solid var(--line); padding: 6px 8px 4px;
}
.toolbar[hidden] { display: none; }
.toolbar .tools { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: center; }
.toolbar button { flex: none; width: 40px; height: 40px; border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.toolbar button:hover { background: rgba(0, 0, 0, .05); }
.toolbar .swatch::before { content: ""; flex: none; display: block; width: 20px; height: 20px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 1px rgba(0, 0, 0, .15); }
.toolbar .swatch.marker::before { border-radius: 4px; width: 14px; height: 22px; transform: rotate(30deg); opacity: .8; }
.toolbar .swatch.on, .toolbar .width.on, .toolbar .tool[aria-pressed="true"] { background: rgba(0, 0, 0, .06); background: color-mix(in srgb, var(--accent) 14%, transparent); box-shadow: inset 0 0 0 2px var(--accent); }
.toolbar .width i { flex: none; display: block; width: var(--d); height: var(--d); border-radius: 50%; background: var(--ink); }
.toolbar .tool svg { flex: none; width: 22px; height: 22px; min-width: 22px; }
.toolbar .sep { width: 1px; height: 24px; background: var(--line); margin: 0 2px; }
.toolbar .done { width: auto; padding: 0 14px; margin-left: 4px; background: var(--accent); color: #fff; font-size: 13px; font-weight: 700; }
.toolbar .done:hover { background: var(--accent); filter: brightness(1.1); }
.local-note { margin: 4px 0 0; font-size: 11px; color: var(--sub); text-align: center; }

/* ===== 付箋 ===== */
body.placing #stage { cursor: copy; }
.page .note {
  position: absolute; z-index: 4;
  /* 拡大しても画面上の大きさは変えない */
  scale: var(--zoom-inv, 1); transform-origin: left top;
  min-width: 26px; max-width: 120px; min-height: 22px; padding: 3px 6px 3px 8px;
  background: #ffe873; color: #3a3000; font-size: 11px; line-height: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border-radius: 2px 2px 8px 2px; box-shadow: 0 2px 6px rgba(0, 0, 0, .28);
  border-left: 3px solid #f2c200; cursor: pointer;
}
.page .note:empty::before { content: "…"; }
.note-box { width: min(420px, 100%); }
.note-box textarea {
  display: block; width: calc(100% - 32px); margin: 16px 16px 0; padding: 10px 12px; resize: vertical;
  font: inherit; font-size: 16px; line-height: 1.6; border: 1px solid var(--line); border-radius: 8px; background: #fffbe0;
}
.note-box textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.note-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px 0; }
.note-actions button { height: 38px; padding: 0 18px; border-radius: 8px; font-size: 14px; font-weight: 600; }
.note-actions .primary { background: var(--accent); color: #fff; }
.note-actions .danger { color: #c62828; margin-right: auto; }
.note-actions .danger:hover { background: rgba(198, 40, 40, .08); }
.note-actions [hidden] { display: none; }
.note-box .local-note { padding: 8px 16px 14px; }
#notePanel { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
#notePanel[hidden] { display: none; }
#noteList { list-style: none; margin: 0; padding: 8px 16px 8px; }
#noteList button { width: 100%; display: flex; align-items: baseline; gap: 12px; text-align: left; padding: 12px 8px; border-bottom: 1px solid var(--line); font-size: 14px; line-height: 1.5; }
#noteList button:hover { background: rgba(0, 0, 0, .03); }
.note-text { flex: 1; min-width: 0; white-space: pre-wrap; word-break: break-all; }
#noteList .empty { padding: 24px 8px; color: var(--sub); font-size: 14px; line-height: 1.7; }
#notePanel .local-note { padding: 4px 16px 20px; }

/* 狭いスマホでは、下のボタンを少し詰めて7つ並べる */
@media (max-width: 440px) {
  .bar.bottom { gap: 0; }
  .bar.bottom button { min-width: 0; flex: 1; max-width: 60px; }
}
@media print { .page svg.ink, .page .note { display: none; } }

/* 近くに並んだリンクから選ぶ（スマホで品番の表を押したとき） */
.popup-box.choose { width: min(360px, 100%); }
/* 印刷のしかたを選ぶ・ページ番号で移動 */
.print-choice { display: flex; flex-direction: column; gap: 8px; padding: 12px; }
.print-choice button { text-align: left; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; font-weight: 700; font-size: 15px; }
.print-choice button:hover { border-color: var(--accent); color: var(--accent); }
.print-choice small { display: block; font-weight: 400; font-size: 12px; color: var(--sub); margin-top: 2px; }
.jump { display: flex; gap: 8px; align-items: flex-end; padding: 16px 16px 4px; }
.jump label { flex: 1; display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--sub); }
.jump input { font-size: 18px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; width: 100%; box-sizing: border-box; }
.jump button { padding: 11px 18px; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 700; }
.jump-note { margin: 4px 16px 16px; font-size: 12px; color: var(--sub); }
.choices { list-style: none; margin: 0; padding: 8px; }
.choices button { width: 100%; text-align: left; padding: 13px 14px; border-radius: 10px; font-size: 16px; font-variant-numeric: tabular-nums; color: var(--link); font-weight: 600; }
.choices button:hover, .choices button:active { background: rgba(26, 102, 214, .08); }
.choices li + li button { border-top: 1px solid var(--line); border-radius: 0; }
.choose-tip { margin: 0; padding: 0 16px 14px; font-size: 12px; color: var(--sub); }

/* 初めて開いたときだけの案内（数秒で消える） */
.first-hint {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 6;
  display: flex; align-items: center; gap: 8px; max-width: calc(100% - 96px);
  padding: 10px 16px; border-radius: 22px; background: rgba(30, 30, 30, .86); color: #fff;
  font-size: 13px; line-height: 1.5; pointer-events: none; animation: hint-in .4s ease-out;
  transition: opacity .4s;
}
.first-hint svg { width: 20px; height: 20px; flex: none; }
.first-hint.out { opacity: 0; }
@keyframes hint-in { from { opacity: 0; transform: translate(-50%, 8px); } }
