/*
 * 画面（操作領域）のスタイル：ヘッダー・ページ一覧・編集フォーム・ダイアログ。
 * 帳票（.a4 など）のスタイルは report.css に分離している。ここから帳票のクラスは触らない。
 *
 * 目次：1. 色・余白の基準  2. 印刷  3. 共通部品  4. 画面全体  5. ヘッダー  6. ページ一覧
 *       7. 編集エリア  8. プレビュー  9. ダイアログ・処理中  10. 中幅/狭幅  11. PDF生成時
 */
/* ---- 1. 色・余白の基準 ---- */
:root{
  --bg:#eef1f4;--surface:#fff;--line:#c8d0da;--line-soft:#e1e6ec;--field-line:#8c99ab;
  --text:#1c2733;--muted:#586577;
  --primary:#0b5cad;--primary-dark:#084a8c;--primary-soft:#e6f0fa;
  --danger:#a8261d;--danger-soft:#fdeceb;--ok:#0f6b3a;--warn:#8a4b00;--warn-soft:#fff4e0;
  --focus:#1366d6;--radius:6px;
}
body{background:var(--bg)}
.viewbar{display:none}
.skip-link{position:absolute;left:8px;top:-80px;z-index:100;background:#fff;color:var(--text);padding:8px 14px;border:2px solid var(--focus);border-radius:var(--radius)}
.skip-link:focus{top:8px}
/* ---- 2. 印刷（ブラウザの印刷：プレビューだけを出す） ---- */
@media print{
  header,aside,main,.viewbar,.preview-head,.skip-link{display:none!important}
  .layout{display:block}
  .preview{display:block;padding:0}
}
@media screen{
/* ---- 3. 共通部品 ---- */
.ui{font-size:15px;line-height:1.5}
.ui button{font:inherit;min-height:36px;padding:6px 14px;border:1px solid var(--field-line);border-radius:var(--radius);background:var(--surface);color:var(--text);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:6px}
.ui button:hover:not(:disabled){background:var(--primary-soft);border-color:var(--primary)}
.ui button:disabled{color:#7b8696;background:#f1f3f5;border-color:var(--line);cursor:not-allowed}
.ui button.primary{background:var(--primary);border-color:var(--primary);color:#fff;font-weight:700}
.ui button.primary:hover:not(:disabled){background:var(--primary-dark);border-color:var(--primary-dark)}
.ui button.danger{color:var(--danger);border-color:#d3918b}
.ui button.danger:hover:not(:disabled){background:var(--danger-soft);border-color:var(--danger)}
.ui :focus-visible{outline:3px solid var(--focus);outline-offset:2px}
.ui .hint{color:var(--muted);font-size:13px;margin:4px 0 12px}
.ui .field{display:flex;flex-direction:column;gap:4px}
.ui .field>span{font-weight:700;font-size:14px}
.ui .field :is(input,textarea,select){display:block;width:100%;margin:0;padding:8px 10px;min-height:38px;border:1px solid var(--field-line);border-radius:var(--radius);background:#fff;color:var(--text);font:inherit}
.ui .field textarea{min-height:140px;line-height:1.6;resize:vertical}
.ui .field :is(input,textarea,select):disabled{background:#eceff2;color:#7b8696;border-color:var(--line);cursor:not-allowed}
/* ---- 4. 画面全体 ---- */
body{height:100vh;display:flex;flex-direction:column;overflow:hidden}
.layout{flex:1;min-height:0;display:grid;grid-template-columns:300px minmax(0,1fr) minmax(0,1fr);grid-template-rows:minmax(0,1fr)}
/* ---- 5. ヘッダー ---- */
.app-header{flex:none;display:flex;align-items:center;flex-wrap:wrap;gap:8px 16px;min-height:56px;padding:8px 16px;background:var(--surface);color:var(--text);border-bottom:1px solid var(--line)}
.app-header .brand{margin-right:auto;font-size:17px}
.app-header .hgroup{display:flex;align-items:center;flex-wrap:wrap;gap:8px;padding:4px 6px;background:#f3f5f8;border-radius:8px}
#state{font-size:13px;font-weight:700;padding:3px 10px;border-radius:999px;border:1px solid transparent}
#state:empty{display:none}
#state[data-status="dirty"]{background:var(--warn-soft);border-color:#d99a3a;color:var(--warn)}
#state[data-status="dirty"]::before{content:"● "}
#state[data-status="saved"]{background:#e5f5ec;border-color:#6dbb91;color:var(--ok)}
#state[data-status="saved"]::before{content:"✓ "}
/* ---- 6. ページ一覧 ---- */
.page-list{padding:0;overflow:auto;min-width:0;background:var(--surface);border-right:1px solid var(--line)}
.page-list .side-head{position:sticky;top:0;z-index:2;padding:12px;background:var(--surface);border-bottom:1px solid var(--line-soft)}
.page-list .side-title{font-weight:700;margin-bottom:8px}
#pages{position:relative;padding:4px 12px 16px}
.page-list .chapter-label{margin:14px 0 4px;padding-bottom:3px;border-bottom:1px solid var(--line-soft);font-size:12px;font-weight:700;color:var(--muted)}
.page-list .chapter-label:first-child{margin-top:6px}
.page-list .page{display:grid;grid-template-columns:28px minmax(0,1fr);align-items:center;gap:0 2px;margin:5px 0;padding:2px 6px 2px 2px;background:var(--surface);border:1px solid var(--line);border-width:1px 1px 1px 4px;border-radius:var(--radius)}
.page-list .page.active{border-color:var(--primary);background:var(--primary-soft)}
.page-list .page.excluded{border-style:dashed dashed dashed solid;background:#f6f7f9}
.page-list .page.excluded.active{background:var(--primary-soft)}
.page-list .page.excluded .page-select b{color:var(--muted)}
.page-list .page.dragging{opacity:.45}
.page-list .drag-handle{align-self:stretch;display:flex;align-items:center;justify-content:center;border-radius:4px;color:var(--muted);font-size:18px;line-height:1;cursor:grab;user-select:none;touch-action:none}
.page-list .drag-handle:hover{background:rgba(11,92,173,.1);color:var(--primary)}
#pages.is-dragging{cursor:grabbing;user-select:none}
.page-list .drop-line{position:absolute;left:12px;right:12px;height:3px;border-radius:2px;background:var(--primary);pointer-events:none}
.page-list .page-select{display:flex;flex-direction:row;align-items:center;justify-content:space-between;gap:8px;width:100%;min-height:38px;padding:4px 6px;border:0;background:transparent;text-align:left;font-weight:400}
.page-list .page-select:hover:not(:disabled){background:rgba(11,92,173,.08);border-color:transparent}
.page-list .page-select b{min-width:0;overflow-wrap:anywhere;font-size:15px;font-weight:500;line-height:1.35;text-align:left}
.page-list .page.active .page-select b{color:var(--primary-dark);font-weight:700}
/* ---- 7. 編集エリア ---- */
main.editor{padding:16px 20px 20px;overflow:auto;min-width:0}
.editor .editor-panel{padding:20px 20px 0;background:var(--surface);border:1px solid var(--line);border-radius:8px}
.editor .editor-head h2{margin:0;font-size:20px;line-height:1.35;overflow-wrap:anywhere}
.editor .editor-head .hint{margin:4px 0 16px}
.editor .include-bar{margin-bottom:16px;padding:10px 14px;background:#f6f8fa;border:1px solid var(--line);border-radius:8px}
.editor .include-bar .hint{margin:4px 0 0 30px}
.editor .include-toggle{display:flex;align-items:center;gap:10px;font-weight:700;cursor:pointer}
.editor .include-toggle input{--sw-w:38px;--sw-h:22px;appearance:none;-webkit-appearance:none;box-sizing:border-box;position:relative;flex:none;width:var(--sw-w);height:var(--sw-h);margin:0;border:1px solid var(--field-line);border-radius:20px;background:var(--disabled-bg);cursor:pointer;transition:background .15s}
.editor .include-toggle input::after{content:"";position:absolute;left:2px;top:2px;width:calc(var(--sw-h) - 6px);height:calc(var(--sw-h) - 6px);border-radius:50%;background:var(--surface);box-shadow:0 1px 3px #0003;transition:transform .15s}
.editor .include-toggle input:checked{background:var(--primary);border-color:var(--primary)}
.editor .include-toggle input:checked::after{transform:translateX(calc(var(--sw-w) - var(--sw-h)))}
.editor .include-toggle input:focus-visible{outline:2px solid var(--focus);outline-offset:2px}
@media (prefers-reduced-motion: reduce) {.editor .include-toggle input, .editor .include-toggle input::after {transition:none}}
.editor .is-excluded .include-bar{background:var(--warn-soft);border-color:#d99a3a}
.editor .form-body{min-width:0;margin:0;padding:0;border:0}
.editor .is-excluded .form-body{opacity:.55;filter:grayscale(1)}
.editor .form-group{min-width:0;margin:0 0 16px;padding:14px 16px 16px;border:1px solid var(--line-soft);border-radius:8px}
.editor .form-group>legend{padding:0 8px;font-weight:700;color:var(--primary)}
.editor .form-group>.hint{margin-top:0}
.editor .grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:12px 16px}
.editor .wide{grid-column:1/-1}
.editor .card{margin:0 0 12px;padding:12px 14px;background:#fafbfc;border:1px solid var(--line);border-radius:8px}
.editor .card .field+.field{margin-top:10px}
.editor .card-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:8px}
.editor .card-no{font-size:13px;font-weight:700;color:var(--muted)}
.editor .table-wrap{max-width:100%;margin-bottom:12px;overflow-x:auto;border:1px solid var(--line);border-radius:6px}
.edit-table{width:100%;min-width:660px;border-collapse:collapse;font-size:14px}
.edit-table th,.edit-table td{padding:6px 8px;border-bottom:1px solid var(--line-soft);text-align:left}
.edit-table th{background:#f1f4f7;font-weight:700;white-space:nowrap}
.edit-table th:first-child,.edit-table td:first-child{width:48px;text-align:center}
.edit-table td.empty{width:auto;padding:16px;color:var(--muted);text-align:center}
.edit-table td input{width:100%;min-width:140px;min-height:36px;padding:6px 8px;border:1px solid var(--field-line);border-radius:4px;font:inherit}
.edit-table td input:disabled{background:#eceff2;color:#7b8696;border-color:var(--line)}
.signature-editor{margin-top:12px}
.signature-note{margin:0 0 12px;font-size:13px;color:var(--muted)}
.signature-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:12px;margin-top:12px}
.signature-card{padding:12px;background:#fafbfc;border:1px solid var(--line);border-radius:8px}
.signature-card h4{margin:0 0 10px;font-size:14px}
.signature-card .field+.field{margin-top:8px}
.stamp-actions{display:flex;flex-wrap:wrap;align-items:center;gap:6px;margin-top:10px}
.stamp-preview{width:54px;height:54px;object-fit:contain;border:1px dashed #aaa;background:#fff}
/* ---- 8. プレビュー（外側の枠だけ。帳票本体には触れない） ---- */
.preview{min-width:0;padding:0 16px 16px;overflow:auto;background:#d9dfe6;border-left:1px solid var(--line)}
.preview-head{position:sticky;top:0;z-index:2;display:flex;align-items:center;flex-wrap:wrap;gap:10px;padding:12px 0 10px;background:#d9dfe6}
.preview-head b{font-size:15px}
/* ---- 9. ダイアログ・処理中 ---- */
dialog.ui{width:min(520px,calc(100vw - 32px));padding:0;border:1px solid var(--line);border-radius:10px;color:var(--text);box-shadow:0 12px 40px rgba(0,0,0,.28)}
dialog.ui::backdrop{background:rgba(16,33,58,.45)}
dialog.ui .dlg-body{padding:20px 24px 8px}
dialog.ui h2{margin:0 0 8px;font-size:18px}
dialog.ui .dlg-actions{display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px;padding:14px 24px;background:#f6f7f9;border-top:1px solid var(--line-soft);border-radius:0 0 10px 10px}
#busy{position:fixed;inset:0;z-index:30;display:grid;place-items:center;background:#0008}
#busy:focus{outline:0}
#busy>div{display:grid;gap:10px;width:min(380px,calc(100vw - 32px));padding:24px;background:#fff;border-radius:8px;color:var(--text)}
#busy b{font-size:17px}
#busy progress{width:100%;height:14px}
#busy #busyText{font-size:13px;color:var(--muted);overflow-wrap:anywhere}
#busy small{color:var(--muted)}
/* ---- 10. 中幅（1200px以下：編集/プレビュー切替）・狭幅（800px以下：ページ全体を縦スクロール） ---- */
@media (max-width:1200px){
  .viewbar{display:flex;align-items:center;flex-wrap:wrap;gap:8px;flex:none;position:sticky;top:0;z-index:5;padding:8px 16px;background:var(--surface);border-bottom:1px solid var(--line)}
  .viewbar #toggleList{display:none;max-width:100%;overflow:hidden}
  .viewbar #toggleList span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  .viewbar .seg{display:inline-flex}
  .viewbar .seg button{border-radius:0}
  .viewbar .seg button:first-child{border-radius:var(--radius) 0 0 var(--radius)}
  .viewbar .seg button:last-child{margin-left:-1px;border-radius:0 var(--radius) var(--radius) 0}
  .viewbar .seg button[aria-pressed="true"]{background:var(--primary);border-color:var(--primary);color:#fff;font-weight:700}
  .viewbar .seg button[aria-pressed="true"]::before{content:"✓"}
  .viewbar .seg button[aria-pressed="true"]:hover:not(:disabled){background:var(--primary-dark);border-color:var(--primary-dark)}
  .layout{grid-template-columns:260px minmax(0,1fr)}
  .layout[data-view="edit"] .preview{display:none}
  .layout[data-view="preview"] main{display:none}
  .layout[data-view="preview"] .preview{display:block}
}
@media (max-width:800px){
  body{display:block;height:auto;overflow:visible}
  .layout{display:block}
  .app-header{padding:8px 12px}
  .app-header .brand{flex:1 0 100%}
  .viewbar{padding:8px 12px}
  .viewbar #toggleList{display:inline-flex}
  .layout[data-list="closed"] aside{display:none}
  .page-list{max-height:55vh;border-right:0;border-bottom:1px solid var(--line)}
  main.editor{padding:12px;overflow:visible}
  .editor .editor-panel{padding:16px 14px 0}
  .preview{padding:0 12px 16px;border-left:0}
  .preview-head{position:static;padding:12px 0 8px}
  dialog.ui .dlg-body{padding:16px 16px 8px}
  dialog.ui .dlg-actions{padding:12px 16px}
}
/* ---- 11. PDF生成時：プレビューが非表示の画面でも、画面外で描画して出力する（処理中表示の下。終了後は元に戻る） ---- */
}
/* Shared compact UI preferences; warnings remain visible when editing is disabled. */
@media screen {
  .preview {overflow:hidden}
  #preview {display:flex;flex-direction:column;align-items:center;gap:12px;min-width:0}
  .preview-sheet {aspect-ratio:210/297;background:white;border:1px solid #bdc6d0;overflow:hidden}
  .preview-status {text-align:center;color:var(--muted);padding:24px}
}
.pagination-capture {position:absolute;left:-20000px;top:0;width:210mm;pointer-events:none;background:white}
.pagination-capture .a4 {margin:0;box-shadow:none}
/* Font-independent grip. */
.drag-handle {font-size:0!important}
.drag-handle::before {content:"";display:block;width:10px;height:16px;background:radial-gradient(circle,#718096 1.2px,transparent 1.5px) 0 0/5px 5px}
/* Unified editor: explicit relationships, restrained secondary actions. */
@media screen {
  .editor {container-type:inline-size}
  .editor .editor-head {display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:24px}
  .editor .editor-heading {min-width:0;flex:1}
  .editor .editor-head h2 {font-size:19px;line-height:1.5}
  .editor .editor-head .hint {margin:8px 0 0}
  .editor .include-bar {flex:none;margin:0;padding:0;background:none;border:0;border-radius:0}
  .editor .include-toggle {min-height:32px;gap:8px;font-size:13px;font-weight:500;white-space:nowrap}
  .editor .include-toggle input {--sw-w:34px;--sw-h:20px}
  .editor .is-excluded .include-bar {background:none}
  .editor .include-message {margin:0 0 16px;padding:10px 12px;border-radius:6px;background:var(--warn-soft);font-size:13px}
  .editor .editor-panel:not(.is-excluded) .include-message {background:var(--primary-soft)}
  .editor .grid {grid-template-columns:repeat(2,minmax(0,1fr));gap:16px}
  .editor .form-group {padding:0 0 24px;margin:0 0 24px;border:0;border-bottom:1px solid var(--line-soft);border-radius:0}
  .editor .form-group:last-child {padding-bottom:0;border-bottom:0;margin-bottom:0}
  .editor .form-group>legend {padding:0;margin-bottom:16px;color:var(--text);font-size:15px}
  .editor .field>span {font-size:14px;font-weight:500;display:flex;align-items:center;justify-content:space-between;gap:8px}
  .editor .field-unit {font-size:13px;color:var(--muted);font-weight:400}
  .editor .field input,.editor .field select {min-height:44px;border-color:#aeb9c6;background:white}
  .editor .field textarea {min-height:180px;border-color:#aeb9c6;resize:vertical;line-height:1.7}
  .editor .period-block+.period-block {margin-top:20px}
  .editor .period-block h3 {margin:0 0 8px;font-size:14px;font-weight:600}
  .editor .date-range {display:grid;grid-template-columns:minmax(0,1fr) 16px minmax(0,1fr);align-items:end;gap:8px}
  .editor .range-separator {align-self:end;padding-bottom:11px;text-align:center;color:var(--muted)}
  .editor .card {padding:16px;background:white;border-color:var(--line-soft);margin-bottom:16px}
  .editor .add-action {border-style:dashed;width:100%;min-height:44px;color:var(--primary);background:#f8fafc}
  .editor .signature-grid {grid-template-columns:repeat(2,minmax(0,1fr))}
  .editor .signature-card {background:white;border-color:var(--line-soft);min-width:0}
  .editor .stamp-actions button {min-height:44px;padding:6px 10px}
  .editor .form-empty {padding:24px;background:#f7f9fb;border:1px solid var(--line-soft);border-radius:8px;text-align:center}
  .editor .form-empty strong {font-size:15px}
  .editor .form-empty p {margin:8px 0 0;font-size:14px;color:var(--muted)}
  .edit-table td input {min-height:44px}
  .edit-table th:nth-child(2) {width:28%}
  .edit-table th:nth-child(3) {width:36%}
}
@container (max-width:440px) {
  .editor .editor-head {flex-direction:column;gap:8px;margin-bottom:20px}
  .editor .grid,.editor .signature-grid {grid-template-columns:minmax(0,1fr)}
  .editor .date-range {grid-template-columns:minmax(0,1fr);gap:12px}
  .editor .range-separator {display:none}
  .editor .table-wrap {border:0;overflow:visible}
  .edit-table,.edit-table tbody,.edit-table tr,.edit-table td {display:block;width:100%;min-width:0}
  .edit-table thead {position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}
  .edit-table tr {padding:12px;border:1px solid var(--line-soft);border-radius:8px;margin-bottom:12px}
  .edit-table td {padding:6px 0;border:0}
  .edit-table td:first-child {width:auto;text-align:left;color:var(--muted);font-weight:600}
  .edit-table td[data-label]::before {content:attr(data-label);display:block;font-size:14px;margin-bottom:6px}
  .edit-table td input {min-width:0}
  .edit-table td:last-child {text-align:right}
}
@media screen {
  .edit-table td textarea {width:100%;min-width:140px;min-height:64px;padding:8px;border:1px solid #aeb9c6;border-radius:4px;font:inherit;line-height:1.5;resize:vertical;background:white}
  .edit-table td {vertical-align:top}
  .editor .include-toggle {min-height:44px}
}
@container (max-width:440px) {
  .edit-table td textarea {min-width:0;min-height:80px}
}
@media screen {.editor .field textarea {min-height:112px}}
@media screen {
  .editor .form-body[data-type="attachment"] .grid>.field {grid-column:1/-1}
  .edit-table button {white-space:nowrap;min-height:44px}
  .edit-table th:last-child,.edit-table td:last-child {min-width:76px}
}
@media screen {.editor .card-head button {min-height:44px}}
@media screen and (max-width:800px) {
  .app-header {gap:6px;padding:8px 12px}
  .app-header .brand {flex-basis:100%;margin-bottom:4px}
  .app-header .hgroup {display:contents}
  .app-header button {font-size:13px;min-height:40px;padding:6px 10px}
}
/* Identical unscaled physical sheet in live preview and export. */
.pdf-sheet {width:210mm;height:297mm;position:relative;overflow:hidden;background:white;color:#111;transform-origin:top left}
.sheet-window {position:absolute;left:0;width:210mm;overflow:hidden}
.sheet-source {position:absolute;left:0;width:210mm}
.sheet-source .a4 {margin:0!important;box-shadow:none}
.sheet-number {position:absolute;bottom:4mm;left:0;width:100%;box-sizing:border-box;text-align:center;font:9pt Arial,sans-serif;color:#505050}
#preview .placed-image {position:relative;user-select:none;-webkit-user-select:none;cursor:grab}
#preview .placed-image.is-moving {opacity:.4;cursor:grabbing}
#preview .placed-image img {-webkit-user-drag:none;user-drag:none}
#preview .placed-image:focus-visible {outline:2px solid var(--accent);outline-offset:3px}
#preview .placed-image.is-resizing {outline:1px dashed var(--accent)}
/* 選んだ画像の枠と角のハンドル（画面だけ。--k は紙の拡大率の逆数で、見た目の寸法を一定にする） */
.img-frame {position:absolute;box-sizing:border-box;outline:calc(var(--k,1) * 2px) solid var(--accent);outline-offset:0;box-shadow:inset 0 0 0 calc(var(--k,1) * 1px) #fff;pointer-events:none;z-index:5}
.img-frame[hidden] {display:none}
.img-handle {position:absolute;box-sizing:border-box;width:calc(var(--k,1) * 24px);height:calc(var(--k,1) * 24px);transform:translate(-50%,-50%);pointer-events:auto;touch-action:none;background:transparent}
.img-handle::after {content:"";position:absolute;left:calc(var(--k,1) * 8px);top:calc(var(--k,1) * 8px);right:calc(var(--k,1) * 8px);bottom:calc(var(--k,1) * 8px);box-sizing:border-box;background:#fff;border:calc(var(--k,1) * 2px) solid var(--accent);border-radius:calc(var(--k,1) * 2px)}
.img-handle[data-corner="nw"],.img-handle[data-corner="se"] {cursor:nwse-resize}
.img-handle[data-corner="ne"],.img-handle[data-corner="sw"] {cursor:nesw-resize}
.img-handle[data-corner="nw"] {left:0;top:0}
.img-handle[data-corner="ne"] {left:100%;top:0}
.img-handle[data-corner="sw"] {left:0;top:100%}
.img-handle[data-corner="se"] {left:100%;top:100%}
/* 移動：挿入線（用紙の中・画面の拡大率に合わせた太さ）、仮の画像（画面の上に出す・本文は変えない）、取消・結果の文言 */
.img-drop-line {position:absolute;height:calc(var(--k,1) * 3px);transform:translateY(-50%);background:var(--accent);border-radius:calc(var(--k,1) * 2px);pointer-events:none;z-index:4}
.img-drop-line[data-state="same"] {background:#6b7280}
.img-drop-line[data-orient="v"] {width:calc(var(--k,1) * 4px);height:auto;transform:translateX(-50%);border-radius:calc(var(--k,1) * 2px);box-shadow:0 0 0 calc(var(--k,1) * 1.5px) rgba(255,255,255,.85)}   /* 横並びへの挿入線は太く、白の縁で明暗どちらの画像にも見えるように */
.img-drop-line[hidden] {display:none}
.preview-viewport .placed-row {position:relative}
.row-split {position:absolute;top:0;height:100%;width:10px;cursor:col-resize;z-index:5;touch-action:none;user-select:none}
/* 横並びの移動の取っ手（⠿・行の左の外側の上）。行の上へ寄せた時・押している時に濃くする（プレビューだけ。PDFには出ない） */
.preview-viewport .placed-row>.row-grip{position:absolute;left:-30px;top:0;z-index:6;width:24px;height:24px;padding:0;border:0;border-radius:5px;background:transparent;color:var(--muted);opacity:.4;cursor:grab;touch-action:none;user-select:none;display:flex;align-items:center;justify-content:center;transition:opacity .12s,background .12s}
.preview-viewport .placed-row>.row-grip svg{width:16px;height:16px;fill:currentColor;pointer-events:none}
.preview-viewport .placed-row:hover>.row-grip,.preview-viewport .row-grip:hover,.preview-viewport .row-grip:focus-visible{opacity:1}
.preview-viewport .row-grip:hover{background:var(--surface-soft)}
.preview-viewport .row-grip:active{cursor:grabbing}
.row-split::after {content:"";position:absolute;left:4px;top:0;bottom:0;width:2px;border-radius:1px;background:var(--accent);opacity:0;transition:opacity .12s}
.row-split:hover::after,.row-split.is-drag::after {opacity:.9}
.img-ghost {position:fixed;z-index:60;width:96px;box-sizing:border-box;padding:4px;background:#fff;border:2px solid var(--accent);border-radius:6px;box-shadow:0 4px 14px rgba(0,0,0,.25);pointer-events:none;opacity:.92}
.img-ghost img {display:block;width:100%;height:auto;border-radius:3px}
.img-ghost span {position:absolute;left:0;top:100%;margin-top:4px;white-space:nowrap;font-size:12px;line-height:1.4;padding:2px 6px;border-radius:4px;background:var(--accent);color:#fff}
.img-ghost[data-state="same"] {border-color:#6b7280}
.img-ghost[data-state="same"] span {background:#6b7280}
.img-ghost[data-state="invalid"] {border-color:#b42318}
.img-ghost[data-state="invalid"] span {background:#b42318}
.img-move-msg {position:fixed;left:50%;bottom:16px;transform:translateX(-50%);z-index:61;max-width:min(90vw,560px);margin:0;padding:8px 14px;border-radius:8px;background:#1f2937;color:#fff;font-size:13px;line-height:1.5;pointer-events:none}
.img-move-msg[hidden] {display:none}
@media screen {
  .preview-sheet {position:relative;border:0}
  main.editor {padding:12px}
  .editor .editor-panel {padding:14px 16px 0}
  .editor .editor-head {margin-bottom:12px;gap:12px}
  .editor .editor-head h2 {font-size:18px}
  .editor .form-group {margin-bottom:12px;padding-bottom:12px}
  .editor .form-group>legend {margin-bottom:8px}
  .editor .grid {gap:8px 12px}
  .editor .field>span {font-size:13px;margin-bottom:4px}
  .editor .field input,.editor .field select {min-height:36px;padding:6px 8px;font-size:14px}
  .editor .period-block {display:grid;grid-template-columns:108px minmax(0,1fr);align-items:center;gap:8px}
  .editor .period-block h3 {margin:0;font-size:13px;font-weight:500}
  .editor .period-block+.period-block {margin-top:8px}
  .editor .date-range .field>span {position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}
  .editor .date-range {align-items:center;gap:6px;grid-template-columns:minmax(0,1fr) 12px minmax(0,1fr)}
  .editor .range-separator {padding:0;align-self:center}
  .editor .card {padding:12px;margin-bottom:10px}
  .editor .card-head {margin-bottom:6px}
  .editor .card .field+.field {margin-top:8px}
  #state[data-status="error"] {color:var(--danger);background:var(--danger-soft);border-color:var(--danger)}
}
@container (min-width:640px) {
  .editor .form-body[data-type="overview"] .grid {grid-template-columns:repeat(2,minmax(0,1fr))}
  .editor .form-body[data-type="overview"] .grid>.wide {grid-column:auto}
  .editor .form-body[data-type="overview"] .form-group:last-child .grid {grid-template-columns:repeat(4,minmax(0,1fr))}
  .editor .form-body[data-type="overview"] .form-group:last-child .grid>.wide {grid-column:span 2}
}
@container (max-width:440px) {
  .editor .editor-head {margin-bottom:12px}
  .editor .period-block {grid-template-columns:minmax(0,1fr);gap:6px}
  .editor .date-range {grid-template-columns:minmax(0,1fr) 12px minmax(0,1fr)}
  .editor .range-separator {display:block}
  .editor .date-range input {min-width:0;font-size:12px;padding:6px}
}
@container (max-width:440px) {
  .editor .editor-head {flex-direction:row;align-items:center;flex-wrap:wrap;gap:8px}
  .editor .editor-heading {min-width:140px}
}
@media screen {
  .essential-note{font-size:13px;line-height:1.5;color:var(--muted);margin:8px 0 0}
  .editor .signature-note{margin:8px 0}
  .editor .signature-card{padding:10px}
  .editor .signature-card h4{font-size:13px;color:var(--muted);margin:0 0 6px}
  .editor .signature-fields{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:8px}
  .editor .signature-card .field+.field{margin-top:0}
  .editor .signature-meta{display:grid;grid-template-columns:minmax(120px,1fr) auto;gap:8px;align-items:end;margin-top:8px}
  .editor .signature-card .field input{min-height:32px;padding:4px 6px;font-size:13px}
  .editor .signature-card .field>span{font-size:12px;margin-bottom:3px}
  .editor .signature-card .stamp-actions{margin:0;gap:4px;justify-content:flex-end}
  .editor .signature-card .stamp-actions button{min-height:34px;padding:4px 8px;font-size:12px}
  .editor .signature-card .stamp-preview{width:30px;height:30px}
  .preview-viewport{width:100%;overflow:auto;overscroll-behavior:contain;touch-action:pan-x pan-y;cursor:grab}
  .preview-viewport.panning{cursor:grabbing;user-select:none}
  .preview-stage{position:relative;display:flex;justify-content:center;align-items:flex-start;padding:0 8px}
  .preview-sheet{flex:none}
  .sheet-pager{display:flex;align-items:center;gap:8px}
  dialog.ui.pdf-viewer-dialog{width:94vw;height:94vh;max-width:1500px;max-height:none;padding:0;border:1px solid var(--line);border-radius:8px}
  .pdf-viewer-dialog[open]{display:flex;flex-direction:column}
  .pdf-viewer-dialog::backdrop{background:rgba(16,33,58,.5)}
  .pdf-viewer-toolbar{display:flex;align-items:center;gap:12px;padding:10px 16px;border-bottom:1px solid var(--line);flex:none}
  dialog.ui.pdf-viewer-dialog .pdf-viewer-toolbar h2{font-size:16px;margin:0;flex:1}
  .pdf-viewer-toolbar a{font-size:14px;color:var(--primary);white-space:nowrap}
  #viewerStatus{padding:10px 16px;font-size:14px;color:var(--muted)}
  #viewerProgress{width:calc(100% - 32px);margin:0 16px 16px}
  #pdfViewerFrame{width:100%;flex:1;min-height:0;border:0;background:#525659}
}
@container (max-width:440px){
  .editor .signature-grid{grid-template-columns:minmax(0,1fr)}
  .editor .signature-meta{grid-template-columns:minmax(0,1fr) auto}
}
@media screen and (max-width:600px){
  dialog.ui.pdf-viewer-dialog{width:98vw;height:96vh}
  .pdf-viewer-toolbar{gap:8px;flex-wrap:wrap;padding:8px}
  dialog.ui.pdf-viewer-dialog .pdf-viewer-toolbar h2{flex-basis:100%}
  .pdf-viewer-toolbar #viewerClose{margin-left:auto}
}
.editor .signature-card .stamp-actions{flex-wrap:nowrap}
.editor .signature-card .stamp-actions button{display:inline-flex;align-items:center;gap:4px;white-space:nowrap}
.editor .signature-card .stamp-actions .stamp-preview{width:18px;height:18px;object-fit:contain;margin:0}
/* One visual language for actions, preserving labels on primary controls. */
.ui button,.pdf-viewer-toolbar a{display:inline-flex;align-items:center;justify-content:center;gap:6px}
.action-icon{width:18px;height:18px;flex:none;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;pointer-events:none}
.ui button.icon-only{min-width:40px;min-height:40px;padding:8px}
.editor .signature-card .stamp-actions button.icon-only{min-width:34px;min-height:34px;padding:6px}
.editor .signature-card .stamp-actions .action-icon{width:16px;height:16px}
/* Insertion controls occupy fixed slots; revealing them never moves page rows. */
#pages .page{position:relative}
#pages .drag-handle{opacity:0;transition:opacity .12s}
#pages .page:hover .drag-handle,#pages .page:focus-within .drag-handle,#pages .page.dragging .drag-handle{opacity:1}
.insert-slot{position:relative;height:10px;display:flex;justify-content:center;z-index:2}
.ui .insert-slot .insert-page{position:absolute;top:-12px;min-height:32px;width:32px;padding:4px;background:white;color:var(--accent,#075bb5);border-radius:50%;opacity:0;pointer-events:none}
.insert-slot:hover .insert-page,.insert-slot:focus-within .insert-page{opacity:1;pointer-events:auto}
.insert-slot:has(+.page:hover) .insert-page{opacity:1;pointer-events:auto}
.media-tools{display:flex;align-items:center;gap:8px;margin-top:12px;flex-wrap:wrap}
.media-item{display:flex;align-items:center;gap:8px;border:1px solid var(--line);border-radius:8px;padding:8px;margin:8px 0}
.media-item .ic-fit{width:64px;height:48px;background:#f4f6f8;flex:0 0 auto;border-radius:4px}
.media-item span{flex:1;min-width:0;overflow-wrap:anywhere;font-size:13px}
.media-progress{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:8px 16px;border-top:1px solid var(--line)}
.media-progress[hidden]{display:none}
#insertSectionField[hidden]{display:none}
@media (hover:none){#pages .drag-handle,.ui .insert-slot .insert-page{opacity:1;pointer-events:auto}}
@media (prefers-reduced-motion:reduce){#pages .drag-handle{transition:none}}
#pages .page{margin-top:2px;margin-bottom:2px}
.insert-slot{height:6px}
.ui .insert-slot .insert-page{min-width:32px;min-height:32px}
.insert-slot:first-child{margin-top:12px}/* Row-local actions; no fixed add/delete buttons above the list. */
.page-list .side-head{padding-bottom:12px}
.chapter-add{padding:12px 0 20px}
.chapter-add button{width:100%;border-style:dashed}
#pages .page{grid-template-columns:28px minmax(0,1fr) 36px}
.ui .page-remove{width:32px;min-width:32px;min-height:32px;padding:6px;opacity:0;pointer-events:none;color:#c52626}
#pages .page:hover .page-remove,#pages .page:focus-within .page-remove{opacity:1;pointer-events:auto}
.insert-slot:first-child{margin-top:0}
.insert-slot:has(+.page:hover) .insert-page{opacity:0;pointer-events:none}
.page:hover+.insert-slot .insert-page,.insert-slot:hover .insert-page,.insert-slot:focus-within .insert-page{opacity:1;pointer-events:auto}
.editor .include-bar{display:flex;align-items:center;gap:8px}
.preview-sheet{aspect-ratio:auto}
.original-pdf-sheet>img{display:block;width:100%;height:100%;object-fit:fill}
@media (hover:none){#pages .page-remove,.ui .insert-slot .insert-page{opacity:1;pointer-events:auto}}
/* Full-width names with compact overlay actions. */
#pages .page{display:block;position:relative}
#pages .page-select{width:100%;padding:10px 12px;text-align:left}
#pages .drag-handle{position:absolute;left:2px;top:50%;transform:translateY(-50%);z-index:2;background:var(--panel,#fff)}
.ui #pages .page-remove{position:absolute;right:3px;top:50%;transform:translateY(-50%);width:24px;min-width:24px;min-height:24px;height:24px;padding:3px;border:0;background:var(--panel,#fff);z-index:2}
.ui .insert-slot .insert-page{width:24px;min-width:24px;min-height:24px;height:24px;padding:3px;border:0;background:transparent;box-shadow:none}
.ui #pages .page-remove svg,.ui .insert-slot .insert-page svg{width:14px;height:14px}
#pages .chapter-label{display:flex;align-items:center;gap:2px}
.ui .chapter-label button{border:0;background:transparent;min-width:24px;min-height:28px;padding:3px;font-size:12px}
.ui .chapter-label .chapter-toggle{flex:1;text-align:left;font-weight:600}
#includeToggle~span{white-space:nowrap}
#copy[hidden]{display:none!important}
.ui .chapter-label .chapter-toggle{justify-content:flex-start;display:flex;gap:4px}
#pageTitleInput{font:inherit;font-weight:700;color:inherit;width:100%;min-width:0;background:transparent;border:1px solid transparent;padding:2px 4px;margin-left:-4px;border-radius:4px}
#pageTitleInput:hover{border-color:var(--line)}
#pageTitleInput:focus{border-color:var(--primary);outline:2px solid var(--primary)}
.editor-heading{flex:1;min-width:0}
#pages .page.excluded .page-select b{text-decoration:line-through}
#messageDlg{width:min(460px,calc(100vw - 24px))}
#messageField[hidden],#messageCancel[hidden]{display:none}
#messageText{white-space:pre-wrap;overflow-wrap:anywhere}
.chapter-grip{font-size:14px;cursor:grab;opacity:0}
.chapter-label:hover .chapter-grip,.chapter-label:focus-within .chapter-grip{opacity:1}
.ui .chapter-label button[data-chapter-up],.ui .chapter-label button[data-chapter-down]{opacity:0;font-size:14px;padding:2px;min-width:20px}
.chapter-label:hover button[data-chapter-up],.chapter-label:hover button[data-chapter-down],.chapter-label:focus-within button[data-chapter-up],.chapter-label:focus-within button[data-chapter-down]{opacity:1}
@media(hover:none){.chapter-grip,.ui .chapter-label button[data-chapter-up],.ui .chapter-label button[data-chapter-down]{opacity:1}}
.chapter-grip{display:inline-flex;align-items:center}.chapter-grip svg{pointer-events:none}
/* Chapter dragging temporarily hides contents without changing fold state. */
#pages.chapters-dragging>.page:not(.page-fixed),#pages.chapters-dragging>.insert-slot{display:none}
#pages.chapters-dragging .chapter-label{position:relative;margin:12px 0;min-height:38px;border:1px solid var(--line);border-radius:5px;padding:4px;background:#fff}
#pages.chapters-dragging .chapter-toggle[aria-expanded="true"]>svg{transform:rotate(-90deg)}
#pages.chapters-dragging .chapter-grip{opacity:1}
#pages.chapters-dragging .chapter-drag-source{opacity:.45;background:#e6f0fb}
#pages{position:relative}
.chapter-grip{touch-action:none;user-select:none}
.chapter-insertion-line{position:absolute;left:0;right:0;top:0;height:3px;background:#0868cd;border-radius:2px;pointer-events:none;z-index:5;will-change:transform}
.chapter-insertion-line[hidden]{display:none}
.chapter-drag-ghost{position:fixed;left:0;top:0;z-index:10000;max-width:280px;pointer-events:none;background:#fff;border:1px solid #0868cd;border-radius:5px;padding:8px 12px;font-size:13px;font-weight:600;box-shadow:0 3px 12px #1233;will-change:transform}
#editTitle:has(#pageTitleInput){display:flex;align-items:center;gap:6px}
.page-auto-number{flex-shrink:0}
#editTitle #pageTitleInput{flex:1;width:0;margin-left:0}
/* Chapter management appears only on hover or keyboard focus. */
.ui .chapter-label [data-rename],.ui .chapter-label [data-chapter-remove]{opacity:0;pointer-events:none}
.ui .chapter-label:hover [data-rename],.ui .chapter-label:hover [data-chapter-remove],.ui .chapter-label:focus-within [data-rename],.ui .chapter-label:focus-within [data-chapter-remove]{opacity:1;pointer-events:auto}
.preview-head #pagePdf{margin-left:auto;flex-shrink:0;width:32px;min-width:32px;height:32px;min-height:32px;padding:7px;background:#fff}
.preview-head #pagePdf svg{width:16px;height:16px}
.editor .editor-panel{padding-bottom:14px}
/* Unified pane headers: list, editor, and preview. */
main.editor{padding:0 0 16px}
.editor .editor-panel{margin:12px 16px 0;padding:14px 16px;background:var(--surface)}
.preview{padding:0}
#preview{margin:12px 16px 16px}
.page-list .pane-header,.editor>.pane-header,.preview>.pane-header{position:sticky;top:0;z-index:3;display:flex;flex-direction:row;align-items:center;flex-wrap:nowrap;gap:10px;height:56px;min-height:56px;margin:0;padding:0 16px;background:var(--surface);border-bottom:1px solid var(--line);font-size:15px;font-weight:700;box-sizing:border-box}
.page-list .side-title{margin:0;font-size:15px;line-height:1.4}
.editor .pane-header .editor-heading{min-width:0;flex:1}
.editor .pane-header h2{font-size:15px;line-height:1.4;margin:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.editor .pane-header .include-bar{margin:0;padding:0;border:0;background:transparent;flex-shrink:0;gap:8px}
.editor .pane-header .include-toggle{font-size:12px;font-weight:400;gap:6px}
.editor .pane-header #copy{width:32px;min-width:32px;min-height:32px;height:32px;padding:7px}
.editor .pane-header #copy svg{width:16px;height:16px}
.editor .pane-header #pageTitleInput{font-size:15px}
.preview .pane-header b{font-size:15px;line-height:1.4}
@media(max-width:800px){.page-list .pane-header,.editor>.pane-header,.preview>.pane-header{padding:0 12px}.editor .editor-panel{margin:12px;padding:14px}.editor .pane-header .include-bar{gap:5px}#preview{margin:12px}}
/* UI themes. Paper/capture geometry and report CSS stay unchanged. */
:root{--surface-soft:#f3f5f8;--field-bg:#fff;--disabled-bg:#eceff2;--disabled-text:#7b8696;--preview-bg:#d9dfe6;--primary-ink:var(--primary-dark);--saved-soft:#e5f5ec;--panel:var(--surface);--accent:var(--primary)}
@media screen{
  :root{color-scheme:light}
  :root[data-theme="dark"]{color-scheme:dark;--bg:#111823;--surface:#1b2432;--surface-soft:#232e3e;--field-bg:#151e2b;--line:#3b485c;--line-soft:#303c50;--field-line:#64758e;--text:#e6edf7;--muted:#a8b6ca;--primary:#2563eb;--primary-dark:#1d4ed8;--primary-ink:#a7ccff;--primary-soft:#213b60;--danger:#ffaaa1;--danger-soft:#49262b;--ok:#a5e8bb;--warn:#ffdcaa;--warn-soft:#40321e;--focus:#8fbcff;--disabled-bg:#293343;--disabled-text:#93a2b7;--preview-bg:#0d141e;--saved-soft:#183b29;--accent:#a7ccff}
  body{color:var(--text)}
  .app-header .hgroup,dialog.ui .dlg-actions,.edit-table th{background:var(--surface-soft)}
  .ui .field :is(input,textarea,select),.editor .field :is(input,textarea,select),.editor .edit-table :is(input,textarea,select){background:var(--field-bg);color:var(--text);border-color:var(--field-line)}
  .ui button:disabled,.ui .field :is(input,textarea,select):disabled,.editor .field :is(input,textarea,select):disabled,.editor .edit-table :is(input,textarea,select):disabled{background:var(--disabled-bg);color:var(--disabled-text);border-color:var(--line)}
  .editor .card,.editor .signature-card,dialog.ui,#busy>div,.chapter-drag-ghost,#pages.chapters-dragging .chapter-label,.preview-head #pagePdf,.skip-link{background:var(--surface);color:var(--text)}
  .editor .add-action,.editor .form-empty{background:var(--surface-soft)}
  .editor .add-action,.editor .form-group>legend,.pdf-viewer-toolbar a{color:var(--primary-ink)}
  .page-list .page.excluded{background:var(--surface-soft)}
  .page-list .page.active,.page-list .page.excluded.active,#pages.chapters-dragging .chapter-drag-source{background:var(--primary-soft)}
  .page-list .page.active .page-select b{color:var(--primary-ink)}
  .ui #pages .page-remove{color:var(--danger)}
  .preview{background:var(--preview-bg)}
  #state[data-status="saved"]{background:var(--saved-soft)}
  .media-item .ic-fit,.stamp-preview{background:var(--surface-soft)}
  dialog.ui::backdrop{background:rgba(0,0,0,.55)}
  #themeStatus{display:block;font-size:12px;color:var(--warn);padding:4px}
  #themeStatus:empty{display:none}
  .pdf-sheet,.a4,.pagination-capture,.original-pdf-sheet,#pdfViewerFrame{color-scheme:light}
  .pdf-sheet,.a4,.pagination-capture,.original-pdf-sheet{background:#fff;color:#111}
}
@media print{html{color-scheme:light}body,.preview{background:#fff;color:#111}}
@media screen{.chapter-insertion-line{background:var(--focus)}.chapter-drag-ghost{border-color:var(--focus)}:root[data-theme="dark"] .page-list .page.active{border-color:var(--focus)}}
/* Pane scrollbars begin below their headers. */
@media screen{
 .app-header .brand{margin-right:auto;margin-left:0}
 .page-list,main.editor,.preview{overflow:hidden;padding:0;display:flex;flex-direction:column;min-height:0}
 .pane-header{flex:none}
 .list-scroll,.editor-scroll{flex:1;min-height:0;overflow:auto}
 .editor-scroll{padding-bottom:16px}
 .preview-actions{display:flex;gap:8px;margin-left:auto;flex-shrink:0}
 .preview-actions button{font-size:13px;padding:6px 8px;min-height:32px}
 .editor .pane-header #pagePdf{width:32px;min-width:32px;height:32px;min-height:32px;padding:7px}
 .editor .pane-header #pagePdf svg{width:16px;height:16px}
}
@media(max-width:800px){
 .app-header .brand{order:-1}
 .list-scroll{max-height:calc(55vh - 56px)}
 .editor-scroll{overflow:visible;flex:none}
 .preview>.pane-header{height:auto;min-height:56px;flex-wrap:wrap;padding-top:8px;padding-bottom:8px}
 .preview-actions{gap:4px}.preview-actions button{font-size:12px;padding:4px 6px}
}
/* Right sidebar: hidden initially, slide without reflowing the report. */
@media screen{
 .app-header .brand{order:0;margin-right:auto;flex:0 1 auto}
 .app-header #sidebarToggle{width:36px;min-width:36px;height:36px;padding:7px}
 .right-sidebar{position:fixed;right:0;top:0;bottom:0;width:min(340px,100vw);z-index:60;display:flex;flex-direction:column;background:var(--surface);color:var(--text);border-left:1px solid var(--line);box-shadow:-8px 0 24px #0003;transform:translateX(105%);visibility:hidden;transition:transform .22s ease,visibility .22s}
 .right-sidebar.open{transform:translateX(0);visibility:visible}
 .sidebar-backdrop{position:fixed;inset:0;border:0;background:#0004;z-index:59}
 .sidebar-head{height:56px;flex:none;display:flex;align-items:center;justify-content:space-between;padding:0 16px;border-bottom:1px solid var(--line)}
 .sidebar-head button,.history-head button{width:32px;height:32px;min-height:32px;padding:6px}
 .sidebar-settings{padding:16px;overflow:auto;flex:0 1 auto}
 .right-sidebar h3{font-size:14px;margin:0 0 10px}
 .sidebar-settings section+section{margin-top:22px}
 .sidebar-settings .hgroup{display:flex;align-items:center;flex-wrap:wrap;gap:8px}
 .theme-choices{display:flex;gap:8px}.theme-choices button{width:44px;height:38px;justify-content:center}
 .theme-choices button[aria-pressed=true]{color:var(--primary-ink);background:var(--primary-soft);border-color:var(--focus)}
 .history-panel{margin-top:auto;min-height:160px;flex:1;max-height:50%;display:flex;flex-direction:column;padding:16px;border-top:1px solid var(--line)}
 .history-head{display:flex;gap:6px;align-items:center;flex:none}.history-head h3{margin:0 auto 0 0}
 #historyList{list-style:none;margin:12px 0;padding:0;overflow:auto;min-height:0;flex:1;font-size:12px}
 #historyList li{padding:8px;border-bottom:1px solid var(--line-soft);overflow-wrap:anywhere}
 .history-current{background:var(--primary-soft);color:var(--primary-ink)}.history-undone{color:var(--muted);opacity:.6}
 .history-panel .hint{font-size:11px;flex:none}
}
@media(max-width:800px){.app-header .brand{flex:1 1 auto;font-size:15px}.app-header{gap:6px}.app-header .hgroup{padding:0;background:transparent}.app-header #new{font-size:12px;padding:6px}}
@media(prefers-reduced-motion:reduce){.right-sidebar{transition:none}}
@media print{.right-sidebar,.sidebar-backdrop{display:none!important}}
@media screen{.right-sidebar,.sidebar-backdrop{top:var(--app-header-height,62px)}}
@media screen{
 .app-header .brand{margin-right:0;flex:none}
 .app-header .hgroup[aria-label="新規作成"]{margin-right:auto}
 #autosaveStatus{font-size:12px;color:var(--muted);display:block;margin-top:8px}
 .sidebar-settings .hint{font-size:12px;line-height:1.5;color:var(--muted)}
}
@media(max-width:800px){.app-header .brand{flex:1 0 100%}.app-header .hgroup[aria-label="Excel"]{margin-left:auto}}
@media(max-width:800px){.app-header #sidebarToggle{margin-left:auto}}
/* Office-like compact autosave toolbar. */
@media screen{
 .office-save{display:flex;align-items:center;gap:10px;padding:5px 8px;border-radius:8px;background:var(--surface-soft);flex:none}
 .office-autosave{display:flex;align-items:center;gap:6px;font-size:14px;cursor:pointer;position:relative}
 .office-autosave input{position:absolute;opacity:0;width:1px;height:1px}
 .office-switch{display:flex;align-items:center;justify-content:flex-end;position:relative;width:58px;height:28px;padding:0 7px;background:var(--disabled-bg);border:1px solid var(--field-line);border-radius:20px;color:var(--text);font-size:12px}
 .office-switch::after{content:'';position:absolute;left:3px;top:3px;width:20px;height:20px;border-radius:50%;background:var(--surface);box-shadow:0 1px 3px #0003;transition:transform .18s}
 .office-autosave input:checked+.office-switch{background:#087d3e;border-color:#087d3e;color:#fff;justify-content:flex-start}
 .office-autosave input:checked+.office-switch::after{background:#fff;transform:translateX(29px)}
 .office-autosave input:focus-visible+.office-switch{outline:2px solid var(--focus);outline-offset:3px}
 .office-save #save{border:0;background:transparent;width:32px;min-width:32px;min-height:32px;height:32px;padding:5px;color:var(--text)}
 .office-save #save svg{width:22px;height:22px}
 .office-save #save:hover:not(:disabled){background:var(--primary-soft);color:var(--primary-ink)}
 .office-save #state{display:none}
}
@media(prefers-reduced-motion:reduce){.office-switch::after{transition:none}}
/* Preserve the app's existing component styling; only autosave is a switch. */
@media screen{
 .office-save{gap:8px;padding:4px 6px;background:var(--surface-soft)}
 .office-autosave{font-size:13px}
 .office-switch{width:38px;height:22px;padding:0;background:var(--disabled-bg);border-color:var(--field-line)}
 .office-switch::after{width:16px;height:16px;left:2px;top:2px;background:var(--surface)}
 .office-autosave input:checked+.office-switch{background:var(--primary);border-color:var(--primary)}
 .office-autosave input:checked+.office-switch::after{transform:translateX(16px)}
 .office-save #save{width:auto;min-width:0;height:auto;min-height:36px;padding:6px 12px;border:1px solid var(--primary);background:var(--primary);color:#fff;gap:6px;border-radius:6px}
 .office-save #save svg{width:16px;height:16px}
 .office-save #save:hover:not(:disabled){background:var(--primary-dark);border-color:var(--primary-dark);color:#fff}
 .office-save #save:disabled{background:var(--disabled-bg);border-color:var(--line);color:var(--disabled-text)}
}
/* Calm save controls and focused settings/history sidebar. */
@media screen{
 .office-save #save{border:1px solid var(--primary-ink);background:var(--surface);color:var(--primary-ink);font-weight:500}
 .office-save #save:hover:not(:disabled){background:var(--primary-soft);color:var(--primary-ink);border-color:var(--focus)}
 html[data-autosave="on"] #save{display:none!important}
 .app-header .hgroup[aria-label="新規作成"]{margin-right:0}
 .app-header #state{margin-right:auto;font-size:12px;font-weight:400;padding:0;color:var(--muted);background:none;border:none;border-radius:0}
 .app-header #state:not([data-status="saved"]){font-size:0}
 .app-header #state::before{content:none}
 .app-header .hgroup[aria-label="Excel"]{margin-left:auto}
 html[data-autosave="on"] .app-header #state{display:none}
 .sidebar-head{height:64px;gap:8px;padding:0 18px}
 .sidebar-head>.theme-choices{margin-right:auto;gap:5px}
 .theme-choices button{width:36px;min-height:36px;height:36px;padding:7px;background:transparent}
 .sidebar-settings{padding:0 18px;flex:none}
 .sidebar-appearance:has(#themeStatus:empty){display:none}
 .history-panel{margin-top:0;max-height:none;flex:1;padding:18px;min-height:0}
 .history-head{flex-wrap:wrap;gap:8px}
 .history-head h3{flex:1 0 100%;font-size:14px;margin-bottom:6px}
 .history-head button{width:auto;min-height:34px;height:34px;padding:6px 10px;gap:6px;font-size:13px;font-weight:600;background:var(--surface-soft);border-color:var(--line)}
 #historyList{display:flex;flex-direction:column;gap:7px;margin:14px 0;overflow:auto}
 #historyList li{position:relative;flex:none;padding:12px 10px;border:1px solid var(--line);border-left:3px solid var(--line);border-radius:8px;font-size:12px;background:var(--field-bg)}
 #historyList li b{display:block;line-height:1.5;margin-bottom:6px;font-weight:600}
 #historyList .history-meta{font-size:11px;color:var(--muted)}
 #historyList .history-current{border-color:var(--focus);border-left-color:var(--primary);color:var(--text);background:var(--primary-soft)}
 .history-badge{float:right;font-size:10px;background:var(--primary-soft);color:var(--primary-ink);padding:2px 5px;border-radius:4px}
}
@media screen{#historyList [data-history-cursor]{cursor:pointer}#historyList [data-history-cursor]:hover{border-color:var(--focus);background:var(--primary-soft)}#historyList [data-history-cursor]:focus-visible{outline:2px solid var(--focus);outline-offset:2px}html[data-autosave="on"] .save-action{display:none!important}}
/* Neutral workspace palette: accent reserved for actions and focus. */
@media screen{
 :root{--bg:#f6f6f5;--surface:#fff;--surface-soft:#f3f3f2;--field-bg:#fff;--line:#dededb;--line-soft:#eaeae7;--field-line:#c8c8c4;--text:#2c2c2b;--muted:#777772;--primary:#347bb7;--primary-dark:#28699e;--primary-ink:#28699e;--primary-soft:#edf4f9;--focus:#5595c7;--preview-bg:#ececeb}
 :root[data-theme="dark"]{--bg:#191919;--surface:#202020;--surface-soft:#292929;--field-bg:#1b1b1b;--line:#3d3d3b;--line-soft:#323230;--field-line:#50504d;--text:#ededeb;--muted:#a5a5a0;--primary:#477fac;--primary-dark:#3b6e98;--primary-ink:#a2bfd6;--primary-soft:#293138;--focus:#709cbf;--preview-bg:#161616;--disabled-bg:#30302e;--disabled-text:#8b8b86;--accent:#d2d2cf;--danger:#e69b94;--danger-soft:#3a2826;--ok:#a1c9ad;--warn:#dab48a;--warn-soft:#362e24;--saved-soft:#253129}
 .app-header{gap:8px 12px}.app-header .hgroup,.office-save{background:transparent;padding:0}
 .app-header .brand{font-size:16px;margin-right:12px}
 .office-save{gap:8px}.office-autosave{gap:8px;color:var(--muted)}
 .ui button{border-radius:6px}.ui button:not(.primary):not(.danger){border-color:var(--line)}
 .editor .editor-panel{border-color:var(--line);border-radius:8px;padding:16px 18px}
 .editor .form-group>legend{color:var(--text);font-size:14px}
 .editor .field :is(input,textarea,select){border-color:var(--field-line);border-radius:5px}
 .page-list .page{border-color:transparent;border-left-color:transparent;background:transparent;border-radius:6px}
 .page-list .page:hover{background:var(--surface-soft)}
 .page-list .page.active{background:var(--surface-soft);border-color:var(--line);border-left-color:var(--primary)}
 .page-list .page.active .page-select b{color:var(--text)}
 .page-list .page-select b{font-size:14px}.page-list .chapter-label{color:var(--muted)}
 .sidebar-head{border-bottom-color:var(--line-soft)}.right-sidebar{box-shadow:-4px 0 20px #0002;border-left-color:var(--line)}
 #historyList .history-current{background:var(--surface-soft);border-color:var(--field-line);border-left-color:var(--primary)}
 #historyList li{padding:12px;background:var(--surface);border-radius:7px}
 #historyList [data-history-cursor]:hover{background:var(--surface-soft);border-color:var(--field-line)}
 .history-head button{background:var(--surface-soft)}
 .history-badge{background:var(--primary-soft);color:var(--primary-ink)}
 .pane-header{color:var(--text)}
}
@media screen{:root{--primary:#2f73ad}:root[data-theme="dark"]{--primary:#3a7099}.sidebar-head .theme-choices button,.sidebar-head #sidebarClose{width:40px;height:40px;min-height:40px}.history-head button{min-height:40px;height:40px}#historyList li{font-size:13px}}
/* Clear chapter groups with a denser item rhythm. */
@media screen{
 .item-pager{display:flex;gap:4px;margin-left:auto}
 .ui .item-pager button{width:32px;min-width:32px;height:32px;min-height:32px;padding:7px;border-color:var(--line);background:transparent}
 #pages .chapter-label{margin:16px 0 6px;padding:5px 6px;min-height:34px;background:var(--surface-soft);border:1px solid var(--line-soft);border-radius:5px;color:var(--text)}
 .ui #pages .chapter-toggle{font-weight:700;font-size:12px}
 #pages .page{margin:1px 0;padding:0;border-left-width:3px}
 #pages .page-select{padding:7px 12px;min-height:34px}
 #pages .insert-slot{height:5px;margin:0}
 #pages .insert-slot .insert-page{position:relative;top:-9px;z-index:2}
 #pages.chapters-dragging .chapter-label{margin:10px 0;min-height:38px}
}
/* Chapter separation through typography and a stronger rule, not a box. */
@media screen{
 #pages .chapter-label{margin:30px 0 10px;padding:3px 0 5px;min-height:30px;background:transparent;border:0;border-bottom:1px solid var(--field-line);border-radius:0;color:var(--text)}
 .ui #pages .chapter-toggle{font-size:13px;font-weight:700}
 #pages.chapters-dragging .chapter-label{margin:10px 0;padding:5px;background:var(--surface);border:1px solid var(--line);border-radius:5px;min-height:38px}
}
@media screen{
 .right-sidebar,.sidebar-backdrop{top:0}
 .pane-divider{position:relative;background:var(--bg);border-left:1px solid var(--line);border-right:1px solid var(--line);cursor:col-resize;touch-action:none;z-index:4}
 .pane-divider::after{content:'';position:absolute;left:2px;right:2px;top:50%;height:36px;border-radius:2px;background:var(--field-line)}
 .pane-divider:hover,.pane-divider:focus-visible{background:var(--primary-soft);outline:none}.pane-divider:focus-visible::after{background:var(--focus)}
 .resizing-panes{cursor:col-resize;user-select:none}.resizing-panes .preview-viewport{pointer-events:none}
}
@media(max-width:1200px){.pane-divider{display:none}}
@media print{.pane-divider{display:none!important}}
@media screen{
 .page-list>.chapter-add{flex:none;margin:0;padding:10px 12px;background:var(--surface);border-top:1px solid var(--line)}
 .app-header .hgroup[aria-label="Excel"]{margin-left:0}
 .app-header>.preview-actions{margin-left:auto;gap:8px}
 .app-header>.preview-actions button{font-size:14px;min-height:36px;padding:6px 12px}
 .header-sheet-pager{margin-left:auto}.header-sheet-pager .sheet-pager{display:flex;gap:8px;align-items:center}
 .ui .header-sheet-pager button{width:32px;min-width:32px;height:32px;min-height:32px;padding:6px}
 .header-sheet-pager .sheet-counter{font-size:12px;font-weight:400;color:var(--muted)}
 .header-sheet-pager[hidden]{display:none}
}
@media(max-width:800px){.app-header>.preview-actions{margin-left:0}.app-header>.preview-actions button{font-size:12px;padding:6px 8px}.header-sheet-pager .sheet-pager{gap:5px}}
@media screen{
 .preview-head{position:relative;display:grid;grid-template-columns:1fr auto 1fr;gap:8px}
 .preview-head>b{grid-column:1;white-space:nowrap}.preview-head .header-sheet-pager{grid-column:2;margin:0;justify-self:center}
 .shortcut-footer{flex:none;border-top:1px solid var(--line);background:var(--surface)}
 .shortcut-footer summary{display:flex;align-items:center;gap:9px;padding:15px 18px;cursor:pointer;list-style:none;font-size:13px;user-select:none}
 .shortcut-footer summary::-webkit-details-marker{display:none}.shortcut-footer summary::after{content:'⌃';margin-left:auto;color:var(--muted);transform:rotate(180deg)}
 .shortcut-footer[open] summary::after{transform:none}.shortcut-footer summary:hover{background:var(--surface-soft)}
 .shortcut-footer summary:focus-visible{outline:2px solid var(--focus);outline-offset:-3px}
 .shortcut-body{padding:0 18px 14px;max-height:40vh;overflow:auto}.shortcut-row{display:flex;flex-wrap:wrap;align-items:center;gap:5px 10px;margin:8px 0;font-size:12px;color:var(--muted)}
 .shortcut-row kbd{font:11px/1.5 inherit;font-family:inherit;border:1px solid var(--line);border-radius:4px;padding:2px 5px;color:var(--text);background:var(--surface-soft)}
 .shortcut-body p{font-size:11px;line-height:1.6;color:var(--muted);margin:12px 0 0}
}
@media screen{.preview-head{grid-template-columns:minmax(0,1fr) auto minmax(0,1fr)}.preview-head>b{min-width:0}}
@media screen{.preview>.preview-head.pane-header{display:grid;grid-template-columns:minmax(0,1fr) auto minmax(0,1fr)}}
@media screen{.shortcut-footer summary::after{content:'';width:6px;height:6px;border-right:1.5px solid var(--muted);border-bottom:1.5px solid var(--muted);transform:rotate(45deg)}.shortcut-footer[open] summary::after{transform:rotate(225deg)}.shortcut-row kbd{font-size:11px;line-height:1.5}}
@media screen{.item-pager #toggleChapters{margin-right:4px}}
@media screen{
 .side-head #toggleChapters{width:28px;min-width:28px;height:28px;min-height:28px;padding:5px;margin:0;background:transparent}
 .side-head #toggleChapters+.side-title{margin-left:-3px}
 #pages .page{margin:0}
 #pages .page-select{min-height:30px;padding:5px 12px}
 #pages .insert-slot{height:3px}
 #pages .insert-slot .insert-page{top:-10px}
}
@media screen{
 #pages .page-select b.numbered-item{display:grid;grid-template-columns:16px minmax(0,1fr);column-gap:2px;width:100%;align-items:start}
 #pages .item-number{text-align:center;font-variant-numeric:tabular-nums}
 #pages .chapter-toggle>svg{flex:none}
}
@media screen{
 .editor-heading,.preview-heading{display:flex;align-items:center;gap:8px;min-width:0}
 .pane-header .pane-title-icon{width:16px;height:16px;flex:none;color:var(--muted)}
 .preview-head .preview-heading{grid-column:1;grid-row:1}
 .preview-head .header-sheet-pager{grid-column:2;grid-row:1}
 .preview-head #pagePdf{grid-column:3;grid-row:1;justify-self:end;margin:0;background:transparent}
}
@media screen{
 .editor-heading>#editTitle{flex:1;min-width:0;width:100%}
 #editTitle .page-auto-number{flex:none}
}
@media screen{.item-drag-ghost{opacity:.85}#pages .page.dragging{opacity:.45}}
/* Preserve the resting chapter layout during drag; only source opacity changes. */
@media screen{
 #pages.chapters-dragging .chapter-label{margin:30px 0 10px;padding:3px 0 5px;min-height:30px;background:transparent;border:0;border-bottom:1px solid var(--field-line);border-radius:0}
 #pages.chapters-dragging .chapter-drag-source{background:transparent}
 #pages.chapters-dragging .chapter-grip{opacity:0}
 #pages.chapters-dragging .chapter-label:hover .chapter-grip,#pages.chapters-dragging .chapter-label:focus-within .chapter-grip,#pages.chapters-dragging .chapter-drag-source .chapter-grip{opacity:1}
}
@media(hover:none){#pages.chapters-dragging .chapter-grip{opacity:1}}

/* ---- 文書レイアウトの操作（右サイドバー・項目フォーム） ---- */
.layout-panel > summary {cursor:pointer;font-weight:700;padding:6px 0}
.lpreset {display:flex;gap:6px;margin:6px 0 4px}
.lpreset button, .lseg button, .lsection-foot button {font-size:13px;min-height:32px;padding:2px 10px;border:1px solid var(--field-line);border-radius:6px;background:var(--surface);color:var(--text);cursor:pointer}
.lpreset button[aria-pressed=true], .lseg button[aria-pressed=true] {background:var(--primary-soft);border-color:var(--primary);color:var(--primary-ink);font-weight:700}
.lsection {border-top:1px solid var(--field-line);padding:2px 0}
.lsection > .lsection-head {cursor:pointer;font-size:15px;font-weight:700;padding:8px 0}
.lsection-body {display:grid;gap:8px;padding:2px 0 8px 1em}
/* 全体設定の節：見出しの文字（トグルアイコンの右）から1文字分下げる */
.lsection > .lsection-body {padding-left:calc(19px + 1em)}
.lsection-foot {display:flex;justify-content:flex-end;padding-top:4px}
.lrow {display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.3fr) 58px 26px auto;align-items:center;gap:4px 8px;font-size:14px;min-width:0}
.lrow .lname {min-width:0;overflow-wrap:anywhere;color:var(--text);font-weight:500;text-align:right}
/* スライダー：トラック・塗り・つまみを明示して、暗い背景でも見分けやすくする（塗りの長さは JS が --fill に入れる） */
.lrow input[type=range] {-webkit-appearance:none;appearance:none;width:100%;min-width:0;height:26px;margin:0;padding:0;background:transparent;cursor:pointer;--fill:50%}
.lrow input[type=range]::-webkit-slider-runnable-track {height:6px;border-radius:3px;background:linear-gradient(to right,var(--primary-ink) 0,var(--primary-ink) var(--fill),var(--field-line) var(--fill),var(--field-line) 100%)}
.lrow input[type=range]::-webkit-slider-thumb {-webkit-appearance:none;appearance:none;width:18px;height:18px;margin-top:-6px;border-radius:50%;background:var(--surface);border:2px solid var(--primary-ink);box-sizing:border-box}
.lrow input[type=range]::-moz-range-track {height:6px;border-radius:3px;background:var(--field-line)}
.lrow input[type=range]::-moz-range-progress {height:6px;border-radius:3px;background:var(--primary-ink)}
.lrow input[type=range]::-moz-range-thumb {width:14px;height:14px;border-radius:50%;background:var(--surface);border:2px solid var(--primary-ink);box-sizing:border-box}
.lrow input[type=range]:focus-visible {outline:2px solid var(--focus);outline-offset:3px}
.lrow .lnum, .lrow > input[type=number] {width:58px;min-height:32px;padding:2px 6px;font:inherit;font-size:14px;font-variant-numeric:tabular-nums;color:var(--text);background:var(--field-bg);border:1px solid var(--field-line);border-radius:6px}
.lrow .lnum:focus-visible, .lrow > input[type=number]:focus-visible {outline:2px solid var(--focus);outline-offset:1px;border-color:var(--primary-ink)}
.lrow .lunit {color:var(--muted);font-size:13px}
.lrow-check {display:flex;align-items:center;gap:6px;font-size:13px}
/* 選択式の行（ページ番号の位置）：ラベルの右に、スライダーと同じ開始位置から並べる */
.lrow-seg {display:grid;grid-template-columns:minmax(0,1fr) 24px minmax(0,1.3fr) 58px 26px;align-items:center;gap:4px 8px}
.lrow-seg .lname {grid-column:1}
.lrow-seg .lseg {grid-column:3 / -1;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}
.lrow-seg .lseg button {width:100%}
.lrow.is-off {opacity:.5}
.lrow.is-off .lname {font-weight:400}

.lrow-select, .lrow-text {display:grid;grid-template-columns:minmax(0,1fr) minmax(0,2fr);gap:6px;align-items:center;font-size:13px}
.lrow-select select, .lrow-text input {min-height:30px;font:inherit;min-width:0}
.lrow-text input[type=text] {width:100%}
.layout-page > summary {font-weight:700;cursor:pointer}
.layout-page .essential-note {margin:4px 0 6px}
.lsection-title {font-weight:700;margin:4px 0}
.layout-break {margin-top:8px;font-size:13px}
.img-card {border:1px solid var(--line);border-radius:8px;padding:10px;margin:8px 0;display:grid;gap:6px;background:var(--surface)}
.img-card.is-focus {box-shadow:0 0 0 3px var(--focus)}
/* 「レイアウト」ボタンの印：この項目を個別に設定しているとき */
#pageLayoutBtn.is-customized::after {content:"";display:inline-block;width:7px;height:7px;margin-left:6px;border-radius:50%;background:var(--accent);vertical-align:middle}
@media (max-width:520px) {.lrow {grid-template-columns:minmax(0,1fr) 58px;} .lrow input[type=range] {grid-column:1/-1}}
/* ---- 文書レイアウト：編集エリアの全体設定・項目の吹き出し・プレビューの入口 ---- */
.editor {position:relative}
.editor[data-mode="layout"] .editor-panel,.editor[data-mode="layout"] .editor-heading,.editor[data-mode="layout"] .include-bar {display:none}
.editor .layout-head {display:flex;align-items:center;justify-content:space-between;gap:8px;flex:1;min-width:0}
.editor .layout-head h2 {font-size:15px;margin:0}
.editor .layout-head[hidden], .editor .global-layout[hidden], .layout-pop[hidden] {display:none!important}
.editor .layout-head button, #pageLayoutBtn {min-height:32px;padding:4px 10px;font-size:13px;white-space:nowrap}
.global-layout {margin:6px 12px 0;padding:0;background:transparent;color:var(--text);border:0}
.preview-tools {display:flex;align-items:center;gap:8px;margin-left:auto;grid-column:3;grid-row:1;justify-self:end}
.preview-tools #layoutOpen {min-height:32px;padding:4px 10px;font-size:13px;white-space:nowrap;border:1px solid var(--line);border-radius:6px;background:var(--surface);color:var(--text)}
.preview-tools #layoutOpen[aria-pressed=true] {background:var(--primary-soft);border-color:var(--primary);color:var(--primary-ink);font-weight:700}
/* 表紙・目次では全体レイアウト設定をグレーアウト（押せない） */
.preview-tools #layoutOpen:disabled {background:var(--disabled-bg);border-color:var(--line);color:var(--disabled-text);cursor:not-allowed}
.layout-pop {position:fixed;z-index:20;width:min(680px,calc(100vw - 24px));max-height:min(88vh,900px);display:flex;flex-direction:column;background:var(--surface);color:var(--text);border:1px solid var(--line);border-radius:8px;box-shadow:0 8px 24px rgba(0,0,0,.18)}
.layout-pop::before {content:"";position:absolute;top:-7px;right:var(--arrow-right,18px);width:12px;height:12px;background:var(--surface);border-left:1px solid var(--line);border-top:1px solid var(--line);transform:rotate(45deg)}
.layout-pop-head {display:flex;align-items:center;justify-content:space-between;gap:8px;padding:8px 8px 6px 14px;border-bottom:1px solid var(--line-soft)}
.layout-pop-head b {font-size:14px}
.layout-pop-tools {display:flex;align-items:center;gap:2px}
.layout-pop-head .lreset-icon {min-width:28px;width:28px;height:28px;font-size:0}
.layout-pop-head .lreset-icon.is-idle {display:none}
.layout-pop-head button {min-width:32px;min-height:32px;padding:0;border:0;background:transparent;color:var(--muted);font-size:20px;line-height:1}
.layout-pop-body {overflow:auto;padding:8px 14px 14px}
.layout-pop .essential-note {margin:0 0 6px;font-size:12px}
.layout-pop .lsection-body {gap:6px}
.layout-pop .lrow.is-overridden .lname {font-weight:700}
/* 吹き出し内の項目名は改行しない（幅が足りなければ右の欄を縮める） */
.layout-pop .lname {white-space:nowrap}
/* 吹き出し：項目名の欄を固定幅にして、スライダーの長さを全行で揃える */
@media (min-width:521px) {.layout-pop .lrow.has-reset {grid-template-columns:180px 22px minmax(0,1fr) 58px}.layout-pop .lrow-seg {grid-template-columns:180px 24px minmax(0,1fr) 58px 26px}}
/* 背景の暗転：編集エリア・一覧・ヘッダーを暗くし、プレビューと吹き出しは明るいまま */
.layout-scrim {position:fixed;inset:0;z-index:15;background:rgba(6,9,14,.55)}
.layout-scrim[hidden] {display:none}
.layout-scrim:not([hidden]) {animation:layout-scrim-in .16s ease-out}
.layout > .preview {position:relative;z-index:16}
@keyframes layout-scrim-in {from {opacity:0} to {opacity:1}}
@media (prefers-reduced-motion: reduce) {.layout-scrim:not([hidden]) {animation:none}}
@media (max-width:520px) {.layout-pop .lrow {grid-template-columns:minmax(0,1fr) 58px}}

/* 文書レイアウト：リセットアイコン（変えた項目・節の見出し）と、設定の行にマウスを重ねたときのプレビュー強調 */
.lrow.has-reset {grid-template-columns:minmax(0,1fr) 22px minmax(0,1.3fr) 58px}
.lreset-icon {display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;min-height:0;padding:0;border:0;border-radius:6px;background:transparent;color:var(--muted);cursor:pointer}
.lreset-icon svg {width:15px;height:15px}
.ui .layout-pop-head .lreset-icon {width:28px;min-width:28px;height:28px;min-height:28px}
.ui .lreset-icon, .ui .lsection > .lsection-head > .lreset-icon {width:22px;min-width:22px;height:22px;min-height:22px;padding:0;border:0;background:transparent;color:var(--muted)}
.lreset-icon:hover, .lreset-icon:focus-visible {background:var(--primary-soft);color:var(--primary-ink)}
.lreset-icon.is-idle {visibility:hidden}
.lreset-icon:disabled {opacity:.35;cursor:default;background:transparent;color:var(--muted)}
/* 余白の図：A4の1枚目。数値と帯をドラッグで変え、クリックで直接入力（スライダーは使わない） */
.margin-diagram {margin:0;display:grid;grid-template-columns:auto 120px auto;grid-template-rows:auto auto auto auto;column-gap:4px;row-gap:0;align-items:center;justify-items:center}
.margin-diagram .md-top {grid-column:2;grid-row:1}
.margin-diagram .md-left {grid-column:1;grid-row:2;justify-self:end}
.margin-diagram .md-page {grid-column:2;grid-row:2}
.margin-diagram .md-right {grid-column:3;grid-row:2;justify-self:start}
.margin-diagram .md-bottom {grid-column:2;grid-row:3}
.md-label {display:inline-flex;align-items:center;gap:3px;padding:2px 4px;border-radius:6px;font-size:12px;color:var(--muted);white-space:nowrap;user-select:none;touch-action:none;cursor:ns-resize}
.md-label.md-left, .md-label.md-right {cursor:ew-resize}
.md-label:hover {background:var(--primary-soft);color:var(--primary-ink)}
.md-label .md-name {font-weight:500}
.md-label.is-overridden .md-name {font-weight:700;color:var(--text)}
.md-num {width:38px;height:26px;margin:0;padding:0 2px;text-align:center;font:inherit;font-size:14px;font-weight:700;font-variant-numeric:tabular-nums;color:var(--text);background:transparent;border:1px solid transparent;border-radius:4px;cursor:text}
.md-num:hover {border-color:var(--field-line);background:var(--surface)}
.md-num:focus-visible {outline:none;border-color:var(--focus);background:var(--surface)}
.md-label.is-overridden .md-num {color:var(--primary-ink)}

.md-page {position:relative;width:120px;aspect-ratio:210 / 297;box-sizing:border-box;border:1px solid var(--field-line);background:repeating-linear-gradient(45deg,var(--primary-soft) 0 4px,var(--surface-soft) 4px 8px);box-shadow:0 1px 3px #0002}
.md-body {position:absolute;top:calc(var(--md-t, 18) / 297 * 100%);bottom:calc(var(--md-b, 12) / 297 * 100%);left:calc(var(--md-l, 20) / 210 * 100%);right:calc(var(--md-r, 18) / 210 * 100%);box-sizing:border-box;border:1px dashed var(--primary);background:var(--surface) repeating-linear-gradient(to bottom,transparent 0 9px,var(--line-soft) 9px 10px);pointer-events:none}
/* 帯：余白の部分そのもの（ドラッグで変える） */
.md-band {position:absolute;touch-action:none;cursor:ns-resize}
.md-band:hover {background:rgba(11,92,173,.22)}
.md-band-top {left:0;right:0;top:0;height:calc(var(--md-t, 18) / 297 * 100%)}
.md-band-bottom {left:0;right:0;bottom:0;height:calc(var(--md-b, 12) / 297 * 100%)}
.md-band-left {top:calc(var(--md-t, 18) / 297 * 100%);bottom:calc(var(--md-b, 12) / 297 * 100%);left:0;width:calc(var(--md-l, 20) / 210 * 100%);cursor:ew-resize}
.md-band-right {top:calc(var(--md-t, 18) / 297 * 100%);bottom:calc(var(--md-b, 12) / 297 * 100%);right:0;width:calc(var(--md-r, 18) / 210 * 100%);cursor:ew-resize}
.lsection > .lsection-head {display:flex;align-items:center;gap:4px;list-style:none;min-height:40px;box-sizing:border-box}
.lsection > .lsection-head::-webkit-details-marker {display:none}
/* 節のトグルアイコン（開いていれば下向き、閉じていれば右向き） */
.lsection > .lsection-head > span {min-width:0}
.lsection > .lsection-head > .lsec-reset {flex:none;margin-left:2px}
/* 節の見出しのリセットは見出しの高さを変えない（ボタンの最小高さ規則に負けないよう固定） */
.lsection > .lsection-head > .lreset-icon {min-height:24px;height:24px;width:24px;padding:0}
.lsection > .lsection-head > .lsec-reset.is-idle {display:none}
/* 節の見出しの右端の「表示」スイッチ（ラベル＋トグル）。項目の見出しでも同じものを使う */
.lsw {position:relative;display:inline-flex;align-items:center;gap:8px;margin-left:auto;flex:none;font-size:13px;font-weight:500;color:var(--text);white-space:nowrap;cursor:pointer}
.lsw input {position:absolute;width:1px;height:1px;margin:0;opacity:0;pointer-events:none}
.lsw i {position:relative;display:inline-block;width:38px;height:22px;box-sizing:border-box;border:1px solid var(--field-line);border-radius:20px;background:var(--disabled-bg);transition:background .15s}
.lsw i::after {content:"";position:absolute;left:2px;top:2px;width:16px;height:16px;border-radius:50%;background:var(--surface);box-shadow:0 1px 3px #0003;transition:transform .15s}
.lsw input:checked + i {background:var(--primary);border-color:var(--primary)}
.lsw input:checked + i::after {transform:translateX(16px)}
.lsw input:focus-visible + i {outline:2px solid var(--focus);outline-offset:2px}
@media (prefers-reduced-motion: reduce) {.lsw i, .lsw i::after {transition:none}}
@media (max-width:520px) {
  .lrow-seg, .layout-pop .lrow-seg {grid-template-columns:minmax(0,1fr)}
  .lrow-seg .lseg {grid-column:1;grid-row:2}
  .lrow.has-reset, .layout-pop .lrow.has-reset {grid-template-columns:24px minmax(0,1fr) 58px 26px}
  .lrow.has-reset .lname {grid-column:1/-1;text-align:left}
  .lrow.has-reset .lreset-icon {grid-column:1;grid-row:2}
  .lrow.has-reset input[type=range] {grid-column:2;grid-row:2}
  .lrow.has-reset .lnum {grid-column:3;grid-row:2}
  .lrow.has-reset .lunit {grid-column:4;grid-row:2}
}
#preview {--lhl-fill:rgba(11,92,173,.16);--lhl-line:#0b5cad}
/* 余白：4辺それぞれの帯 */
#preview:is([data-layout-hl~="margin.top"],[data-layout-hl~="margin.right"],[data-layout-hl~="margin.bottom"],[data-layout-hl~="margin.left"]) .a4::before {content:"";position:absolute;inset:0;box-sizing:border-box;pointer-events:none;z-index:2}
#preview[data-layout-hl~="margin.top"] .a4::before {border-top:var(--cp-m-top,18mm) solid var(--lhl-fill)}
#preview[data-layout-hl~="margin.right"] .a4::before {border-right:var(--cp-m-right,18mm) solid var(--lhl-fill)}
#preview[data-layout-hl~="margin.bottom"] .a4::before {border-bottom:var(--cp-m-bottom,12mm) solid var(--lhl-fill)}
#preview[data-layout-hl~="margin.left"] .a4::before {border-left:var(--cp-m-left,20mm) solid var(--lhl-fill)}
/* 字下げ：余白の内側から字下げの幅 */
#preview[data-layout-hl~="indent"] .a4::before {content:"";position:absolute;top:var(--cp-m-top,18mm);bottom:var(--cp-m-bottom,12mm);left:var(--cp-m-left,20mm);width:var(--cp-indent,15mm);background:var(--lhl-fill);pointer-events:none;z-index:2}
/* ページ番号：項目ごとに見え方を変える。位置＝左・中央・右の番号を点線の枠、文字サイズ＝番号を塗りで四角く囲む（どちらも番号の場所は data-lhl-pn で決める）、下からの位置＝番号までの帯、表示＝下端の帯 */
#preview:is([data-layout-hl~="pageNumber.position"],[data-layout-hl~="pageNumber.font"]) .a4::after {content:"1";position:absolute;bottom:var(--cp-pn-bottom,4mm);left:auto;right:auto;transform:none;line-height:1;font-size:var(--cp-pn-font,9pt);color:var(--lhl-line);padding:.6mm 1.2mm;white-space:nowrap;pointer-events:none;z-index:2}
#preview[data-lhl-pn="left"]:is([data-layout-hl~="pageNumber.position"],[data-layout-hl~="pageNumber.font"]) .a4::after {left:var(--cp-m-left,20mm)}
#preview[data-lhl-pn="center"]:is([data-layout-hl~="pageNumber.position"],[data-layout-hl~="pageNumber.font"]) .a4::after {left:50%;transform:translateX(-50%)}
#preview[data-lhl-pn="right"]:is([data-layout-hl~="pageNumber.position"],[data-layout-hl~="pageNumber.font"]) .a4::after {right:var(--cp-m-right,18mm)}
#preview[data-layout-hl~="pageNumber.position"] .a4::after {font-weight:700;outline:1.5px dashed var(--lhl-line);outline-offset:1px}
#preview[data-layout-hl~="pageNumber.font"] .a4::after {background:var(--lhl-fill);color:var(--lhl-line)}
#preview[data-layout-hl~="pageNumber.bottom"] .a4::after {content:"";position:absolute;left:0;right:0;bottom:0;height:var(--cp-pn-bottom,4mm);box-sizing:border-box;background:var(--lhl-fill);border-top:1.5px dashed var(--lhl-line);pointer-events:none;z-index:2}
#preview[data-layout-hl~="pageNumber.show"][data-lhl-pn] .a4::after {content:"1";position:absolute;left:0;right:0;bottom:0;height:var(--cp-m-bottom,12mm);box-sizing:border-box;display:flex;align-items:flex-end;justify-content:var(--cp-pn-justify,center);padding:0 var(--cp-pn-pr,0mm) var(--cp-pn-bottom,4mm) var(--cp-pn-pl,0mm);background:var(--lhl-fill);color:var(--lhl-line);font-size:var(--cp-pn-font,9pt);font-weight:400;line-height:1;transform:none;outline:none;white-space:normal;pointer-events:none;z-index:2}
/* 見出し・表・タイトル・本文・目次：枠線 */
#preview[data-layout-hl~="title.font"] .a4 .title {outline:1.5px dashed var(--lhl-line);outline-offset:2px}
#preview[data-layout-hl~="heading.font"] .a4 h2 {outline:1.5px dashed var(--lhl-line);outline-offset:2px}
#preview[data-layout-hl~="table.font"] .a4 .table {outline:1.5px dashed var(--lhl-line);outline-offset:2px}
#preview:is([data-layout-hl~="body.font"],[data-layout-hl~="body.lineHeight"]) .a4 .document-body {outline:1.5px dashed var(--lhl-line);outline-offset:2px}
#preview:is([data-layout-hl~="toc.chapterFont"],[data-layout-hl~="toc.chapterWeight"],[data-layout-hl~="toc.chapterAfter"]) .a4 .toc-chapter-title {outline:1.5px dashed var(--lhl-line);outline-offset:2px}
#preview:is([data-layout-hl~="toc.itemFont"],[data-layout-hl~="toc.itemIndent"],[data-layout-hl~="toc.lineHeight"]) .a4 .toc-items {outline:1.5px dashed var(--lhl-line);outline-offset:2px}
#preview:is([data-layout-hl~="toc.marginTop"],[data-layout-hl~="toc.marginRight"],[data-layout-hl~="toc.marginBottom"],[data-layout-hl~="toc.marginLeft"]) .a4.toc::before {content:"";position:absolute;inset:0;box-sizing:border-box;pointer-events:none;z-index:2}
#preview[data-layout-hl~="toc.marginTop"] .a4.toc::before {border-top:var(--cp-toc-mt,16mm) solid var(--lhl-fill)}
#preview[data-layout-hl~="toc.marginRight"] .a4.toc::before {border-right:var(--cp-toc-mr,24mm) solid var(--lhl-fill)}
#preview[data-layout-hl~="toc.marginBottom"] .a4.toc::before {border-bottom:var(--cp-toc-mb,18mm) solid var(--lhl-fill)}
#preview[data-layout-hl~="toc.marginLeft"] .a4.toc::before {border-left:var(--cp-toc-ml,24mm) solid var(--lhl-fill)}
#preview:is([data-layout-hl~="toc.numWidth"],[data-layout-hl~="toc.pageOn"]) .a4 .toc-page-number {outline:1.5px dashed var(--lhl-line);outline-offset:2px}
/* 表紙：項目の行にマウスを重ねると、その文字・署名欄を強調する */
#preview:is([data-layout-hl~="cover.project"],[data-layout-hl~="cover.projectFont"]) .a4.cover .coverProject, #preview:is([data-layout-hl~="cover.date"],[data-layout-hl~="cover.infoFont"]) .a4.cover .coverDate, #preview:is([data-layout-hl~="cover.company"],[data-layout-hl~="cover.infoFont"]) .a4.cover .coverCompany, #preview[data-layout-hl~="cover.signArea"] .a4.cover .sign-area, #preview:is([data-layout-hl~="cover.doc"],[data-layout-hl~="cover.docFont"],[data-layout-hl~="cover.docWeight"],[data-layout-hl~="cover.docSide"]) .a4.cover .coverDoc, #preview:is([data-layout-hl~="cover.align"],[data-layout-hl~="cover.textSide"]) .a4.cover .coverProject, #preview:is([data-layout-hl~="cover.align"],[data-layout-hl~="cover.textSide"]) .a4.cover .coverDate, #preview:is([data-layout-hl~="cover.align"],[data-layout-hl~="cover.textSide"]) .a4.cover .coverCompany {outline:1.5px dashed var(--lhl-line);outline-offset:2px}
/* 間隔：間隔の部分の帯 */
#preview[data-layout-hl~="space.titleAfter"] .a4 .title {position:relative;outline:1.5px dashed var(--lhl-line);outline-offset:2px}
#preview[data-layout-hl~="space.titleAfter"] .a4 .title::after {content:"";position:absolute;left:0;right:0;top:100%;height:var(--cp-title-after,10mm);background:var(--lhl-fill);pointer-events:none}
#preview[data-layout-hl~="space.headingBefore"] .a4 h2:not(:first-child) {position:relative}
#preview[data-layout-hl~="space.headingBefore"] .a4 h2:not(:first-child)::before {content:"";position:absolute;left:0;right:0;bottom:100%;height:var(--cp-h-before,6mm);background:var(--lhl-fill);pointer-events:none}
#preview[data-layout-hl~="space.headingAfter"] .a4 h2 {position:relative}
#preview[data-layout-hl~="space.headingAfter"] .a4 h2::after {content:"";position:absolute;left:0;right:0;top:100%;height:var(--cp-h-after,2mm);background:var(--lhl-fill);pointer-events:none}
#preview[data-layout-hl~="space.blockAfter"] .a4 .block-text {position:relative;outline:1px dashed var(--lhl-line);outline-offset:2px}
#preview[data-layout-hl~="space.blockAfter"] .a4 .block-text::after {content:"";position:absolute;left:0;right:0;top:100%;height:var(--cp-block-after,0mm);background:var(--lhl-fill);pointer-events:none}

/* 文書レイアウトの吹き出し：開閉のアニメーション・節の区切り・見出し右端のリセット */
.layout-pop:not([hidden]) {animation:layout-pop-in .16s ease-out}
.layout-pop.is-closing {animation:layout-pop-out .14s ease-in forwards}
@keyframes layout-pop-in {from {opacity:0;transform:translateY(-6px) scale(.98)} to {opacity:1;transform:none}}
@keyframes layout-pop-out {from {opacity:1;transform:none} to {opacity:0;transform:translateY(-6px) scale(.98)}}
@media (prefers-reduced-motion: reduce) {.layout-pop:not([hidden]), .layout-pop.is-closing {animation:none}}
.layout-pop .lgroup + .lgroup {margin-top:18px}
.layout-pop .lgroup-head {display:flex;align-items:center;gap:8px;margin-bottom:6px;padding-bottom:4px;border-bottom:1px solid var(--line-soft)}
.layout-pop .lgroup-title {margin:0;min-width:0;font-size:13px;font-weight:700}

/* ---- 全体設定の左上のタブ（表紙・目次・本文） ---- */
/* 表紙・目次は行が少ないので、余裕をもたせる */
.gl-panel.is-roomy {padding:14px 16px 16px}
.gl-panel.is-roomy .lsection > .lsection-head {min-height:40px;font-size:15px}
.gl-panel.is-roomy .lsection > .lsection-body {gap:12px;padding:6px 0 14px 19px}
.gl-panel.is-roomy .lrow {font-size:14px;gap:8px 10px}
.gl-panel.is-roomy .lrow input[type=range] {height:26px}
.gl-panel.is-roomy .lrow .lnum {height:32px;min-height:32px}
/* 全体レイアウト設定：ブラウザのタブ風（タブの列の下に面が続く）。サンプル／実際のページはタブの列の右端 */
.gl-tabbar {display:flex;align-items:flex-end;gap:8px;min-width:0;padding:10px 0 0 14px;background:transparent}
.gl-tabs {display:flex;align-items:flex-end;gap:0;min-width:0;flex:1 1 auto}
.gl-tabs button {position:relative;height:34px;min-height:34px;margin:0 0 -1px;padding:0 18px;font-size:14px;line-height:1;font-weight:500;white-space:nowrap;border:1px solid var(--line);border-bottom:0;border-radius:8px 8px 0 0;background:color-mix(in srgb, var(--text) 9%, var(--surface));color:var(--muted);cursor:pointer}
.gl-tabs button:hover {color:var(--text);background:var(--surface)}
.gl-tabs button + button {margin-left:-1px}
.gl-tabs button[aria-selected=true] {height:35px;min-height:35px;color:var(--text);font-weight:700;background:var(--surface);border-color:var(--line);z-index:1}
.gl-tabs button:focus-visible {outline:2px solid var(--focus);outline-offset:-2px}
.gl-tabbar .preview-mode {flex:none;margin:0 0 6px auto}
.global-layout {border:0;background:transparent}
.global-layout .gl-panel > .lsection:first-child {border-top:0;padding-top:0}
.global-layout .lsection {padding:14px 0 4px}
.global-layout .gl-panel .lsection > .lsection-body {gap:9px;padding-top:12px}
.global-layout .lsection > .lsection-head {position:relative;min-height:34px}
.global-layout .lrow-seg {grid-template-columns:207px 22px minmax(0,1fr) 52px;gap:3px 6px}
.global-layout .lrow-seg .lseg {grid-column:3 / 5;grid-template-columns:repeat(auto-fit,minmax(0,1fr))}
.global-layout .lsec-icon {position:absolute;left:0;top:50%;width:16px;height:16px;transform:translateY(-50%);fill:none;stroke:var(--muted);stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;pointer-events:none}
.ui .gl-tabs button:not([aria-selected=true]):hover:not(:disabled) {background:var(--surface);color:var(--text)}
.ui .gl-tabs button[aria-selected=true]:hover:not(:disabled) {background:var(--surface);border-color:var(--line)}
.gl-panel {padding:8px 14px 10px;background:var(--surface);color:var(--text);border:1px solid var(--line);border-radius:8px}
.global-layout .lpreset {margin:0 0 6px}
.global-layout .lpreset button {min-height:28px;padding:1px 10px;font-size:13px}
.global-layout .lsection {border-top:1px solid var(--line-soft);padding:0}
.global-layout .lsection > .lsection-head {min-height:30px;padding:3px 0;gap:0;font-size:14px;font-weight:700}
.global-layout .lsection > .lsection-body {gap:4px;padding:0 0 6px 19px}
.global-layout .lrow {font-size:13px;gap:3px 6px}
.global-layout .lrow .lname {white-space:nowrap;overflow-wrap:normal}
.global-layout .lrow input[type=range] {height:22px}
.global-layout .lrow .lnum {width:52px;height:26px;min-height:26px;padding:1px 6px;font-size:13px}
.global-layout .lrow .lunit {font-size:12px}
@media (min-width:521px) {
  .global-layout .lrow.has-reset {grid-template-columns:207px 22px minmax(0,1fr) 52px}
}

/* プレビュー見出しの「サンプル／実際のページ」切り替え */
.preview-mode {display:inline-flex;margin-left:6px}
.preview-mode[hidden] {display:none}
.preview-mode button {font-size:12px;min-height:28px;padding:2px 10px;border:1px solid var(--line);background:var(--surface);color:var(--text);cursor:pointer;white-space:nowrap}
.preview-mode button:first-child {border-radius:6px 0 0 6px}
.preview-mode button:last-child {border-radius:0 6px 6px 0;margin-left:-1px}
.preview-mode button[aria-pressed=true] {background:var(--primary-soft);border-color:var(--primary);color:var(--primary-ink);font-weight:700}
/* 「サンプル／実際のページ」は見出し「プレビュー」の右に並べる（全体レイアウト設定の「本文」タブだけ出す） */
.preview-mode button {min-height:26px;padding:1px 8px;font-size:12px}
@media screen {
 .preview>.preview-head.pane-header {grid-template-columns:auto minmax(0,1fr) auto}
}

/* 余白（左・図）と間隔（右・行）を同じ節に並べる。間隔の行は「名前・リセット」の上に、スライダーと数値を下に置く（縦に詰める） */
.margin-diagram figcaption {grid-column:1/-1;grid-row:4;justify-self:center;margin:0;font-size:12px;color:var(--muted)}
.lsection-pair {display:grid;grid-template-columns:auto minmax(0,1fr);gap:10px;align-items:center}
.lpair-rows {display:grid;gap:4px;min-width:0}
@media (min-width:521px) {
  .global-layout .lsection-pair {margin-left:-19px}
  .layout-pop .lpair-rows .lrow.has-reset {grid-template-columns:104px 22px minmax(40px,1fr) 52px}
  .global-layout .lpair-rows .lrow.has-reset {grid-template-columns:104px 22px minmax(40px,1fr) 52px}
  .global-layout .lpair-rows .lunit {display:none}
}
@media (max-width:520px) {.lsection-pair {grid-template-columns:minmax(0,1fr)}}
/* ---- 見た目の調整：プリセットは中央、節は開閉しない、一覧・編集履歴は影と箱をなくして罫線と左の線だけで区切る ---- */
@media screen{
 .global-layout .lpreset{justify-content:center}
 .global-layout .lsection > .lsection-head{padding-left:19px;cursor:default}
 .app-header #new.danger{color:var(--danger);border-color:var(--danger);background:transparent}
 .app-header #new.danger:is(:hover,:focus,:active):not(:disabled){background:transparent;border-color:var(--danger);color:var(--danger)}
 .right-sidebar{box-shadow:none}
 .sidebar-backdrop{background:transparent}
 .page-list .page,.page-list .page.excluded,.page-list .page.excluded.active{background:transparent;border-color:transparent;border-radius:0}
 .page-list .page:hover{background:var(--surface-soft);border-color:transparent;border-radius:0}
 .page-list .page.active,.page-list .page.excluded.active{background:var(--primary-soft);border-color:transparent;border-left-color:var(--primary);border-radius:0}
 .page-list .page.active .page-select b{color:var(--primary-ink);font-weight:700}
 #historyList{margin:8px 0 0;gap:0}
 #historyList li,#historyList .history-current{display:flex;align-items:center;gap:8px;min-width:0;margin:0;padding:9px 8px;background:transparent;border:0;border-bottom:1px solid var(--line);border-left:3px solid transparent;border-radius:0;font-size:13px;line-height:1.5;white-space:nowrap}
 #historyList li b{display:block;flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;margin:0;font-weight:500}
 #historyList .history-meta{flex:none;font-size:12px;color:var(--muted);font-variant-numeric:tabular-nums}
 #historyList .history-badge{float:none;flex:none;margin:0;padding:0 4px;font-size:11px;font-weight:700;background:transparent;color:var(--primary-ink)}
 #historyList li.history-current{background:var(--primary-soft);border-left-color:var(--primary);color:var(--text)}
 #historyList li.history-current b{font-weight:700}
 #historyList li.history-undone{opacity:1;color:var(--muted)}
 #historyList [data-history-cursor]:hover{background:var(--surface-soft);border-color:var(--line);border-bottom-color:var(--line)}
 #historyList li.history-current[data-history-cursor]:hover{background:var(--primary-soft);border-left-color:var(--primary)}
}


/* Table direct editing: screen-only controls, paper typography stays unchanged. */
.preview-viewport{cursor:default;user-select:text}
.preview-viewport.panning,.preview-viewport.panning *{user-select:none!important;cursor:grabbing!important}
.preview-viewport .table td[data-cell-field]{cursor:text;white-space:pre-line}
.preview-viewport .table td[data-cell-field]:focus-visible{outline:2px solid #2783de;outline-offset:-2px}
.preview-viewport .table td.is-selected{outline:2px solid #2783de;outline-offset:-2px;background:rgba(39,131,222,.1)}  /* 表示だけの選択（保存・履歴・PDFには入らない） */
.table-col-grip{position:absolute;z-index:5;width:var(--grip-size,8px);padding:0;border:0;border-radius:0;transform:translateX(-50%);background:transparent;cursor:col-resize;touch-action:none;min-height:0;min-width:0}
.table-col-grip:hover,.table-col-grip:focus-visible,.table-col-grip.is-resizing{background:rgba(39,131,222,.45);outline:1px solid #2783de}
/* Compact shared headings; adapt to the actual editor width, not viewport. */
#form{container-type:inline-size}
.table-editor{--table-secondary:color-mix(in srgb,var(--text) 70%,var(--surface));--table-grid:56px minmax(0,1fr) minmax(0,1.35fr) minmax(0,.85fr)}
.table-toolbar{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:8px}
.table-count{font-size:14px;color:var(--table-secondary)}
.ui .table-add{border:0;background:transparent;color:var(--text);padding:4px 8px;min-height:44px;font-size:14px}
.table-column-head,.table-entry{display:grid;grid-template-columns:var(--table-grid);gap:8px;align-items:start}
.table-column-head{padding:4px 0 8px;color:var(--table-secondary);font-size:14px;border-bottom:1px solid var(--line)}
.table-rows{display:block}
.table-entry{padding:8px 0;border-bottom:1px solid var(--line-soft);position:relative}
.table-entry:focus-within{background:var(--surface)}
.table-entry-fields{display:contents}.cell-field{display:flex;flex-direction:column;min-width:0;gap:4px}
.cell-label{display:none;font-size:14px;color:var(--muted)}
.ui .cell-box{display:block;width:100%;height:48px;min-height:0;margin:0;padding:4px 8px;border:1px solid var(--field-line);border-radius:4px;background:var(--field-bg);color:var(--text);font:inherit;font-size:14px;line-height:1.4;text-align:left;cursor:text;overflow:hidden;box-shadow:none}
.ui .cell-box:hover:not(:disabled){background:var(--field-bg);border-color:var(--primary)}
.cell-box:focus-visible{outline:2px solid var(--focus);outline-offset:2px}
.cell-box.is-empty .cell-text{color:var(--muted)}
.cell-text{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;white-space:pre-wrap;overflow-wrap:anywhere}
.ui .table-icon,.ui .table-row-grip{display:inline-flex;align-items:center;justify-content:center;width:44px;min-width:44px;min-height:44px;padding:4px;border:0;background:transparent;color:var(--muted);border-radius:4px;box-shadow:none}
.table-icon svg,.table-row-grip svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;pointer-events:none}
.ui .table-row-grip{gap:2px;font-size:12px;cursor:grab;touch-action:none;user-select:none}
.ui .table-icon:hover:not(:disabled),.ui .table-row-grip:hover:not(:disabled){background:var(--surface-soft);color:var(--text)}
.ui .table-icon[data-rowdel]:hover{color:var(--danger,#b42318);background:var(--danger-soft,#fbecec)}
.ui .table-icon:disabled{opacity:.25;cursor:default;background:transparent}
.ui .table-row-grip:disabled{opacity:1;cursor:default;background:transparent}
.table-row-grip:disabled svg{opacity:.25}
.table-empty{padding:20px 8px;text-align:center;color:var(--muted);font-size:14px}
.table-edit-status{font-size:12px;color:var(--muted);margin:0}.table-edit-status:empty{display:none}
.table-reordering{user-select:none}.table-entry.is-row-dragging{opacity:.4}
.table-row-insertion{position:fixed;z-index:80;height:2px;background:var(--primary,#2783de);pointer-events:none}
.table-row-ghost{position:fixed;z-index:81;padding:4px 10px;border:1px solid var(--line);background:var(--panel);color:var(--text);border-radius:4px;font-size:13px;pointer-events:none}
@container(max-width:560px){
 .table-column-head{display:flex;flex-wrap:wrap;gap:4px 8px;padding:0 0 8px}
 .table-column-head>span{display:none}
 .table-entry{grid-template-columns:44px minmax(0,1fr);gap:8px;padding:12px 0}
 .table-row-grip{grid-column:1;grid-row:1}
 .table-entry-fields{grid-column:1/-1;grid-row:2;display:grid;grid-template-columns:1fr;gap:8px}
 .cell-label{display:block}
}
@media print{.table-col-grip,.cell-bubble,.img-ext,.row-split,.row-grip{display:none!important}}

.ui.cell-bubble{position:fixed;z-index:90;box-sizing:border-box;display:grid;gap:8px;max-width:calc(100vw - 16px);padding:10px;border:1px solid var(--line);border-radius:8px;background:var(--panel);color:var(--text);box-shadow:0 1px 2px rgba(0,0,0,.05),0 4px 12px rgba(0,0,0,.12);font-size:14px;line-height:1.5}
.cell-bubble::before{content:"";position:absolute;z-index:-1;left:var(--arrow-x,20px);width:12px;height:12px;background:var(--panel);border:1px solid var(--line);transform:rotate(45deg)}
.cell-bubble.is-below::before{top:-7px;border-right:0;border-bottom:0}
.cell-bubble:not(.is-below)::before{bottom:-7px;border-left:0;border-top:0}
.cell-bubble textarea{box-sizing:border-box;width:100%;min-width:0;margin:0;padding:8px 10px;border:1px solid var(--field-line);border-radius:6px;background:var(--field-bg);color:var(--text);font:inherit;line-height:1.5;resize:none;overflow-y:auto;white-space:pre-wrap;overflow-wrap:anywhere}
.cell-measure{position:absolute;left:0;top:0;visibility:hidden;white-space:pre;font:inherit;pointer-events:none}
/* Table form: setup note above, column-name alignment popover, centered add action, row delete menu. */
.table-foot{display:flex;justify-content:center;padding:10px 0 4px}
/* 列名ボタン：クリックで列の揃えポップアップを開く（下向き矢印で操作できることを示す） */
/* 列名：各列の幅いっぱいをクリック対象にした見出し。枠・背景・現在値は常時表示せず、hover／フォーカスで控えめに示す */
.ui .table-colhead{display:flex;align-items:center;justify-content:flex-start;gap:4px;justify-self:stretch;min-width:0;min-height:0;margin:-4px -4px -8px;padding:4px 4px 8px;border:0;border-radius:4px 4px 0 0;background:transparent;color:inherit;font:inherit;font-size:14px;text-align:left;box-shadow:none;cursor:pointer}
.ui .table-colhead:hover:not(:disabled),.ui .table-colhead[aria-expanded="true"]{background:var(--surface-soft)}
@container(max-width:560px){.ui .table-colhead{margin:0;padding:6px 8px;min-height:36px}}
.ui .table-colhead:focus-visible{outline:2px solid var(--focus);outline-offset:-2px}
.ui .table-colhead:last-child{margin-right:0}
.table-colhead-mark{width:12px;height:12px;flex:none;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round;opacity:0;transition:opacity .12s}
.ui .table-colhead:hover .table-colhead-mark,.ui .table-colhead:focus-visible .table-colhead-mark,.ui .table-colhead[aria-expanded="true"] .table-colhead-mark{opacity:.6}
.table-format-pop{position:fixed;z-index:85;box-sizing:border-box;width:max-content;max-width:calc(100vw - 16px);padding:10px;background:var(--panel);border:1px solid var(--line);border-radius:8px;box-shadow:0 4px 14px rgba(0,0,0,.18);color:var(--text);font-size:14px}
.table-format-pop-row{display:flex;align-items:center;gap:4px}
.table-format-pop-row+.table-format-pop-row{margin-top:6px}
.table-format-pop-axis{width:24px;flex:none;color:var(--muted);font-size:13px}
.ui .table-align-btn{box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;width:40px;min-width:40px;height:40px;min-height:40px;padding:0;border:1px solid var(--field-line);border-radius:6px;background:var(--surface);color:var(--text);box-shadow:none}
.ui .table-align-btn:hover:not(:disabled){background:var(--primary-soft);border-color:var(--primary)}
.ui .table-align-btn[aria-pressed="true"]{background:var(--primary-soft);border:2px solid var(--primary);color:var(--primary-ink)}
.ui .table-align-btn:focus-visible{outline:2px solid var(--focus);outline-offset:2px}
.table-align-btn svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}
.table-align-btn .ico-box{stroke:var(--muted);stroke-width:1;opacity:.7}
.ui .table-foot .table-add{min-height:44px;padding:6px 18px;border:1px dashed var(--field-line);background:var(--surface-soft);color:var(--text)}
.table-editor .cell-box.is-pasted{box-shadow:inset 0 0 0 2px var(--accent)}
.table-row-menu{position:fixed;z-index:85;min-width:156px;padding:4px;background:var(--panel);border:1px solid var(--line);border-radius:6px;box-shadow:0 4px 14px rgba(0,0,0,.18)}
.table-row-menu button{display:flex;align-items:center;gap:8px;width:100%;min-height:44px;padding:8px 12px;border:0;background:transparent;color:var(--text);font-size:15px;font-weight:600;text-align:left;justify-content:flex-start}
.table-row-menu button.is-danger{color:var(--danger)}
.undo-toast{position:fixed;left:0;right:0;margin:0 auto;bottom:max(16px,env(safe-area-inset-bottom));width:max-content;z-index:90;display:flex;align-items:center;gap:6px;max-width:calc(100vw - 24px);padding:6px 6px 6px 16px;background:var(--panel);color:var(--text);border:1px solid var(--line);border-radius:8px;box-shadow:0 6px 18px rgba(0,0,0,.2)}
.undo-toast{pointer-events:none}
.undo-toast button{pointer-events:auto}
.undo-toast[hidden]{display:none}
.undo-toast-text{margin:0;font-size:15px;line-height:1.4;min-width:0;overflow-wrap:anywhere}
.undo-toast-action{min-height:44px;padding:8px 14px;border:0;border-radius:6px;background:transparent;color:var(--primary-ink);font-size:15px;font-weight:700;white-space:nowrap}
.undo-toast-action:hover{background:var(--primary-soft)}
.undo-toast-close{min-width:44px;min-height:44px;padding:0;border:0;border-radius:6px;background:transparent;color:var(--muted);font-size:20px;line-height:1}
.undo-toast-close:hover{background:var(--surface-soft);color:var(--text)}
.undo-toast button:focus-visible{outline:2px solid var(--focus);outline-offset:2px}
@media print{.undo-toast{display:none!important}}
.table-row-menu button .action-icon,.table-row-menu button > svg:not(.table-menu-trash){width:20px;height:20px;flex:none;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.table-menu-trash{width:20px;height:20px;flex:none;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.table-row-menu button:hover:not(:disabled),.table-row-menu button:focus-visible{background:var(--surface-soft)}
.table-row-menu button.is-danger:hover:not(:disabled),.table-row-menu button.is-danger:focus-visible{background:var(--danger-soft)}


/* ---- 画像の設定（段階②C）：プレビューの入口・フォームの画像カード・設定ポップアップ ---- */
.img-set {position:absolute;right:0;bottom:calc(100% + var(--k,1) * 4px);pointer-events:auto;touch-action:manipulation;box-sizing:border-box;min-height:0;height:auto;margin:0;padding:calc(var(--k,1) * 2px) calc(var(--k,1) * 8px);font:inherit;font-size:calc(var(--k,1) * 12px);line-height:1.4;white-space:nowrap;border:calc(var(--k,1) * 1px) solid var(--line);border-radius:calc(var(--k,1) * 6px);background:var(--surface);color:var(--text);box-shadow:0 1px 3px rgba(0,0,0,.18);cursor:pointer}
.img-set:hover, .img-set:focus-visible, .img-set[aria-expanded=true] {background:var(--primary-soft);border-color:var(--primary-ink);color:var(--primary-ink)}
.img-set[aria-expanded=true] {font-weight:700}
.img-set:focus-visible {outline:calc(var(--k,1) * 2px) solid var(--focus);outline-offset:calc(var(--k,1) * 2px)}
.image-pop {width:min(340px,calc(100vw - 16px));max-height:min(80vh,560px)}
.image-pop::before {display:none}
.image-pop-body {display:grid;gap:8px}
.image-pop-foot {display:flex;flex-wrap:wrap;align-items:center;gap:6px 12px;padding:8px 14px 12px;border-top:1px solid var(--line-soft)}
.image-pop-foot button {min-height:32px;padding:4px 10px;font-size:13px;border:1px solid var(--field-line);border-radius:6px;background:var(--surface);color:var(--text)}
.image-pop-foot .essential-note {margin:0;font-size:12px;flex:1 1 100%}
.media-items {display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:8px;align-items:start}
.media-items.is-drop {outline: 2px dashed var(--accent); outline-offset: 4px; border-radius: 8px}
.img-card {display:grid;gap:6px;min-width:0;border:1px solid var(--line);border-radius:8px;padding:6px;margin:0;background:var(--surface)}
.img-card-thumb {display:block;width:100%;aspect-ratio:4/3;box-sizing:border-box;object-fit:contain;border-radius:6px;border:1px solid var(--line-soft);background:var(--field-bg)}
/* 一覧・カードのサムネイル：箱（切り取り後の範囲）を枠の中に収める。cq 単位は枠の大きさに合わせる。 */
.ic-fit {display:flex;align-items:center;justify-content:center;container-type:size;overflow:hidden;box-sizing:border-box;min-width:0}
.img-card-thumb-wrap {position:relative;min-width:0}
/* 画像の設定ポップアップ：項目名の欄を固定幅にして、欄どうしが重ならないようにする */
.image-pop .lrow {grid-template-columns:96px minmax(0,1fr) 58px}
.image-pop .lrow.lrow-seg {grid-template-columns:96px minmax(0,1fr)}
.image-pop .lrow-seg .lseg {grid-column:2 / -1}
.image-pop .lrow-select, .image-pop .lrow-text {grid-template-columns:96px minmax(0,1fr)}
/* ③2 キャプション：カードの入力欄（固定高・1行）と、プレビューの吹き出し。削除は右のボタンだけ。 */
.ui .img-card-thumb-btn {padding:0;min-height:0;border:0;background:none;cursor:pointer;border-radius:6px;display:block;width:100%;min-width:0}
.img-card-thumb-btn:focus-visible {outline:2px solid var(--focus);outline-offset:2px}
.ui .img-add {display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;width:calc(100% - 14px);margin:7px;min-width:0;min-height:auto;aspect-ratio:4/3;box-sizing:border-box;padding:2px;border:1.5px dashed var(--field-line);border-radius:6px;background:var(--surface);color:var(--muted);font-size:12px;line-height:1.3;text-align:center;cursor:pointer}
.ui .img-add .img-add-plus {font-size:26px;line-height:1}
.ui .img-add .img-add-text {display:block;max-width:100%;white-space:normal;overflow-wrap:anywhere;word-break:keep-all}
.ui .img-add .img-add-sub {display:block;font-size:11px;line-height:1.3;color:var(--muted);font-weight:400}
.ui .img-add:hover:not(:disabled) {border-color:var(--primary);color:var(--primary);background:var(--primary-soft)}
.ui .img-add:focus-visible {outline:2px solid var(--focus);outline-offset:2px}
/* ③3：キャプションの表示セル（表のセルと同じ見た目・固定高1行）と、その入力の吹き出し（表の吹き出しと同じ枠・入力だけ）。 */
/* ③3B：前後の余白（画像を選んでいる時だけ。辺の帯＝ドラッグ、範囲＝表示だけ（PDFには入らない）） */
.img-margin-zone {position:absolute;box-sizing:border-box;pointer-events:auto;cursor:ns-resize;touch-action:none;background:transparent;z-index:2}
.img-margin-zone[data-on] {background:var(--lhl-fill);outline:calc(var(--k,1) * 1.5px) dashed var(--lhl-line);outline-offset:calc(var(--k,1) * -1.5px)}
.img-margin-hit {position:absolute;box-sizing:border-box;pointer-events:auto;cursor:ns-resize;background:transparent;touch-action:none;z-index:3}
.placed-image.img-sel > .img-margin-hit {z-index:4}
.img-margin-tip {display:none;position:absolute;left:50%;top:50%;transform:translate(-50%,-50%) scale(var(--k,1));white-space:nowrap;font-size:12px;line-height:1.4;padding:1px 6px;border-radius:4px;background:var(--lhl-line);color:#fff;pointer-events:none}
.img-margin-zone[data-on] .img-margin-tip {display:block}

/* ③A：選んだ画像の操作ツールバー（プレビューの上に浮かせる・表示だけ）。拡大率に依らず 44px。見えている範囲に収める。 */
.preview-viewport{position:relative}

/* 画像の操作（表示だけ・プレビューの上に重ねる層 .img-ext。HTML・PDF・履歴には入らない）。ライト／ダーク共通のグレーで少し半透明。ボタンは画面の px（36px・アイコン18px）。位置は JS が画面で測って決める。 */
.img-ext {position:absolute;left:0;top:0;z-index:6;pointer-events:none;font-size:13px;line-height:1.3}
.img-ext[data-mode="none"] {display:none}
.img-ext .img-ov-btn {position:absolute;box-sizing:border-box;width:30px;height:30px;margin:0;padding:0;display:flex;align-items:center;justify-content:center;border:0;border-radius:6px;background:rgba(64,64,64,.72);color:#fff;cursor:pointer;pointer-events:auto}
.img-ext .img-ov-btn[hidden] {display:none}
/* 「…」（外に出た操作のメニュー）：操作ボタンと同じ見た目の箱。中のボタンは箱の中の並び（位置は箱が決める） */
.img-ext .img-ov-menu{position:absolute;box-sizing:border-box;display:flex;flex-direction:column;align-items:center;gap:4px;padding:4px;border-radius:8px;background:rgba(64,64,64,.72)}
.img-ext .img-ov-menu[hidden]{display:none}
.img-ext .img-ov-menu .img-ov-btn{position:static}
.img-ext .img-ov-menu.is-row{flex-direction:row}
.img-ext .img-ov-btn:hover {background:rgba(40,40,40,.88)}
.img-ext .img-ov-btn.is-danger {color:#ffb4b4}
.img-ext .img-ov-btn:focus-visible,.img-ext .img-ov-cap:focus-visible {outline:2px solid var(--focus);outline-offset:2px}
.img-ext .img-ov-btn.is-current {box-shadow:inset 0 0 0 2px #fff;background:rgba(20,20,20,.9)}   /* 現在の値（横並びの高さ・寄せ・縦の位置）を強調 */
.img-ov-btn svg {width:18px;height:18px;flex:none;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;pointer-events:none}
.img-ext .img-ov-cap {position:absolute;box-sizing:border-box;height:32px;margin:0;padding:0 10px;min-width:0;border:0;border-radius:6px;background:rgba(64,64,64,.72);color:#fff;font:inherit;font-size:13px;outline:none;pointer-events:auto}
.img-ext .img-ov-cap::placeholder {color:rgba(255,255,255,.8)}
.img-ext .img-ov-cap:hover {background:rgba(40,40,40,.88)}
.img-ext .img-ov-cap:focus {background:rgba(30,30,30,.92)}

/* 画像の編集ポップアップ（段階④D）。表示だけ。切り取りは枠の外を暗くして示す。操作は回転・切り取り・キャプション・キャンセル／保存のみ。 */
dialog.ui.image-edit-dlg{width:min(560px,calc(100vw - 32px))}
.image-edit-dlg .ie-form{margin:0}
.image-edit-dlg .ie-stage{display:flex;justify-content:center;align-items:center;background:#1b1f27;border-radius:6px;padding:20px;min-height:160px}
.image-edit-dlg .ie-frame{position:relative;display:block;margin:0 auto;line-height:0;max-width:100%}
.image-edit-dlg .ie-img{position:absolute;display:block;max-width:none;max-height:none;margin:0;padding:0;object-fit:fill;user-select:none;-webkit-user-drag:none}
.image-edit-dlg .ie-mask{position:absolute;background:rgba(0,0,0,.62);pointer-events:none}
.image-edit-dlg .ie-crop{position:absolute;box-sizing:border-box;border:1.5px solid #fff;box-shadow:0 0 0 1px rgba(0,0,0,.45);cursor:move;touch-action:none}
.image-edit-dlg .ie-crop::before{content:"";position:absolute;inset:0;pointer-events:none;background-image:linear-gradient(to right,transparent calc(100%/3 - .5px),rgba(255,255,255,.5) calc(100%/3 - .5px),rgba(255,255,255,.5) calc(100%/3 + .5px),transparent calc(100%/3 + .5px),transparent calc(200%/3 - .5px),rgba(255,255,255,.5) calc(200%/3 - .5px),rgba(255,255,255,.5) calc(200%/3 + .5px),transparent calc(200%/3 + .5px)),linear-gradient(to bottom,transparent calc(100%/3 - .5px),rgba(255,255,255,.5) calc(100%/3 - .5px),rgba(255,255,255,.5) calc(100%/3 + .5px),transparent calc(100%/3 + .5px),transparent calc(200%/3 - .5px),rgba(255,255,255,.5) calc(200%/3 - .5px),rgba(255,255,255,.5) calc(200%/3 + .5px),transparent calc(200%/3 + .5px))}
.image-edit-dlg .ie-crop:focus-visible{outline:2px solid var(--focus);outline-offset:2px}
.image-edit-dlg .ie-h{position:absolute;box-sizing:border-box;width:18px;height:18px;min-width:0;min-height:0;max-width:none;max-height:none;margin:-12px 0 0 -12px;padding:0;border:0;background:transparent;touch-action:none}
.image-edit-dlg .ie-h::before{content:"";position:absolute;box-sizing:border-box;pointer-events:none;filter:drop-shadow(0 0 1px rgba(0,0,0,.8)) drop-shadow(0 0 2px rgba(0,0,0,.35))}
/* 角：L字（見た目14px・細い白線）。当たり判定は角の外へ12px・内へ6px。 */
.image-edit-dlg .ie-h[data-h=tl]{margin:-12px 0 0 -12px}
.image-edit-dlg .ie-h[data-h=tr]{margin:-12px 0 0 -6px}
.image-edit-dlg .ie-h[data-h=br]{margin:-6px 0 0 -6px}
.image-edit-dlg .ie-h[data-h=bl]{margin:-6px 0 0 -12px}
.image-edit-dlg .ie-h[data-h=tl]::before,.image-edit-dlg .ie-h[data-h=tr]::before,.image-edit-dlg .ie-h[data-h=br]::before,.image-edit-dlg .ie-h[data-h=bl]::before{width:14px;height:14px;border:0 solid #fff}
.image-edit-dlg .ie-h[data-h=tl]::before{left:12px;top:12px;border-top-width:2px;border-left-width:2px}
.image-edit-dlg .ie-h[data-h=tr]::before{right:12px;top:12px;border-top-width:2px;border-right-width:2px}
.image-edit-dlg .ie-h[data-h=br]::before{right:12px;bottom:12px;border-bottom-width:2px;border-right-width:2px}
.image-edit-dlg .ie-h[data-h=bl]::before{left:12px;bottom:12px;border-bottom-width:2px;border-left-width:2px}
/* 辺：辺に沿った短いI字（上下は横棒、左右は縦棒。角丸）。当たり判定は辺の内外へ6px ずつ。 */
.image-edit-dlg .ie-h[data-h=t],.image-edit-dlg .ie-h[data-h=b]{width:24px;height:12px;margin:-6px 0 0 -12px}
.image-edit-dlg .ie-h[data-h=l],.image-edit-dlg .ie-h[data-h=r]{width:12px;height:24px;margin:-12px 0 0 -6px}
.image-edit-dlg .ie-h[data-h=t]::before,.image-edit-dlg .ie-h[data-h=b]::before{left:1px;top:4.5px;width:22px;height:3px;border-radius:2px;background:#fff}
.image-edit-dlg .ie-h[data-h=l]::before,.image-edit-dlg .ie-h[data-h=r]::before{left:4.5px;top:1px;width:3px;height:22px;border-radius:2px;background:#fff}
.image-edit-dlg .ie-h[data-h=tl],.image-edit-dlg .ie-h[data-h=br]{cursor:nwse-resize}
.image-edit-dlg .ie-h[data-h=tr],.image-edit-dlg .ie-h[data-h=bl]{cursor:nesw-resize}
.image-edit-dlg .ie-h[data-h=t],.image-edit-dlg .ie-h[data-h=b]{cursor:ns-resize}
.image-edit-dlg .ie-h[data-h=l],.image-edit-dlg .ie-h[data-h=r]{cursor:ew-resize}
.image-edit-dlg .ie-h:focus-visible{outline:2px solid var(--focus);outline-offset:1px}
.image-edit-dlg .ie-tools{display:grid;gap:10px;margin-top:12px}
.image-edit-dlg .ie-rot{display:flex;gap:6px}
.image-edit-dlg .ie-icon{width:36px;height:36px;display:inline-flex;align-items:center;justify-content:center;padding:0;border:1px solid var(--line);border-radius:6px;background:var(--surface);color:var(--text);cursor:pointer}
.image-edit-dlg .ie-icon svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;pointer-events:none}
.image-edit-dlg .ie-flip svg{transform:scaleX(-1)}
.image-edit-dlg .ie-row{display:flex;justify-content:space-between;align-items:center;gap:12px;flex-wrap:wrap}
.image-edit-dlg .ie-ratio{display:flex;align-items:center;gap:8px;font-size:13px}
.image-edit-dlg .ie-ratio select{min-height:36px;padding:4px 8px;border:1px solid var(--field-line);border-radius:var(--radius);background:var(--field-bg);color:var(--text);font:inherit;font-size:14px}
.image-edit-dlg .ie-cap{display:grid;gap:4px;font-size:13px}
.image-edit-dlg .ie-cap input{width:100%;box-sizing:border-box;min-height:38px;margin:0;padding:8px 10px;border:1px solid var(--field-line);border-radius:var(--radius);background:var(--field-bg);color:var(--text);font:inherit;font-size:14px}
/* キャンセル・保存はタイトル行の右端に置く（下部の帯は出さない）。並び（DOM）はキャプションの後のまま＝フォーカス順は従来どおり。 */
.image-edit-dlg .ie-form{position:relative;margin:0}
:root dialog.ui.image-edit-dlg .dlg-actions{position:absolute;top:16px;right:24px;display:flex;gap:8px;margin:0;padding:0;background:none;border:0;border-radius:0}
:root dialog.ui.image-edit-dlg .ie-body>h2{padding-right:190px}
:root dialog.ui.image-edit-dlg .ie-body{padding-bottom:20px}
@media (max-width:800px){:root dialog.ui.image-edit-dlg .dlg-actions{top:12px;right:16px}:root dialog.ui.image-edit-dlg .ie-body>h2{padding-right:170px}:root dialog.ui.image-edit-dlg .ie-body{padding-bottom:16px}}
.image-edit-dlg .ie-info{margin:0;font-size:13px;color:var(--muted)}
.image-edit-dlg .ie-info:empty{display:none}
.image-edit-dlg .ie-info[data-error]{color:#b42318}
