/* pdf-impose 固有スタイル */

.tool-main:has(.pi-layout:not([hidden])) { max-width: 1200px; }

.pi-layout { display: grid; grid-template-columns: minmax(0, 1fr) 460px; gap: 1rem; align-items: start; }
.pi-layout[data-view="flip"] { grid-template-columns: minmax(0, 1fr) 620px; }
.pi-options { min-width: 0; }
.pi-preview { min-width: 0; }
.pi-sticky { position: sticky; top: 0.75rem; }
.pi-preview .card { margin-bottom: 0; }
.pi-preview [hidden] { display: none !important; }

#pv-stage canvas { box-shadow: 0 0 0 1px var(--border); }
#pv-stage.busy { opacity: 0.6; }

.pi-views { margin: 0 0 0.7rem; }

/* ───────── 読み込み後は上部を1行に詰める ───────── */
.pi-loaded { padding-top: 1rem; }
.pi-loaded > h1 { font-size: 1.25rem; margin-bottom: 0.6rem; }
.pi-loaded > .pt-lead { display: none; }
.pi-file.loaded { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; padding: 0.55rem 0.8rem; margin-bottom: 0.8rem; }
.pi-file.loaded .pt-fileinfo { order: 1; flex: 1 1 200px; margin: 0 !important; padding: 0; border: 0; background: none; }
.pi-file.loaded .pt-drop { order: 2; flex: 0 0 auto; padding: 0.4rem 0.9rem; }
.pi-file.loaded .pt-drop-main { margin: 0; font-size: 0.88rem; }
.pi-file.loaded .pt-drop-sub { display: none; }
.pi-file.loaded .pt-notice { order: 3; flex: 1 0 100%; }
.pi-loaded .pi-options .card { padding: 1rem 1.1rem; margin-bottom: 0.8rem; }

/* ───────── 仕上げの設定（タブ・折りたたみ） ───────── */
.pi-tabs { margin-bottom: 1rem; }
.pi-tabs .pt-tab { flex: 1 1 auto; text-align: center; padding: 0.6rem 0.5rem; }
.pi-tabs .pt-tab[data-on="1"]::after {
  content: ""; display: inline-block; width: 0.5rem; height: 0.5rem; margin-left: 0.35rem; vertical-align: 0.1em;
  border-radius: 50%; background: var(--pt-accent);
}
.pi-more { margin-top: 0.8rem; border: 1px solid var(--border); border-radius: var(--pt-r); background: var(--surface); }
.pi-more > summary { cursor: pointer; padding: 0.55rem 0.8rem; font-size: 0.88rem; color: var(--text-sub); list-style: none; }
.pi-more > summary::-webkit-details-marker { display: none; }
.pi-more > summary::before { content: "＋"; display: inline-block; width: 1.2em; font-weight: 700; }
.pi-more[open] > summary::before { content: "－"; }
.pi-more > summary:hover { color: var(--text); }
.pi-more > summary:focus-visible { outline: 2px solid var(--pt-accent); outline-offset: -2px; }
.pi-more[open] > summary { border-bottom: 1px solid var(--border); }
.pi-more > :not(summary) { margin-left: 0.8rem; margin-right: 0.8rem; }
.pi-more > summary + * { margin-top: 0.8rem; }
.pi-more > :last-child { margin-bottom: 0.8rem; }
.pi-more[hidden] { display: none; }

/* ───────── ページめくり ───────── */
.pi-flip-stage {
  display: grid; place-items: center; overflow: hidden; outline: none;
  padding: 1.25rem 1rem; touch-action: pan-y;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--pt-r);
}
.pi-flip-stage:focus-visible { outline: 2px solid var(--pt-accent); outline-offset: -2px; }
.pi-flip-stage.is-zoomed { overflow: auto; }
.pi-flip-stage.is-zoomed .pi-book { transition: none; }
.pi-hi { position: absolute; display: block; pointer-events: none; }
#flip-zbar .pt-zbar { margin-top: 0; }

.pi-book { position: relative; perspective: 2400px; transition: transform 0.6s cubic-bezier(0.5, 0.05, 0.2, 1); }
.pi-book[data-state="front"][data-bind="left"],
.pi-book[data-state="back"][data-bind="right"] { transform: translateX(-25%); }
.pi-book[data-state="back"][data-bind="left"],
.pi-book[data-state="front"][data-bind="right"] { transform: translateX(25%); }

.pi-cast {
  position: absolute; top: 0; bottom: 0; left: 0; right: 0; z-index: 0;
  background: var(--surface); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.1);
  transition: left 0.6s cubic-bezier(0.5, 0.05, 0.2, 1), right 0.6s cubic-bezier(0.5, 0.05, 0.2, 1);
}
.pi-book[data-state="front"][data-bind="left"] .pi-cast,
.pi-book[data-state="back"][data-bind="right"] .pi-cast { left: 50%; }
.pi-book[data-state="back"][data-bind="left"] .pi-cast,
.pi-book[data-state="front"][data-bind="right"] .pi-cast { right: 50%; }

.pi-leaf {
  position: absolute; top: 0; height: 100%; width: 50%; cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.7s cubic-bezier(0.5, 0.05, 0.2, 1);
}
.pi-book[data-bind="left"] .pi-leaf { left: 50%; transform-origin: 0 50%; }
.pi-book[data-bind="left"] .pi-leaf.flipped { transform: rotateY(-180deg); }
.pi-book[data-bind="right"] .pi-leaf { right: 50%; transform-origin: 100% 50%; }
.pi-book[data-bind="right"] .pi-leaf.flipped { transform: rotateY(180deg); }

.pi-face {
  position: absolute; inset: 0; overflow: hidden; background: #fff;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.pi-face.back { transform: rotateY(180deg); }
.pi-canvas { display: block; width: 100%; height: 100%; }
.pi-face::before, .pi-face::after { content: ""; position: absolute; inset: 0; pointer-events: none; }
.pi-face::after { background: linear-gradient(var(--sd, to right), rgba(0, 0, 0, 0.16), rgba(0, 0, 0, 0) 14%); }
.pi-face::before { background: #000; opacity: 0; }
.pi-leaf.moving .pi-face::before { animation: pi-dim 0.7s ease-in-out both; animation-delay: var(--d, 0ms); }
@keyframes pi-dim { 0%, 100% { opacity: 0; } 50% { opacity: 0.22; } }

.pi-book[data-bind="left"] .pi-face.front { --sd: to right; }
.pi-book[data-bind="left"] .pi-face.back { --sd: to left; }
.pi-book[data-bind="right"] .pi-face.front { --sd: to left; }
.pi-book[data-bind="right"] .pi-face.back { --sd: to right; }

.pi-flip-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.6rem; margin-top: 0.7rem; }
.pi-flip-bar .btn-xs { margin: 0; width: auto; flex: none; white-space: nowrap; padding: 0.45rem 0.8rem; font-size: 0.85rem; }
.pi-flip-bar input[type="range"] { flex: 1 1 8rem; width: auto; min-width: 0; margin: 0; }
.pi-flip-bar .pi-flip-fs[aria-pressed="true"] { background: var(--pt-accent); border-color: var(--pt-accent); color: #fff; }
.pi-flip-bar button:disabled { opacity: 0.45; cursor: default; }
.pi-flip-cap { margin: 0.6rem 0 0; text-align: center; font-weight: 700; font-size: 0.95rem; }
.pi-flip-hint { margin: 0.2rem 0 0; text-align: center; }

/* 全画面：めくり表示が余りの高さをすべて使う */
.pt-fs .pi-flip { display: flex; flex-direction: column; flex: 1 1 0%; min-height: 0; }
.pt-fs .pi-flip-stage { flex: 1 1 0%; min-height: 0; }

.pi-flip-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.4rem 1.2rem; margin-top: 0.5rem; }
.pi-flip-tools .pi-flip-anim { margin: 0; }
.pi-jump-label { display: flex; align-items: center; gap: 0.4rem; margin: 0; font-size: 0.85rem; }
.pi-flip-tools input[type="number"] { width: 4.5rem; margin: 0; padding: 0.3rem 0.4rem; }
.pi-flip-tools .btn-xs { margin: 0; width: auto; flex: none; white-space: nowrap; padding: 0.4rem 0.8rem; font-size: 0.85rem; }

/* 1ページ表示: 枠は1ページぶんの幅。拡大して1ページずつ見せる */
.pi-flip-stage.is-single { padding-left: 0; padding-right: 0; place-items: start; margin-left: auto; margin-right: auto; scrollbar-width: none; max-width: 100%; }
.pi-flip-stage.is-single::-webkit-scrollbar { display: none; }
.pt-fs .pi-flip-stage.is-single { align-self: center; }

.pi-flip-anim { display: flex; align-items: center; justify-content: center; gap: 0.4rem; margin: 0.5rem 0 0; font-size: 0.85rem; cursor: pointer; }
.pi-flip-anim input { margin: 0; width: auto; }

.pi-book.no-anim, .pi-book.no-anim .pi-cast, .pi-book.no-anim .pi-leaf { transition-duration: 0.01s !important; transition-delay: 0s !important; }
.pi-book.no-anim .pi-leaf.moving .pi-face::before { animation: none; }

@media (max-width: 1000px) {
  .pi-layout[data-view="flip"] { grid-template-columns: 1fr; }
  .pi-layout[data-view="flip"] .pi-preview { order: -1; }
  .pi-layout[data-view="flip"] .pi-sticky { position: static; }
}
@media (max-width: 860px) {
  .pi-layout { grid-template-columns: 1fr; }
  .pi-preview { order: -1; }
  .pi-sticky { position: static; }
  .pi-preview .card { padding: 0.7rem 0.8rem; }
  .pi-preview .pt-title { margin-bottom: 0.4rem; }
  .pi-preview .pt-zhint { display: none; }
  .pi-views { margin-bottom: 0.4rem; }
  .pi-tabs .pt-tab { padding: 0.55rem 0.2rem; font-size: 0.85rem; }
  .pi-options .pt-seg { display: flex; flex-direction: column; }
  .pi-options .pt-seg label { border-right: none; border-bottom: 1px solid var(--border); }
  .pi-options .pt-seg label:last-child { border-bottom: none; }
  .pi-flip-stage { padding: 0.8rem 0.5rem; }
}

.pi-flip-load { margin: 0.3rem 0 0; text-align: center; }


/* ───────── 各項目の「?」ボタンと説明モーダル ───────── */
.pi-q {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.45rem; height: 1.45rem; margin: 0 0 0 0.4rem; padding: 0; vertical-align: middle;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
  color: var(--pt-accent); font: 700 0.78rem/1 var(--font); cursor: pointer; flex-shrink: 0;
}
.pi-q:hover, .pi-q:focus-visible { border-color: var(--pt-accent); background: var(--pt-accent-soft); }
.pt-check .pi-q { margin-top: -0.1rem; }
@media (pointer: coarse) { .pi-q { width: 1.9rem; height: 1.9rem; font-size: 0.9rem; } }

.pi-hint-modal { z-index: 2100; }
.pi-hint-modal .help-modal-inner { max-width: 640px; }
.pi-hint-modal .help-modal-body ol, .pi-hint-modal .help-modal-body ul { padding-left: 1.4rem; margin: 0 0 0.5rem; }
.pi-hint-modal .help-modal-body li { margin-bottom: 0.25rem; }
.pi-hint-modal .help-modal-body:focus { outline: none; }
.pi-hd-only { display: inline-block; margin: 0 0 0.5rem; padding: 0.1rem 0.55rem; font-size: 0.78rem; color: var(--text-sub); border: 1px solid var(--border); border-radius: 6px; }
.pi-hd-lead { font-weight: 700; margin-bottom: 0.6rem; }
.pi-hd-now { margin: 0.2rem 0 0.4rem; padding: 0.4rem 0.7rem; font-size: 0.85rem; background: var(--pt-accent-soft); border: 1px solid var(--border); border-radius: 6px; }
.pi-hd-now[hidden] { display: none; }
.pi-figs { display: flex; flex-direction: column; gap: 0.7rem; margin: 0.4rem 0 0.8rem; }
.pi-fig { margin: 0; padding: 0.6rem 0.4rem; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; }
.pi-hd-tbl { width: 100%; border-collapse: collapse; margin: 0.2rem 0 0.8rem; font-size: 0.85rem; }
.pi-hd-tbl th, .pi-hd-tbl td { border: 1px solid var(--border); padding: 0.3rem 0.6rem; text-align: left; }
.pi-hd-tbl th { background: var(--bg); font-weight: 700; }
.pi-hd-tbl code { font-family: ui-monospace, Consolas, monospace; color: var(--pt-accent); }

.hd { display: block; width: 100%; max-width: 440px; height: auto; margin: 0 auto; font-family: var(--font); }
.hd text { font-family: var(--font); }
.hd-paper { fill: var(--surface); stroke: var(--text-sub); stroke-width: 1.2; }
.hd-paper2 { fill: var(--surface); stroke: none; }
.hd-mgz { fill: var(--pt-warn-soft); stroke: var(--pt-warn); }
.hd-gpz { fill: var(--pt-warn-line); stroke: none; }
.hd-pg { fill: var(--pt-accent-soft); stroke: var(--pt-accent); stroke-width: 1; }
.hd-pg2 { fill: var(--pt-ok-soft); stroke: var(--pt-ok); stroke-width: 1; }
.hd-pgf { fill: var(--surface); stroke: var(--text); stroke-width: 1.2; }
.hd-pgn { fill: var(--surface); stroke: none; }
.hd-bl { fill: none; stroke: var(--text-sub); stroke-width: 1; stroke-dasharray: 3 3; }
.hd-bleed { fill: var(--pt-accent-soft); stroke: var(--pt-accent); stroke-width: 1; }
.hd-trim { fill: var(--surface); stroke: var(--pt-err); stroke-width: 1.2; stroke-dasharray: 4 3; }
.hd-safe { fill: none; stroke: var(--text-sub); stroke-width: 1; stroke-dasharray: 2 3; }
.hd-ln { stroke: var(--text-sub); stroke-width: 1; }
.hd-ln2 { stroke: var(--text-sub); stroke-width: 0.6; opacity: 0.5; }
.hd-cl { stroke: var(--pt-accent); stroke-width: 1.4; opacity: 0.35; }
.hd-dash { stroke-dasharray: 4 3; }
.hd-thick { stroke-width: 2.2; }
.hd-a { stroke: var(--pt-accent); stroke-width: 1.6; fill: none; }
.hd-ahf { fill: var(--pt-accent); }
.hd-red { stroke: var(--pt-err); stroke-width: 1.4; fill: none; }
.hd-ok { stroke: var(--pt-ok); stroke-width: 1.4; fill: none; }
.hd-mk { stroke: var(--text); stroke-width: 1.2; }
.hd-hole { fill: var(--surface); stroke: var(--text-sub); stroke-width: 1; }
.hd-dot { fill: var(--pt-accent); }
.hd-dot2 { fill: var(--pt-warn); }
.hd-ring { fill: none; stroke: var(--pt-err); stroke-width: 1.2; }
.hd-sheet, .hd-sheet2 { fill: none; stroke-width: 2; stroke-linejoin: round; }
.hd-sheet { stroke: var(--pt-accent); }
.hd-sheet2 { stroke: var(--pt-warn); }
.hd-t { fill: var(--text); font-size: 12px; }
.hd-ts { fill: var(--text-sub); font-size: 10.5px; }
.hd-tb { fill: var(--text); font-size: 12.5px; font-weight: 700; }
.hd-tn { fill: var(--pt-accent); font-size: 12px; font-weight: 700; }
.hd-tnb { fill: var(--pt-accent); font-size: 22px; font-weight: 700; }
.hd-tw { fill: var(--pt-warn); font-size: 11px; font-weight: 700; }
.hd-tok { fill: var(--pt-ok); font-size: 11px; font-weight: 700; }
.hd .mono { font-family: ui-monospace, Consolas, monospace; }
@media (max-width: 560px) {
  .pi-hint-modal { padding: 0.5rem; }
  .pi-hint-modal .help-modal-inner { max-height: 92vh; }
  .pi-fig { padding: 0.4rem 0.2rem; }
}


/* ───────── 項目名（「?」を含むため label ではなく div） ───────── */
.pi-flabel { display: block; font-size: 0.875rem; color: var(--text-sub); margin-bottom: 0.4rem; font-weight: 500; }
.pi-options .form-group > label { display: flex; flex-wrap: wrap; align-items: center; row-gap: 0.1rem; }
.pi-options .form-group > label.pt-check, .pi-options .form-group > label.pt-radio { display: flex; }
.pi-options .pt-grid2, .pi-options .pt-grid3 { align-items: end; }
#range-hint { margin-bottom: 0.7rem; }

/* 切り替えタブ：枠からはみ出さない */
.pi-options .pt-seg, .pi-views.pt-seg { display: flex; width: 100%; max-width: 100%; }
.pi-options .pt-seg label, .pi-views.pt-seg label { flex: 1 1 auto; min-width: 0; white-space: normal; text-align: center; line-height: 1.35; padding: 0.5rem 0.4rem; }
@media (max-width: 760px) {
  .pi-options .pt-seg { flex-direction: column; }
  .pi-options .pt-seg label { flex: none; }
}

/* ───────── 使い方（pi-guide） ───────── */
.pi-guide .help-modal-inner { max-width: 780px; max-height: 88vh; }
.pi-guide .help-modal-header { padding: 1.1rem 1.5rem; }
.pi-guide .help-modal-header h2 { font-size: 1.15rem; font-weight: 700; letter-spacing: 0.01em; display: flex; align-items: baseline; gap: 0.7rem; flex-wrap: wrap; }
.pi-guide .help-modal-header h2 small { font-size: 0.8rem; font-weight: 500; color: var(--text-sub); }
.pi-guide .help-modal-body { padding: 1.5rem; line-height: 1.7; }
.pi-guide .pg-sec { margin: 0 0 2rem; }
.pi-guide .pg-sec:last-of-type { margin-bottom: 1.2rem; }
.pi-guide .help-modal-body h3 {
  display: flex; align-items: center; gap: 0.8rem;
  margin: 0 0 0.9rem; padding: 0; border: none;
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.12em; color: var(--text-sub);
}
.pi-guide .help-modal-body h3::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.pi-guide .pg-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.8rem; }
.pi-guide .pg-mode { border: 1px solid var(--border); border-radius: var(--pt-r); background: var(--surface); padding: 0.8rem 0.9rem 0.9rem; }
.pi-guide .pg-mode svg { display: block; width: 100%; height: auto; max-height: 92px; margin-bottom: 0.7rem; padding: 0.5rem 0; background: var(--bg); border-radius: 4px; }
.pi-guide .pg-mode b { display: block; font-size: 0.92rem; margin-bottom: 0.2rem; }
.pi-guide .pg-mode p { margin: 0; font-size: 0.8rem; line-height: 1.6; color: var(--text-sub); }
.pi-guide .pg-paper { fill: var(--surface); stroke: var(--text-sub); stroke-width: 1; }
.pi-guide .pg-pg { fill: var(--pt-accent-soft); stroke: var(--pt-accent); stroke-width: 0.8; }
.pi-guide .pg-fold { stroke: var(--text-sub); stroke-width: 0.8; stroke-dasharray: 2 2; }
.pi-guide .pg-num { font: 700 8px var(--font); fill: var(--pt-accent); text-anchor: middle; }
.pi-guide .pg-ln line { stroke: var(--text-sub); stroke-width: 0.7; opacity: 0.6; }

.pi-guide .pg-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin: 0; padding: 0; list-style: none; border: 1px solid var(--border); border-radius: var(--pt-r); overflow: hidden; }
.pi-guide .pg-steps li { margin: 0; padding: 0.9rem 0.95rem 1rem; border-right: 1px solid var(--border); background: var(--surface); }
.pi-guide .pg-steps li:last-child { border-right: none; }
.pi-guide .pg-n { display: block; font: 700 1.5rem/1 var(--font); color: var(--pt-accent); opacity: 0.85; margin-bottom: 0.6rem; font-variant-numeric: tabular-nums; }
.pi-guide .pg-steps b { display: block; font-size: 0.9rem; margin-bottom: 0.25rem; }
.pi-guide .pg-steps p { margin: 0; font-size: 0.78rem; line-height: 1.6; color: var(--text-sub); }

.pi-guide .pg-acc { border: 1px solid var(--border); border-radius: var(--pt-r); overflow: hidden; background: var(--surface); }
.pi-guide .pg-acc details + details { border-top: 1px solid var(--border); }
.pi-guide .pg-acc summary { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.85rem 1rem; cursor: pointer; list-style: none; font-size: 0.92rem; font-weight: 600; }
.pi-guide .pg-acc summary::-webkit-details-marker { display: none; }
.pi-guide .pg-acc summary::after { content: "＋"; font-weight: 400; color: var(--text-sub); flex-shrink: 0; }
.pi-guide .pg-acc details[open] > summary::after { content: "－"; }
.pi-guide .pg-acc summary:hover { background: var(--bg); }
.pi-guide .pg-acc summary:focus-visible { outline: 2px solid var(--pt-accent); outline-offset: -2px; }
.pi-guide .pg-dl { display: grid; grid-template-columns: 7.5em 1fr; gap: 0.7rem 1rem; margin: 0; padding: 0.2rem 1rem 1.1rem; font-size: 0.85rem; }
.pi-guide .pg-dl dt { font-weight: 700; color: var(--text); }
.pi-guide .pg-dl dd { margin: 0; color: var(--text-sub); }
.pi-guide .pg-dl dd strong { color: var(--text); font-weight: 600; }
.pi-guide .pg-foot { margin: 0; padding-top: 1rem; border-top: 1px solid var(--border); font-size: 0.78rem; line-height: 1.7; color: var(--text-sub); }

@media (max-width: 640px) {
  .pi-guide .help-modal-body { padding: 1.1rem; }
  .pi-guide .pg-modes { grid-template-columns: 1fr; }
  .pi-guide .pg-mode { display: grid; grid-template-columns: 96px 1fr; column-gap: 0.8rem; align-items: center; }
  .pi-guide .pg-mode svg { grid-row: 1 / span 2; margin: 0; }
  .pi-guide .pg-steps { grid-template-columns: 1fr 1fr; }
  .pi-guide .pg-steps li:nth-child(2) { border-right: none; }
  .pi-guide .pg-steps li:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
  .pi-guide .pg-dl { grid-template-columns: 1fr; gap: 0.15rem; }
  .pi-guide .pg-dl dd { margin-bottom: 0.6rem; }
}
