/* 記事切り抜き 試作 — スタイル
   スマートフォンのタッチ操作を主対象にする。
   ボタンは指で押しやすい大きさ（最低44px相当）を確保する。
   画像読込み後は、Instagramの投稿編集画面に近い1画面型（小さなヘッダー／常に見える
   大きなキャンバス／下部固定ツールバー＋ボトムシート）で編集する。
   配色は「暗い背景・落ち着いた金・生成り色」のアプリらしいトーンにする（2026-11-15：
   3案比較の末に「カメラ編集」案へ一本化）。外部フォント・画像素材は使わず、色とCSS・インラインSVGのみで作る。 */

:root {
  --color-bg: #17171a;
  --color-surface: #1e1e22;
  --color-text: #e7e4de;
  --color-text-soft: #97928a;
  --color-accent: #b4925e;
  --color-accent-bg: #2a241d;
  --color-accent-ink: #e2cda3;
  --color-accent-contrast: #1a1712; /* 金の地には濃い文字を乗せる */
  --color-blue: #8b9bb3;
  --color-blue-bg: #20242b;
  --color-border: #36332d;
  --color-panel-bg: #201f22;
  --color-notice-bg: #20242b;
  --color-required: #c9705a;
  --color-comment-bg: #3a3328;
  --color-candidate: #8fa391;
  --radius-card: 16px;
  --radius-btn: 14px;
  --radius-tile: 14px;
  --font-main: "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
  --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.3);
  --touch-min: 44px;
  /* window.visualViewport の高さ（px）。JS側で常に最新値へ更新する。
     未対応環境向けに、まずJSのフォールバック値が入るまでの初期値を100vhにしておく。 */
  --vv-height: 100vh;
  /* 編集画面の高さ：キーボードの表示では変えない（JSが window.innerHeight から設定する） */
  --app-height: 100vh;
  /* iPhoneのセーフエリア（ホームインジケータ等）。非対応環境では0として扱われる。 */
  --safe-top: env(safe-area-inset-top, 0px);
  --credit-h: 16px; /* 最下部のクレジットの帯（2026-11-18-x3）。下に置く操作はこのぶん上へ */
  --safe-bottom: calc(env(safe-area-inset-bottom, 0px) + var(--credit-h));
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}
/* ライト（2026-11-17-4。初めの表示）：生成りの地に墨の文字、落ち着いた金。ダークは上の値のまま */
:root[data-theme="light"] {
  color-scheme: light;
  --color-bg: #f5f1e8;
  --color-surface: #ffffff;
  --color-text: #2b2620;
  --color-text-soft: #6e665a;
  --color-accent: #9c7741;
  --color-accent-bg: #f1e7d5;
  --color-accent-ink: #6b4f24;
  --color-accent-contrast: #ffffff;
  --color-blue: #3d5a80;
  --color-blue-bg: #e6ecf3;
  --color-border: #dcd3c4;
  --color-panel-bg: #efeae0;
  --color-notice-bg: #e9eef4;
  --color-required: #b3402a;
  --color-comment-bg: #efe4d0;
  --color-candidate: #4f6b52;
  --shadow-card: 0 4px 14px rgba(60, 45, 25, 0.12);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-main);
  line-height: 1.6;
}

/* 横スクロールを発生させない。
   htmlとbody両方にoverflow-xを指定すると、bodyが独自のスクロール
   コンテナになってしまい、内部のposition:stickyが効かなくなる
   （実際にスクロールしているのはhtml側のため）。htmlだけに指定する。 */
html {
  overflow-x: hidden;
}

header, main, footer {
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 16px;
}

/* 編集画面（#step-edit）を表示している間は、mainの幅上限・左右余白を外し、
   キャンバスがiPhoneでは実質フル幅、Mac等の広い画面でも大きく使えるようにする。
   （:has()はSafari 15.4+/Chrome 105+で対応。未対応環境ではmax-width:480pxのまま
   ＝これまでどおりの表示になるだけで、機能そのものは損なわれない。） */
main:has(> #step-edit:not([hidden])) {
  /* 2026-10-23-9：iPadなど広い画面でも紙面を大きく出すため、幅の上限（以前は640px）を外す */
  max-width: none;
  padding: 0;
}

h1 {
  font-size: 1.15rem;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  letter-spacing: 0.02em;
}
/* アプリ名（2026-11-25-event8 で「新聞で話そう」に）：題名と、その直下の一言。起動画面でいちばん目立つ文字にする
   （カードの中の見出し「新聞を読んで、考えたことを一枚に」は外した） */
header:has(> h1.app-name) {
  padding-top: 32px;
  padding-bottom: 0;
  text-align: center;
}
/* 2026-11-17-4：親しみやすく：丸みのある書体、小さな吹き出しの印、一言はやわらかい札に */
h1.app-name {
  margin: 0;
  font-family: ui-rounded, "Hiragino Maru Gothic ProN", "Arial Rounded MT Bold", "Hiragino Sans", sans-serif;
  font-size: clamp(1.8rem, 10.5vw, 2.4rem); /* 幅320pxでも1行に収める */
  font-weight: 700;
  white-space: nowrap;
  line-height: 1.15;
  letter-spacing: 0.01em;
  color: var(--color-text);
}
.app-name-bubble {
  display: inline-block;
  margin-right: 0.25em;
  padding: 0 0.32em 0.12em;
  font-size: 0.62em;
  line-height: 1.2;
  vertical-align: 0.28em;
  color: var(--color-accent-contrast);
  background: var(--color-accent);
  border-radius: 0.6em 0.6em 0.6em 0.15em;
}
.app-tagline {
  display: inline-block;
  margin: 10px 0 0;
  padding: 2px 14px;
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Sans", sans-serif;
  font-size: 1.15rem;
  font-weight: bold;
  letter-spacing: 0.06em;
  color: var(--color-accent-ink);
  background: var(--color-accent-bg);
  border-radius: 999px;
}
.app-version {
  margin: 10px 0 0;
  font-size: 0.78rem;
  color: var(--color-text-soft);
}
.app-version-badge {
  padding: 1px 8px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
}
.about-theme-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 10px;
}
.simple-about-btn {
  flex: 0 0 auto;
  min-width: 44px;
}

h2 {
  font-size: 1rem;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  border-left: 4px solid var(--color-accent);
  padding-left: 8px;
  margin-top: 0;
}

.notice {
  background: var(--color-notice-bg);
  border: 1px solid var(--color-accent);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 0.85rem;
}

.step {
  border-top: 1px solid var(--color-border);
  padding-top: 16px;
  margin-top: 16px;
}

.hint {
  font-size: 0.9rem;
  color: var(--color-text-soft);
}

label {
  display: block;
  margin-top: 10px;
  font-size: 0.95rem;
  font-weight: bold;
}

.required {
  color: var(--color-required);
  font-weight: normal;
  font-size: 0.8rem;
}

input[type="text"],
input[type="date"],
textarea {
  width: 100%;
  padding: 10px;
  font-size: 1rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  margin-top: 4px;
}

input[type="range"] {
  width: 100%;
  margin-top: 8px;
}

textarea {
  background: var(--color-comment-bg);
  resize: vertical;
}

fieldset {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  margin-top: 12px;
}

button {
  display: inline-block;
  min-height: var(--touch-min);
  min-width: var(--touch-min);
  padding: 10px 18px;
  margin: 6px 4px 6px 0;
  font-size: 1rem;
  font-family: inherit;
  border: none;
  border-radius: var(--radius-btn);
  background: var(--color-accent);
  color: var(--color-accent-contrast);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

button:active:not(:disabled) {
  transform: scale(0.96);
}

button:disabled {
  background: #333029;
  color: #716c62;
  cursor: not-allowed;
}

/* チェックボックス付きの補助ラベル（マーカーの吸着・動きの一括オフなど） */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: normal;
  margin-top: 10px;
  min-height: var(--touch-min);
}

.checkbox-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
}

input[type="file"] {
  margin-top: 8px;
}

/* --- 画像読込み画面：使ってみたくなる「プロダクト画面」に見せるヒーローカード --- */
.hero-step {
  border-top: none;
  padding-top: 24px;
}

.hero-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 28px 22px 24px;
  text-align: center;
}

.hero-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 10px;
  color: var(--color-accent);
}

.hero-icon svg {
  width: 100%;
  height: 100%;
}

.hero-lead {
  font-size: 0.92rem;
  color: var(--color-text-soft);
  margin: 0 0 14px;
}

.local-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-blue-bg);
  color: var(--color-blue);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.78rem;
  font-weight: bold;
  margin: 0 auto 12px;
}

.local-badge svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.hero-note {
  font-size: 0.78rem;
  color: var(--color-text-soft);
  margin: 0 0 4px;
}

/* --- 画像読込み：撮影／選択の2ボタン --- */
.file-input-row {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.file-btn {
  flex: 1;
  min-width: 140px;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px;
  margin: 0;
  font-size: 0.95rem;
  font-weight: bold;
  border-radius: 10px;
  background: var(--color-surface);
  color: var(--color-text);
  border: 1.5px solid var(--color-border);
  text-align: center;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(43, 36, 29, 0.06);
}

.file-btn-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.file-btn-primary {
  background: var(--color-accent);
  color: var(--color-accent-contrast);
  border-color: var(--color-accent);
  box-shadow: 0 3px 10px rgba(179, 64, 42, 0.3);
}

/* --- 引用範囲を画面に合わせるボタン --- */
.fit-btn {
  display: block;
  width: 100%;
  margin: 10px 0 0;
  background: #2f7d3a;
}

.fit-btn:disabled {
  background: #b7a98c;
}

/* --- 新聞名プリセットなど、選択式ボタン群の共通スタイル --- */
.mode-buttons {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.mode-btn {
  flex: 1;
  background: var(--color-surface);
  color: var(--color-text);
  margin: 0;
}

.mode-btn.active {
  background: var(--color-accent);
  color: var(--color-accent-contrast);
}

/* 背景スタイルなど、項目数が多く折り返しが必要なボタン列 */
.mode-buttons.wrap-buttons {
  flex-wrap: wrap;
}

.mode-buttons.wrap-buttons .bg-style-btn,
.mode-buttons.wrap-buttons .source-badge-style-btn {
  flex: 0 0 auto;
  min-width: 72px;
}

#source-badge-block {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--color-border);
}

/* --- コメントの背景スタイル選択ボタン（色つき、選択中は太い枠で示す） --- */
.bg-style-btn {
  border: 2px solid var(--color-border);
  font-size: 0.8rem;
}

.bg-style-btn-none {
  background: repeating-linear-gradient(
    45deg,
    var(--color-surface),
    var(--color-surface) 6px,
    var(--color-panel-bg) 6px,
    var(--color-panel-bg) 12px
  );
  color: var(--color-text);
}

.bg-style-btn.active {
  border-color: var(--color-accent);
  border-width: 3px;
}

/* ============================================================
   画像読込み後の1画面編集
   #step-edit を、小さなヘッダー／常に見える大きなキャンバス／
   ボトムシート／下部固定ツールバーの縦積みflexにする。
   高さは window.visualViewport（キーボード表示時などに変化する）に
   追従させ、長い縦スクロールが生まれないようにする。
   main の左右パディングを打ち消し、ツールバー等を横幅いっぱいに使う。
   ============================================================ */
#step-edit {
  display: flex;
  flex-direction: column;
  width: 100%;
  margin: 0;
  padding-top: 0;
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  border-top: none;
  /* 2026-10-23-9：以前は画面の高さより24px低くしていた（紙面の下に使わない帯が残っていた） */
  height: var(--app-height);
  max-height: var(--app-height);
  overflow: hidden;
  background: var(--color-bg);
}

/* display:flex が hidden 属性より優先され、読込み画面・切り抜き画面の下に編集画面が
   表示されたままになっていたため、明示的に隠す */
#step-edit[hidden] {
  display: none;
}

/* --- 小さなヘッダー --- */
#editor-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  padding-top: calc(4px + var(--safe-top));
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
}

#editor-header-text {
  flex: 1 1 auto;
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.3;
  color: var(--color-text-soft);
  min-width: 0;
}

/* 開いた説明は、ヘッダーの下に重ねて表示する（ヘッダーの高さを変えず、キャンバスを動かさない） */
#editor-header {
  position: relative;
}

#editor-header-text[open] > p {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 100%;
  z-index: 20;
  margin: 4px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.9rem;
  line-height: 1.5;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}

/* 「詳しく」などで開ける説明（details.more-info）の共通の見た目 */
.more-info > summary {
  cursor: pointer;
  list-style: none;
  color: var(--color-text-soft);
}

.more-info > summary::-webkit-details-marker {
  display: none;
}

.more-info > summary::after {
  content: " ⓘ";
}

.more-info[open] > summary::after {
  content: " ×";
}

.sheet-panel .more-info {
  margin: 4px 0 8px;
}

.sheet-panel .more-info > summary {
  font-size: 0.85rem;
  padding: 6px 0;
}

.sheet-panel .more-info > p {
  margin: 4px 0 0;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--color-text-soft);
}

.editor-header-btn {
  flex: 0 0 auto;
  min-height: var(--touch-min);
  padding: 4px 8px;
  margin: 0;
  font-size: 0.85rem;
  background: var(--color-surface);
  color: var(--color-text);
  white-space: nowrap;
}

/* --- 初回だけの操作案内バナー：キャンバスの外（editor-headerの下）に置き、
   選択枠やキャンバスには一切重ならない。閉じるとlocalStorageに記録される。 --- */
#first-run-hint {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--color-blue-bg);
  border-bottom: 1px solid var(--color-border);
}

/* display:flex が hidden 属性より優先されて×で閉じられなかったため、明示的に隠す */
#first-run-hint[hidden] {
  display: none;
}

#first-run-hint p {
  flex: 1 1 auto;
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--color-blue);
}

#first-run-hint-close {
  flex: 0 0 auto;
  min-width: var(--touch-min);
  min-height: var(--touch-min);
  padding: 0;
  margin: 0;
  background: transparent;
  color: var(--color-blue);
  font-size: 1.1rem;
  line-height: 1;
}

.editor-header-btn:disabled {
  background: var(--color-surface);
  color: var(--color-border);
  opacity: 0.6;
}

/* ============================================================
   キャンバスビューポート：ツール（フローティングバー）・ポップオーバー
   （旧ボトムシート）・ズームHUD・アクション行は、すべてこの上に「重なる」
   絶対配置のオーバーレイとして置く。ツールの開閉やパネル切替でこの箱自体の
   大きさは一切変わらないため、キャンバスの表示サイズ・画像の位置やズームは
   常に維持される。
   ============================================================ */
#canvas-viewport {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  margin: 8px 12px 4px;
  border-radius: 8px;
  overflow: hidden;
  /* 完成画像（キャンバス）の外側は、紙面や仕上がりの色と紛らわしくない、明確に
     「作業用の余白」とわかる中立なグレーの縞模様にする。書き出しにはこの領域は
     一切含まれない。 */
  background:
    repeating-linear-gradient(
      135deg,
      #babcc0 0px,
      #babcc0 10px,
      #a9abaf 10px,
      #a9abaf 20px
    );
  border: 1px solid var(--color-border);
}

/* 完成画像エリア＝canvas要素そのものの境界を、周囲の作業用余白とはっきり区別する */
#edit-canvas {
  box-shadow: 0 0 0 2px #ffffff, 0 0 0 3px rgba(20, 20, 22, 0.75), 0 2px 14px rgba(0, 0, 0, 0.35);
}

/* 「完成画像エリア」表示：キャンバスの境界は枠線と影で区別できるため、上部の操作帯と
   重なる小さなラベルは表示しない（要素とJSの位置計算は残す） */
#canvas-frame-label,
#canvas-frame-label:not([hidden]) {
  display: none;
}

#canvas-frame-label {
  position: absolute;
  z-index: 4;
  transform: translateY(-100%);
  padding: 3px 8px;
  margin-bottom: 4px;
  border-radius: 4px 4px 0 0;
  background: rgba(20, 20, 22, 0.75);
  color: #fff;
  font-size: 0.66rem;
  font-weight: bold;
  letter-spacing: 0.02em;
  white-space: nowrap;
  pointer-events: none;
}

#canvas-wrap {
  position: absolute;
  inset: 0;
  /* 下側はフローティングツールバーの高さぶん、常に余白を確保しておく
     （ツールバーの表示・非表示でキャンバスの実効表示サイズを変えないよう、
     開閉に関係なく常にこの余白を確保する）。パネルを開いている間は、
     JS（refreshCanvasWrapReserve）がこの初期値の上から4辺の余白を書き換え、
     完成画像全体がパネルの下に隠れないようにする。 */
  /* 上側は操作帯（#canvas-topbar、高さ44px＋上下6px）のぶんを確保する */
  padding: 56px 14px 76px;
  padding-bottom: calc(76px + var(--safe-bottom));
  display: flex;
  align-items: center;
  justify-content: center;
  /* viewZoom（表示ズーム）のtranslate+scaleは、canvasViewport左上を原点とする
     px単位の計算（setViewZoom等）を前提にしている。transform-originを既定の
     中央（50% 50%）のままにすると、scaleが要素中心を基準にかかってしまい、
     ピンチ操作の中心が指の位置からずれる（拡大縮小のたびに位置が飛ぶ）原因になる。
     原点を左上（0 0）に揃えることで、計算どおりピンチ中心の紙面位置が指の下に
     留まるようにする。 */
  transform-origin: 0 0;
}

canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
}

/* Canvas上のドラッグ・2本指ピンチ・トラックパッドのジェスチャーを、iPhoneでも
   Mac Chromeでも確実にアプリ側へ渡す（ブラウザ標準のページズーム・スクロールに
   奪われないようにする）。 */
#edit-canvas {
  touch-action: none;
  overscroll-behavior: contain;
}

/* --- キャンバス上部の操作帯：「仕上がり」切替と表示の拡大縮小を1行に並べる。
   キャンバスは帯の下から始まる（#canvas-wrap の上側の余白＝帯の高さ）ため、通常の表示では
   紙面や取っ手に重ならない。帯そのものは指の操作を通し、ボタンだけが操作を受け取る。 --- */
#canvas-topbar {
  position: absolute;
  top: 6px;
  left: 6px;
  right: 6px;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 5;
  pointer-events: none;
}

#canvas-topbar > * {
  pointer-events: auto;
}

/* 「仕上がり」トグル：帯の左端。ツール切替では動かない */
#finished-view-toggle {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 40px;
  padding: 6px 12px 6px 9px;
  margin: 0;
  border-radius: 999px;
  background: rgba(43, 36, 29, 0.78);
  color: #fff;
  font-size: 0.85rem;
  font-weight: bold;
  white-space: nowrap;
}

#finished-view-toggle svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

#finished-view-toggle[aria-pressed="true"] {
  background: var(--color-accent);
  color: var(--color-accent-contrast);
}

/* 「画像を動かす」：オンの間は色を変え、紙面の周りにも色の枠を出して、いま画像全体を動かしていると分かるようにする */
#image-move-toggle {
  flex: 0 1 auto;
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 40px;
  padding: 6px 12px 6px 9px;
  margin: 0;
  border-radius: 999px;
  background: rgba(43, 36, 29, 0.78);
  color: #fff;
  font-size: 0.85rem;
  font-weight: bold;
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

#image-move-toggle svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

#image-move-toggle[aria-pressed="true"] {
  background: #1a5fb4;
}

#canvas-viewport.image-move-mode {
  box-shadow: inset 0 0 0 4px #1a5fb4;
}

/* 表示の拡大縮小：帯の右端 */
#zoom-hud {
  flex: 0 0 auto;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 1px;
  background: rgba(43, 36, 29, 0.78);
  border-radius: 999px;
  padding: 2px;
}

.zoom-hud-btn {
  min-width: 36px;
  min-height: 36px;
  margin: 0;
  padding: 0 7px;
  border-radius: 999px;
  background: transparent;
  color: #fff;
  font-size: 0.9rem;
  font-weight: bold;
  line-height: 1;
}

.zoom-hud-btn:active:not(:disabled) {
  background: rgba(255, 255, 255, 0.18);
  transform: none;
}

.zoom-hud-value {
  min-width: 50px;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.zoom-hud-fit {
  min-width: auto;
  padding: 0 10px;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  border-left: 1px solid rgba(255, 255, 255, 0.25);
  margin-left: 2px;
}

/* --- 追加操作中のキャンセル、選択中要素の削除：キャンバス下端に浮かぶ小さな行 --- */
#canvas-action-row {
  position: absolute;
  left: 50%;
  bottom: 66px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 6;
  max-width: calc(100% - 16px);
}

#action-buttons {
  display: flex;
  justify-content: center;
  gap: 8px;
}

#action-buttons .tool-btn {
  min-width: 56px;
  min-height: 44px;
  padding: 8px 10px;
  white-space: nowrap;
}

#action-buttons .tool-btn[hidden] {
  display: none;
}

.tool-btn.quiet-btn {
  background: rgba(43, 36, 29, 0.82);
}

/* 範囲の角度：指で押しやすい大きさのボタンとスライダー */
#angle-controls {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 6px;
  border-radius: 14px;
  background: rgba(43, 36, 29, 0.86);
  color: #fff;
  width: 340px;
  max-width: 100%;
}

#angle-controls[hidden] {
  display: none;
}

.angle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.angle-btn {
  flex: 1 1 0;
  min-height: 44px;
  margin: 0;
  padding: 4px 2px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 0.9rem;
  font-weight: bold;
  white-space: nowrap;
}

.angle-btn.angle-wide {
  flex: 2 1 0;
}

.angle-value {
  flex: 1 1 0;
  text-align: center;
  font-size: 1rem;
  font-weight: bold;
  font-variant-numeric: tabular-nums;
}

#angle-slider {
  width: 100%;
  min-height: 32px;
  margin: 0;
}

/* 操作の状況表示：キャンバスの上の1行。空でも高さを保ち、キャンバスの位置を動かさない */
#edit-status {
  flex: 0 0 auto;
  height: 1.5em;
  margin: 4px 14px 0;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--color-text);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#edit-status:empty {
  visibility: hidden;
}

#cancel-add-btn {
  background: var(--color-text-soft);
}

.tool-btn.delete-btn {
  background: var(--color-required);
}

#cancel-add-btn[hidden],
.delete-btn[hidden] {
  display: none;
}

/* --- コメントのインライン編集オーバーレイ：選択中コメントの矩形に正確に重ねて
   配置する（位置・大きさはJSが毎回計算してインラインスタイルへ書き込む）。
   文字色を透明にし、Canvas側の描画（実際の書体・色・効果つき）をそのまま見せながら、
   カーソル（caret）と選択範囲のハイライトだけは見えるようにする。 --- */
/* --- 文字の直接編集：紙面の文字と同じ位置・見た目で重ねる（JSが位置・書体・色・飾りを合わせる） --- */
.comment-inline-editor {
  position: absolute;
  z-index: 6;
  margin: 0;
  border: none;
  border-radius: 0;
  outline: 2px dashed rgba(26, 95, 180, 0.85);
  outline-offset: 2px;
  resize: none;
  overflow: hidden;
  transform-origin: 0 0;
  white-space: pre-wrap;
  word-break: break-all;
  overflow-wrap: anywhere;
  -webkit-user-select: text;
  user-select: text;
  -webkit-text-size-adjust: 100%;
}
.comment-inline-editor[hidden] {
  display: none;
}
.comment-inline-editor::placeholder {
  color: rgba(43, 36, 29, 0.45);
}
.inline-done-btn {
  position: absolute;
  z-index: 8;
  width: auto;
  min-width: 88px;
  min-height: 44px;
  margin: 0;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--color-blue);
  color: #ffffff;
  font-size: 1rem;
  font-weight: bold;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
  touch-action: manipulation;
}
.inline-done-btn[hidden] {
  display: none;
}

/* --- シートの背後の半透明スクリム：タップで閉じる。
   フローティングツールバー（z-index 8）より下に置き、シートを開いたままでも
   ツールバーのタブ切替はそのまま操作できるようにする。 --- */
#sheet-scrim {
  position: absolute;
  inset: 0;
  background: rgba(43, 36, 29, 0.28);
  z-index: 7;
  opacity: 0;
  transition: opacity 0.2s ease;
}

#sheet-scrim.scrim-visible {
  opacity: 1;
}

#sheet-scrim[hidden] {
  display: none;
}

/* --- ポップオーバー（旧ボトムシート）：画像の上に重なるカードとして浮かぶ。
   選択中の要素・見せたい範囲を隠さない側（上下、広い画面では左右も）をJS側
   （applySheetDock）が選び、位置（--sheet-base-x/-y）・大きさ（width/max-height）を
   px単位で計算してそのつどインラインスタイルへ書き込む。ここでは、その値を
   「transformで動かす」ことだけを担当する。left/right/top/bottomをdockごとに
   使い分けると値がautoへ切り替わり飛んでしまうため、常にtransform（translate）だけで
   動かすことで、どの側へ移っても滑らかにアニメーションする。つまみ行をドラッグすると
   自由な位置へ動かせ（--sheet-drag-x/--sheet-drag-y、基準位置に加算する）、最小化ボタンで
   タイトル行だけに畳める（.sheet-minimized）。内容はカード内部だけでスクロールする。
   開閉に軽いスライド＋フェードの動きを付ける（[hidden]切替えの直後にJS側で
   .sheet-open を付け外しし、opacityを遷移させる）。 --- */
#bottom-sheet {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 9;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--color-border);
  border-radius: 16px;
  background: color-mix(in srgb, var(--color-panel-bg) 96%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  box-shadow: 0 8px 28px rgba(43, 36, 29, 0.25);
  padding: 12px 12px 14px;
  transform: translate(
    calc(var(--sheet-base-x, 10px) + var(--sheet-drag-x, 0px)),
    calc(var(--sheet-base-y, 10px) + var(--sheet-drag-y, 0px) + 8px)
  );
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.24s cubic-bezier(0.2, 0.7, 0.3, 1), width 0.24s ease, max-height 0.24s ease;
}

#bottom-sheet.sheet-open {
  transform: translate(
    calc(var(--sheet-base-x, 10px) + var(--sheet-drag-x, 0px)),
    calc(var(--sheet-base-y, 10px) + var(--sheet-drag-y, 0px))
  );
  opacity: 1;
}

#bottom-sheet[hidden] {
  display: none;
}

/* 最小化：タイトル行だけを残し、本体を畳む */
#bottom-sheet.sheet-minimized {
  max-height: none;
  overflow: visible;
  padding-bottom: 4px;
}
#bottom-sheet.sheet-minimized #sheet-body {
  display: none;
}
#bottom-sheet.sheet-minimized::before {
  display: none;
}

/* シート上端の「つまみ」（iOSのボトムシートを思わせる装飾。画像等は使わずCSSのみ）。
   ドラッグ操作の対象であることも示す。 */
#bottom-sheet::before {
  content: "";
  display: block;
  width: 36px;
  height: 4px;
  margin: -6px auto 10px;
  border-radius: 2px;
  background: var(--color-border);
}

#sheet-handle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 8px;
}

#sheet-title {
  font-size: 1.02rem;
  font-weight: bold;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  color: var(--color-accent-ink);
  flex: 1 1 auto;
  min-width: 0;
}

#sheet-minimize-btn,
#sheet-close-btn {
  flex: 0 0 auto;
  min-height: var(--touch-min);
  min-width: var(--touch-min);
  padding: 0 12px;
  margin: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  font-size: 0.9rem;
  font-weight: bold;
  line-height: 1;
  white-space: nowrap;
}

.sheet-panel[hidden] {
  display: none;
}

.sheet-panel .hint {
  margin-top: 0;
}

.sheet-panel label:first-child {
  margin-top: 0;
}

/* --- フローティングツールバー：6つのツール。画像の上に浮かぶ丸みのあるバーとして
   下端中央に固定し、開閉してもキャンバスの表示サイズには影響しない。 --- */
#toolbar {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 10px;
  z-index: 8;
  display: flex;
  border-radius: 16px;
  background: color-mix(in srgb, var(--color-panel-bg) 92%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 18px rgba(43, 36, 29, 0.22);
  margin-bottom: var(--safe-bottom);
  overflow: hidden;
}

.tool-tab-btn {
  flex: 1 1 0;
  min-height: 52px;
  min-width: var(--touch-min);
  margin: 0;
  padding: 7px 1px 6px;
  border-radius: 0;
  border-top: 3px solid transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  /* iPhone幅（7つで1つ約50px）でも4文字のラベルが1行に収まる大きさ */
  font-size: 0.72rem;
  white-space: nowrap;
  background: transparent;
  color: var(--color-text-soft);
}

.tool-tab-icon {
  width: 20px;
  height: 20px;
}

.tool-tab-label {
  line-height: 1;
}

.tool-tab-btn.active {
  background: var(--color-accent-bg);
  color: var(--color-accent-ink);
  border-top-color: var(--color-accent);
  font-weight: bold;
}

/* ツール内の「追加」ボタン・プレビューボタンなど（ボトムシート内） */
.tool-btn {
  min-width: 96px;
  margin: 0;
  padding: 8px 10px;
  font-size: 0.95rem;
  background: var(--color-accent);
  color: var(--color-accent-contrast);
}

.tool-btn.cancel-btn {
  background: var(--color-text-soft);
}

.tool-btn.preview-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  background: #3f6b4a;
}

.tool-btn.detect-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  background: var(--color-candidate);
}

/* --- 見出し候補（試作機能）：一覧・採用／却下ボタン --- */
.headline-detect-block {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--color-border);
}

/* --- スタンプ（図形・矢印・記号）：パレットと選択中の図形の設定 --- */
.stamp-block {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--color-border);
}

.stamp-palette {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 6px;
}

.stamp-btn {
  min-height: var(--touch-min);
  min-width: var(--touch-min);
  margin: 0;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
}

.stamp-btn svg {
  width: 22px;
  height: 22px;
}

.stamp-btn-glyph {
  font-size: 1.2rem;
  font-weight: 900;
}

#shape-edit-block {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--color-border);
}

.swatch-btn-none {
  background: repeating-linear-gradient(
    45deg,
    var(--color-surface),
    var(--color-surface) 5px,
    var(--color-panel-bg) 5px,
    var(--color-panel-bg) 10px
  );
}

.candidate-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
}

.candidate-list li {
  padding: 8px;
  margin-bottom: 6px;
  background: var(--color-surface);
  border: 1px solid var(--color-candidate);
  border-radius: 6px;
  font-size: 0.9rem;
}

.candidate-list li.selected {
  border-width: 2px;
  background: #faf1da;
}

.candidate-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.candidate-btn-row .stepper-btn {
  flex: 1 1 auto;
  min-width: 64px;
}

.candidate-accept-btn {
  background: var(--color-accent);
  color: var(--color-accent-contrast);
}

/* --- 仕上げ：マスク方式ごとの調整スライダー --- */
.mask-param-row {
  margin-top: 10px;
}

.mask-param-row[hidden] {
  display: none;
}

.mode-controls {
  margin-top: 10px;
  padding: 10px;
  background: var(--color-panel-bg);
  border-radius: 6px;
}

/* --- 引用範囲一覧・サイズ調整 --- */
#rect-list {
  list-style: none;
  margin: 8px 0;
  padding: 0;
}

#rect-list li {
  padding: 8px;
  margin-bottom: 4px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
}

#rect-list li.selected {
  border-color: var(--color-accent);
  border-width: 2px;
  background: var(--color-accent-bg);
}

.stepper-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.stepper-label {
  font-size: 0.9rem;
  font-weight: bold;
  width: 100%;
}

.stepper-btn {
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.9rem;
  padding: 8px 10px;
  margin: 0;
}

.stepper-btn.danger {
  background: #f6d3d3;
  color: var(--color-required);
}

.stepper-btn.active {
  background: var(--color-accent);
  color: var(--color-accent-contrast);
}

/* --- 微調整（±ボタン）：主要な操作はハンドルのドラッグなので、
   こちらは折りたたみ、小さく控えめな見た目にする --- */
.fine-adjust {
  margin-top: 10px;
}

.fine-adjust summary {
  font-size: 0.9rem;
  color: var(--color-text-soft);
  cursor: pointer;
  min-height: var(--touch-min);
  display: flex;
  align-items: center;
}

.fine-adjust .stepper-row {
  margin-top: 4px;
  opacity: 0.85;
}

.fine-adjust .stepper-btn {
  font-size: 0.88rem;
  padding: 6px 8px;
  min-height: 36px;
}

/* --- コメント文字サイズ・書体 --- */
.font-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.font-btn {
  background: var(--color-surface);
  color: var(--color-text);
  margin: 0;
}

.font-btn.active {
  background: var(--color-accent);
  color: var(--color-accent-contrast);
}

/* --- 書体プレビューチップ：ボタンの文字自体をその書体で表示する --- */
.font-chip[data-family="system"],
.font-chip[data-badge-family="system"] { font-family: -apple-system, "Hiragino Sans", "Yu Gothic", sans-serif; }
.font-chip[data-family="gothic"],
.font-chip[data-badge-family="gothic"] { font-family: "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif; }
.font-chip[data-family="maru"],
.font-chip[data-badge-family="maru"] { font-family: "Hiragino Maru Gothic ProN", "UD Digi Kyokasho N-R", "Yu Gothic", sans-serif; }
.font-chip[data-family="mincho"],
.font-chip[data-badge-family="mincho"] { font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif; }
.font-chip[data-family="shinbun"],
.font-chip[data-badge-family="shinbun"] { font-family: "Hiragino Mincho ProN", "Yu Mincho", serif; font-weight: 900; letter-spacing: 0.03em; }
.font-chip[data-family="hand"],
.font-chip[data-badge-family="hand"] { font-family: "Klee One", "Yuji Syuku", "Hiragino Maru Gothic ProN", cursive, "Yu Gothic", sans-serif; }
.font-chip[data-family="boldgothic"],
.font-chip[data-badge-family="boldgothic"] { font-family: "Hiragino Sans", "Yu Gothic", sans-serif; font-weight: 900; }
.font-chip[data-family="manga"],
.font-chip[data-badge-family="manga"] { font-family: "Hiragino Sans", "Yu Gothic", sans-serif; font-weight: 900; letter-spacing: 0.02em; text-shadow: -1px -1px 0 currentColor, 1px 1px 0 rgba(0,0,0,0.15); }
.font-chip[data-family="typewriter"],
.font-chip[data-badge-family="typewriter"] { font-family: "Osaka-Mono", "Courier New", "Hiragino Sans", monospace; letter-spacing: 0.04em; }
.font-chip[data-family="pop"],
.font-chip[data-badge-family="pop"] { font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", sans-serif; font-weight: 900; letter-spacing: 0.05em; }

/* --- 現在選択中の色（名称）表示 --- */
.current-color-label {
  font-size: 0.82rem;
  font-weight: normal;
  color: var(--color-text-soft);
  margin-left: 6px;
}

/* --- カスタム色（ネイティブのカラーピッカー）：スウォッチと並べて置く小さなラベル --- */
.custom-color-swatch-label {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.8rem;
  color: var(--color-text-soft);
  cursor: pointer;
  vertical-align: top;
}

.custom-color-swatch-label input[type="color"] {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 2px solid var(--color-border);
  border-radius: 50%;
  background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red);
  cursor: pointer;
}

/* --- 道具の中の小見出し（マーカー・囲みの「図形」など） --- */
.stamp-category-label {
  font-size: 0.85rem;
  font-weight: bold;
  color: var(--color-text-soft);
  margin: 12px 0 2px;
}

.marker-edit-block {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--color-border);
}

/* --- コメントの文字色・背景色プリセット --- */
.swatch-row {
  margin-top: 10px;
}

.swatch-list {
  display: flex;
  gap: 6px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.swatch-btn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  margin: 0;
  border: 2px solid var(--color-border);
  border-radius: 50%;
}

.swatch-btn.active {
  border-color: var(--color-accent);
  border-width: 3px;
}

.status {
  font-size: 0.9rem;
  color: var(--color-text-soft);
  min-height: 1.2em;
}

.status.error {
  color: var(--color-required);
  font-weight: bold;
}

/* 面積の目安：判定ではなく事実の提示なので、エラー色（赤）とは分けて
   確認を促す色（アンバー）にする。 */
.status.caution {
  color: #8a4b00;
  font-weight: bold;
}

/* 「試験機能」であることを正直に伝える注意書き */
.feature-caution {
  background: var(--color-notice-bg);
  border-left: 3px solid #8a4b00;
  border-radius: 4px;
  padding: 8px 10px;
  color: #6b4400;
}

/* --- 保存前の案内：適法性を断定せず、確認と責任の所在だけを短く伝える --- */
.legal-hint {
  font-size: 0.88rem;
  color: var(--color-text-soft);
  background: var(--color-panel-bg);
  border-left: 3px solid var(--color-accent);
  border-radius: 4px;
  padding: 8px 10px;
  margin: 8px 0;
}

footer {
  font-size: 0.8rem;
  color: var(--color-text-soft);
  border-top: 1px solid var(--color-border);
  margin-top: 24px;
}

/* --- プレビュー・保存共有モーダル --- */
.modal-overlay[hidden] {
  display: none;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-box {
  position: relative;
  background: #fff;
  border-radius: 10px;
  padding: 16px;
  max-width: 480px;
  width: 100%;
  max-height: 92dvh;
  overflow-y: auto;
  text-align: center;
}

.modal-box h2 {
  font-size: 1rem;
  border-left: 4px solid var(--color-accent);
  padding-left: 8px;
  margin: 0 0 8px;
  text-align: left;
}

.modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  min-width: var(--touch-min);
  min-height: var(--touch-min);
  padding: 0;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 1.2rem;
  line-height: 1;
}

#save-modal-img,
#preview-modal-img {
  display: block;
  width: 100%;
  max-height: 60dvh;
  height: auto;
  object-fit: contain;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  margin: 8px 0;
  background: var(--color-panel-bg);
}

.secondary-btn {
  background: var(--color-surface);
  color: var(--color-text);
  width: 100%;
  margin: 6px 0 0;
}

/* 入力欄の文字が16px未満だと、iPhoneのSafariは入力時に画面を自動で拡大してしまうため、
   入力欄は16px以上にそろえる（読みやすさのためにも小さくしない） */
input[type="text"],
input[type="date"],
input[type="number"],
select,
textarea {
  font-size: 16px;
}

/* ============================================================
   記事の切り抜き画面（#step-crop）：写真全体を表示し、対象記事を四角で囲む。
   編集画面と同じく画面いっぱいを使い、下に「キャンセル／紙面全体で進む／この範囲で切り抜く」を置く。
   ============================================================ */
main:has(> #step-crop:not([hidden])) {
  max-width: 640px;
  padding: 0;
}

#step-crop {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: calc(var(--vv-height) - 24px);
  max-height: calc(var(--vv-height) - 24px);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  overflow: hidden;
  background: var(--color-bg);
}

#step-crop[hidden] {
  display: none;
}

#crop-header {
  flex: 0 0 auto;
  padding: 8px 14px 4px;
  padding-top: calc(8px + var(--safe-top));
}

#crop-title {
  margin: 0;
  font-size: 1rem;
  font-weight: bold;
}

#crop-header .hint {
  margin: 2px 0 0;
}

#crop-viewport {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  margin: 4px 12px;
  border-radius: 8px;
  overflow: hidden;
  background: #3a3632;
}

#crop-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#crop-actions {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  padding: 6px 12px;
  padding-bottom: calc(10px + var(--safe-bottom));
}

#crop-actions button {
  margin: 0;
  width: auto;
  flex: 0 1 auto;
}

/* 「この範囲で切り抜く」を右端の主ボタンにし、キャンセルは左に寄せる */
#crop-cancel-btn {
  margin-right: auto !important;
}

#crop-actions button[hidden] {
  display: none;
}

#recrop-btn {
  margin-bottom: 4px;
}

/* 「OCRで読めた文字を確認」の行ごとの判定理由 */
.ocr-raw-reason {
  margin-top: 2px;
  font-size: 0.82rem;
  color: var(--color-text-soft);
}

/* OCRの診断（送った画像・OCRサーバーの数値）。改行をそのまま表示する */
.ocr-diagnostics {
  margin: 4px 0 8px;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--color-surface);
  font-size: 0.8rem;
  line-height: 1.5;
  white-space: pre-line;
  color: var(--color-text-soft);
}

/* ============================================================
   候補の確認画面（全画面）。紙面の該当箇所を大きく表示し、操作ボタンは紙面の外（下）に置く。
   ============================================================ */
.review-open-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 4px 0 6px;
}

.review-open-row button {
  margin: 0;
}

#review-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  height: var(--vv-height, 100vh);
  background: #24211e;
  color: #f4efe6;
  padding-top: var(--safe-top);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

#review-screen[hidden] {
  display: none;
}

#review-top {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
}

#review-title {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  text-align: center;
  font-size: 1rem;
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.review-top-btn {
  flex: 0 0 auto;
  margin: 0;
  min-height: 44px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 0.9rem;
}

.review-top-btn[aria-pressed="true"] {
  background: var(--color-blue);
}

/* 紙面の表示領域：画面の残りすべてを使う（ボタン・説明はこの外） */
#review-view {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background: #3a3632;
}

#review-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* 紙面全体での位置（右上の小さな縮図）。タップでその位置へ移動 */
#review-minimap {
  position: absolute;
  top: 8px;
  right: 8px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  touch-action: none;
}

/* タップした位置のOCRの結果（紙面の上に大きく。タップした位置と反対側の端に置く） */
#review-probe {
  position: absolute;
  left: 8px;
  right: 8px;
  z-index: 2;
  padding: 10px 12px;
  border-radius: 12px;
  border: 3px solid #888;
  background: rgba(20, 18, 16, 0.92);
  color: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

#review-probe[hidden] {
  display: none;
}

#review-probe.at-top {
  top: 8px;
}

#review-probe.at-bottom {
  bottom: 8px;
}

#review-probe.none {
  border-color: #ff5a5a;
}

#review-probe.candidate {
  border-color: #4cc46a;
}

#review-probe.excluded {
  border-color: #ffb02e;
}

#review-probe.adopted {
  border-color: #3d8bff;
}

#review-probe-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: bold;
  line-height: 1.35;
}

#review-probe-detail {
  margin: 4px 0 0;
  font-size: 1rem;
  line-height: 1.4;
  color: #eee6d8;
  max-height: 6.5em;
  overflow-y: auto;
}

.review-probe-btns {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.review-probe-btns button {
  flex: 1 1 0;
  margin: 0;
  min-height: 48px;
  font-size: 1rem;
  font-weight: bold;
  border-radius: 10px;
}

#review-probe-adopt {
  background: var(--color-accent);
  color: var(--color-accent-contrast);
}

#review-probe-adopt[hidden] {
  display: none;
}

#review-probe-close {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

#review-info {
  flex: 0 0 auto;
  padding: 6px 12px 0;
  min-height: 3.2em;
}

#review-text {
  margin: 0;
  font-size: 1rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

#review-reason {
  margin: 2px 0 0;
  font-size: 0.85rem;
  color: #cfc5b6;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

#review-actions {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr 1.3fr 1fr;
  gap: 6px;
  padding: 8px 8px;
}

#review-actions button {
  margin: 0;
  min-height: 52px;
  padding: 6px 4px;
  font-size: 1rem;
  font-weight: bold;
  border-radius: 10px;
}

#review-actions button:disabled {
  opacity: 0.35;
}

.review-nav-btn {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.review-reject-btn {
  background: #5b5650;
  color: #fff;
}

.review-adopt-btn {
  background: var(--color-accent);
  color: var(--color-accent-contrast);
}

#review-more {
  flex: 0 0 auto;
  padding: 0 10px calc(6px + var(--safe-bottom));
  max-height: 45vh;
  overflow-y: auto;
  color: var(--color-text);
}

#review-more > details {
  margin: 0;
  background: var(--color-surface);
  border-radius: 8px;
  padding: 2px 8px;
}

#review-more > details > summary {
  color: var(--color-text-soft);
}

/* iPhoneなど幅の狭い画面：上の帯に「仕上がり」「画像を動かす」「全体表示」が1行に収まるよう、
   表示の－・％・＋は隠す（2本指のピンチで拡大縮小でき、「全体表示」で戻せる） */
@media (max-width: 430px) {
  #zoom-out-btn,
  #zoom-in-btn,
  #zoom-reset-btn {
    display: none;
  }
  #finished-view-toggle,
  #image-move-toggle {
    padding: 6px 10px 6px 8px;
    font-size: 0.8rem;
  }
}

/* よく使う出典の一覧 */
.source-preset-list {
  list-style: none;
  margin: 6px 0;
  padding: 0;
}

.source-preset-list li {
  padding: 6px 0;
  border-bottom: 1px solid var(--color-border);
}

.source-preset-label {
  display: block;
  font-weight: bold;
  margin-bottom: 4px;
}

.source-preset-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.source-preset-btns .stepper-btn {
  min-height: 40px;
}

/* 文字の読み取り（OCR）の状態表示：上の帯のすぐ下、中央 */
#ocr-progress {
  position: absolute;
  top: 54px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  margin: 0;
  padding: 6px 14px 6px 32px;
  border-radius: 999px;
  background: rgba(26, 95, 180, 0.92);
  color: #fff;
  font-size: 0.85rem;
  font-weight: bold;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

#ocr-progress[hidden] {
  display: none;
}

#ocr-progress::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  animation: ocr-spin 0.9s linear infinite;
}

#ocr-progress[data-state="done"] {
  background: rgba(46, 125, 50, 0.92);
}

#ocr-progress[data-state="error"] {
  background: rgba(176, 42, 30, 0.94);
}

#ocr-progress[data-state="done"]::before,
#ocr-progress[data-state="error"]::before {
  animation: none;
  border: none;
  content: "✓";
  width: auto;
  height: auto;
  margin-top: -0.6em;
  line-height: 1.2;
}

#ocr-progress[data-state="error"]::before {
  content: "!";
}

@keyframes ocr-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  #ocr-progress::before {
    animation: none;
  }
}

/* 角度の操作を開くボタン：開いている間は色を変える */
#angle-toggle-btn.active {
  background: #1a5fb4;
}

/* 上のヘッダー：「画像をOCRへ送信」は折り返さず1行（入りきらなければ省略記号）。狭い画面では
   元に戻す・やり直すを記号だけにして（読み上げ用の名前は残す）、縦に崩れないようにする */
#editor-header-text > summary {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.editor-header-btn {
  white-space: nowrap;
}

@media (max-width: 460px) {
  #editor-header {
    gap: 6px;
    padding-left: 8px;
    padding-right: 8px;
  }
  #undo-btn,
  #redo-btn {
    min-width: 44px;
    padding-left: 8px;
    padding-right: 8px;
    font-size: 1.1rem;
  }
  #undo-btn .header-btn-label,
  #redo-btn .header-btn-label {
    display: none;
  }
}

/* ============================================================
   写真の補正画面（#step-correct）：切り抜き画面と同じく画面いっぱいを使う。
   四隅の丸は指で押しやすい大きさにし、動かす間は拡大鏡を上の隅に出す。
   ============================================================ */
main:has(> #step-correct:not([hidden])) {
  max-width: 640px;
  padding: 0;
}

#step-correct {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: calc(var(--vv-height) - 24px);
  max-height: calc(var(--vv-height) - 24px);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  overflow: hidden;
  background: var(--color-bg);
}

#step-correct[hidden] {
  display: none;
}

#correct-header {
  flex: 0 0 auto;
  padding: 8px 14px 2px;
  padding-top: calc(8px + var(--safe-top));
}

#correct-title {
  margin: 0;
  font-size: 1rem;
  font-weight: bold;
}

#correct-header .hint {
  margin: 2px 0 0;
}

#correct-viewport {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  margin: 4px 12px;
  border-radius: 8px;
  overflow: hidden;
  background: #3a3632;
}

#correct-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#correct-loupe {
  position: absolute;
  top: 8px;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  background: #3a3632;
}

#correct-loupe[hidden],
#correct-busy[hidden] {
  display: none;
}

#correct-busy {
  position: absolute;
  inset: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-weight: bold;
}

#correct-tools {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 12px 0;
}

.correct-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.correct-btn {
  flex: 0 0 auto;
  min-height: 44px;
  min-width: 44px;
  margin: 0;
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.95rem;
  font-weight: bold;
  white-space: nowrap;
}

.correct-btn.correct-small {
  padding: 6px 4px;
}

.correct-btn.correct-wide {
  flex: 1 1 auto;
}

.correct-btn[aria-pressed="true"] {
  background: #1a5fb4;
  color: #fff;
}

.correct-btn:disabled {
  opacity: 0.4;
}

#correct-fine-slider {
  flex: 1 1 auto;
  min-width: 60px;
  min-height: 36px;
  margin: 0;
}

#correct-fine-value {
  flex: 0 0 3.6em;
  text-align: right;
  font-weight: bold;
  font-variant-numeric: tabular-nums;
}

#correct-actions {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 12px;
  padding-bottom: calc(10px + var(--safe-bottom));
}

#correct-actions button {
  margin: 0;
  width: auto;
}

.correct-impact-btns {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.correct-impact-btns button {
  margin: 0;
  width: auto;
}

#photo-correct-btn {
  margin-bottom: 4px;
}

/* ---- 補正画面：細かな回転の行はスライダーを幅いっぱいに。＋／−を続けて押してもページが拡大しないよう、
   操作部分だけダブルタップでの拡大を止める（2本指でのページの拡大はそのまま使える） ---- */
#correct-tools,
#crop-actions,
#correct-actions,
#canvas-action-row {
  touch-action: manipulation;
}

.correct-btn.correct-grow {
  flex: 1 1 auto;
}

.correct-fine-row #correct-fine-slider {
  flex: 1 1 auto;
  height: 44px;
  min-height: 44px;
}

/* スライダーのつまみを指で押しやすい大きさに */
#correct-fine-slider {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}

#correct-fine-slider::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 4px;
  background: var(--color-border);
}

#correct-fine-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 30px;
  height: 30px;
  margin-top: -11px;
  border-radius: 50%;
  background: var(--color-accent);
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

#correct-fine-slider::-moz-range-track {
  height: 8px;
  border-radius: 4px;
  background: var(--color-border);
}

#correct-fine-slider::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--color-accent);
  border: 3px solid #fff;
}

/* 進み具合・失敗の表示 */
#correct-busy {
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  text-align: center;
}

#correct-busy p {
  margin: 0;
}

#correct-busy.error {
  background: rgba(60, 10, 6, 0.86);
}

#correct-busy-btns {
  display: flex;
  gap: 8px;
}

#correct-busy-btns[hidden] {
  display: none;
}

#correct-busy-btns button {
  margin: 0;
  width: auto;
}

/* 下の操作の行：戻る（左）・保存・進む（右）を1行に並べ、iPhoneの幅でも折り返さない */
#crop-actions,
#correct-actions {
  flex-wrap: nowrap;
  justify-content: flex-start;
}

#crop-actions button,
#correct-actions button {
  flex: 0 0 auto;
  min-height: 44px;
  padding-left: 12px;
  padding-right: 12px;
  white-space: nowrap;
}

#crop-confirm-btn,
#correct-confirm-btn {
  margin-left: auto !important;
}

#crop-cancel-btn {
  margin-right: 0 !important;
}

/* ---- 保存の窓・続きから再開 ---- */
#save-draft-modal .modal-box button {
  width: 100%;
  margin: 6px 0 0;
}

#save-draft-modal .modal-box button.modal-close {
  width: auto;
  margin: 0;
}

.draft-list-block {
  margin-top: 12px;
}

.draft-list-title {
  margin: 0 0 6px;
  font-size: 1rem;
}

#draft-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.draft-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--color-border);
}

.draft-item img {
  width: 44px;
  height: 56px;
  object-fit: cover;
  border-radius: 4px;
  flex: 0 0 auto;
}

.draft-info {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.9rem;
}

.draft-item button {
  flex: 0 0 auto;
  width: auto;
  margin: 0;
  min-height: 44px;
  padding: 6px 10px;
}

/* 読込み画面：保存したファイルから再開 */
.resume-file-btn {
  display: block;
  margin-top: 10px;
  text-align: center;
}

/* 読み取り方（試験）の切り替えと「詳しく読み直す」 */
.ocr-mode-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}
.ocr-mode-label {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 0.85rem;
  line-height: 1.4;
}
.ocr-mode-label input {
  margin-top: 3px;
  flex: none;
}
/* 共通のボタンの表示指定（.tool-btn の display）より優先して、hidden のときは隠す（速い読み取りが完了したときだけ出す） */
#ocr-full-reread-btn[hidden] {
  display: none;
}

/* ============================================================
   スマホでの押しやすさ・読みやすさ（2026年10月15日）
   iPhoneの画面幅（390px前後）で、よく使う操作を指で押しやすく（44px以上）、
   説明・ラベルを読みやすい大きさにする。キャンバスの広さと拡大位置は変えない。
   ============================================================ */

/* hidden 属性の付いた要素は、ほかの表示指定（display）より優先して隠す
   （「編集へ戻る」「編集をやめる」「詳しく読み直す」などが、隠したつもりで表示されていた） */
[hidden] {
  display: none !important;
}

/* 読込み画面の小さな説明 */
.hero-note,
.local-badge span {
  font-size: 0.875rem;
}

/* 入力欄・スライダー・チェックボックスを指で操作しやすい大きさに */
input[type="text"],
input[type="date"],
input[type="number"],
select {
  min-height: 44px;
}

input[type="range"] {
  min-height: 44px;
}

.checkbox-row input[type="checkbox"],
.ocr-mode-label input[type="checkbox"] {
  width: 24px;
  height: 24px;
  flex: none;
}

.ocr-mode-label {
  align-items: center;
  min-height: 44px;
  font-size: 0.9rem;
  font-weight: normal;
  margin-top: 0;
}

/* 小さなボタン（±・調整・登録の編集など）も44px以上に */
.stepper-btn,
.fine-adjust .stepper-btn,
.source-preset-btns .stepper-btn {
  min-height: 44px;
}

/* 「詳しく」などの開閉：文字の周りまで押せるように */
.sheet-panel .more-info > summary,
.fine-adjust summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0;
  font-size: 0.9rem;
}

/* --- 編集画面のヘッダー：記号だけにせず「戻す」「やり直す」の文字も出す --- */
#editor-header-text > summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  font-size: 0.85rem;
}

.editor-header-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 0.85rem;
}

.header-btn-icon {
  font-size: 1.05rem;
  line-height: 1;
}

@media (max-width: 460px) {
  #undo-btn,
  #redo-btn {
    font-size: 0.85rem;
    padding-left: 7px;
    padding-right: 8px;
  }
  #undo-btn .header-btn-label,
  #redo-btn .header-btn-label {
    display: inline;
  }
}

/* 初回の案内は短く1〜2行に */
#first-run-hint p {
  font-size: 0.9rem;
}

/* --- キャンバス上部の「仕上がり」「画像を動かす」「全体表示」：高さ44px --- */
#finished-view-toggle,
#image-move-toggle {
  min-height: 44px;
}

#finished-view-toggle svg,
#image-move-toggle svg {
  width: 18px;
  height: 18px;
}

.zoom-hud-btn {
  min-width: 44px;
  min-height: 40px;
}

@media (max-width: 430px) {
  #finished-view-toggle,
  #image-move-toggle {
    font-size: 0.85rem;
  }
}

/* --- 下のツールバー：アイコンとラベルを大きく、押せる高さを広く --- */
.tool-tab-btn {
  min-height: 60px;
  gap: 4px;
  font-size: 0.8rem;
}

.tool-tab-icon {
  width: 24px;
  height: 24px;
}

/* --- ボトムシートの「小さく」「閉じる」 --- */
#sheet-minimize-btn,
#sheet-close-btn {
  min-height: 44px;
  font-size: 0.9rem;
}

/* --- 切り抜き・補正の画面：説明は短く、下の「戻る／保存／進む」は幅いっぱいに大きく --- */
#crop-header .hint,
#correct-header .hint {
  font-size: 0.9rem;
}

#crop-actions,
#correct-actions {
  gap: 8px;
}

#crop-actions button,
#correct-actions button {
  flex: 1 1 0;
  min-height: 50px;
  padding-left: 8px;
  padding-right: 8px;
  font-size: 1rem;
  font-weight: bold;
}

#crop-actions #crop-save-btn,
#correct-actions #correct-save-btn {
  flex: 0.75 1 0;
}

#crop-actions #crop-confirm-btn,
#correct-actions #correct-confirm-btn {
  flex: 1.9 1 0;
  margin-left: 0 !important;
}

/* 「紙面全体」は3つ目のボタンとして増えた分、文字が切れないよう折り返しを許す（2026-11-15） */
#correct-actions #correct-whole-btn {
  white-space: normal;
  font-size: 0.85rem;
  padding-left: 4px;
  padding-right: 4px;
  line-height: 1.2;
}

.correct-row .correct-btn {
  flex: 1 1 0;
  min-height: 46px;
  font-size: 0.92rem;
  padding-left: 6px;
  padding-right: 6px;
}

.correct-row.correct-fine-row .correct-btn {
  flex: 0 0 auto;
  min-width: 48px;
}

/* --- 候補の確認画面：上の「閉じる」「OCR結果」 --- */
.review-top-btn {
  min-height: 44px;
}

/* 選んだ要素の操作（角度・設定・削除）の行：大きくしたツールバー（高さ60px）と重ならないよう上へ */
#canvas-action-row {
  bottom: calc(80px + var(--safe-bottom));
}

/* 色の丸：指で押しやすい大きさ（42px）と間隔（8px） */
.swatch-list {
  gap: 8px;
}

.swatch-btn,
.custom-color-swatch-label input[type="color"] {
  width: 42px;
  height: 42px;
  min-width: 42px;
  min-height: 42px;
}

/* 「全体表示」も高さ44px */
.zoom-hud-fit {
  min-height: 44px;
}

#zoom-hud {
  padding: 0;
}

/* ============================================================
   iPhoneでの操作性（2026年10月17日）：よく使う操作（仕上がり・画像を動かす・全体表示、
   候補の採用、角度、保存）を押しやすく、文字を読みやすくする。キャンバスの大きさは変えない。
   ============================================================ */

/* --- 上の帯：高さ48px、文字14.4px、アイコン付き。帯の高さ（4px＋48px）は、キャンバスの上の
   余白（56px）の内側に収め、紙面に重ねない --- */
#canvas-topbar {
  top: 4px;
  height: 48px;
}

#finished-view-toggle,
#image-move-toggle {
  min-height: 48px;
  gap: 6px;
  padding: 6px 12px 6px 10px;
  font-size: 0.9rem;
}

#finished-view-toggle svg,
#image-move-toggle svg,
.zoom-hud-fit svg {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.zoom-hud-fit {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 48px;
  padding: 0 12px 0 10px;
  font-size: 0.9rem;
  font-weight: bold;
}

@media (max-width: 430px) {
  #finished-view-toggle,
  #image-move-toggle {
    padding: 6px 10px 6px 9px;
    font-size: 0.9rem;
  }
  .zoom-hud-fit {
    border-left: none;
    margin-left: 0;
  }
}

/* 読み取り中の表示は、大きくした帯のすぐ下に */
#ocr-progress {
  top: 58px;
}

/* --- 選んだ要素の操作（採用・却下・角度・設定・削除）：高さ48px。
   「採用」は太字で幅を広く、「削除」は白地に赤の枠にして、隣の「採用」（赤地）と見分けやすく、少し離す --- */
#action-buttons {
  gap: 10px;
}

#action-buttons .tool-btn {
  min-height: 48px;
  padding: 8px 12px;
  font-size: 1rem;
}

#action-buttons #candidate-adopt-quick-btn {
  min-width: 92px;
  font-weight: bold;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

#action-buttons .tool-btn.delete-btn {
  margin-left: 6px;
  background: #fff;
  color: var(--color-required);
  box-shadow: inset 0 0 0 2px var(--color-required);
  font-weight: bold;
}

/* --- 角度：ボタンは高さ48px、スライダーは指で押しやすい高さ・つまみに --- */
.angle-btn {
  min-height: 48px;
  font-size: 0.95rem;
}

#angle-slider {
  min-height: 44px;
  height: 44px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}

#angle-slider::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.35);
}

#angle-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 30px;
  height: 30px;
  margin-top: -11px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid #1a5fb4;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

#angle-slider::-moz-range-track {
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.35);
}

#angle-slider::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid #1a5fb4;
}

/* --- 以前の保存ボタンの指定（ヘッダーの「保存」・仕上げの「端末に保存」は 2026-10-23-10/11 で廃止。指定は害が無いため残す） --- */
#edit-save-btn {
  min-width: 64px;
  font-weight: bold;
}

.header-btn-svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

#save-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  margin: 8px 0 0;
  font-size: 1.05rem;
  font-weight: bold;
}

#save-btn svg {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
}

#download-btn {
  min-height: 48px;
}

/* --- 確認画面の「採用」「却下」：記号付きの文字を読みやすく --- */
#review-actions .review-adopt-btn {
  font-size: 1.05rem;
}

/* ヘッダー：狭い画面ではボタンの間隔を少し詰める */
@media (max-width: 430px) {
  #editor-header {
    gap: 4px;
  }
}

/* 角度の操作：縦長の範囲（縦書きの見出しなど）を選んだとき、横幅いっぱいの角度の操作が範囲の取っ手を
   隠していた。幅を狭くし、範囲と反対側の端へ逃がせるようにする（位置は positionCanvasActionRow） */
#angle-controls {
  width: 252px;
  padding: 6px;
}

#angle-controls .angle-row {
  gap: 4px;
}

#angle-controls .angle-btn {
  min-width: 0;
  padding: 4px 1px;
  font-size: 0.88rem;
}

#angle-controls .angle-value {
  font-size: 0.95rem;
}

/* 角度の操作を開いている間は、その下の「角度・設定・削除」の行を隠し、操作の塊を小さくする
   （角度の操作には「閉じる」があり、閉じれば行は戻る）。縦長の範囲の取っ手の間に収まるようにする */
#canvas-action-row:has(#angle-controls:not([hidden])) #action-buttons {
  display: none;
}

#angle-controls {
  width: 236px;
  padding: 4px;
  gap: 4px;
}

#angle-controls #angle-auto-btn {
  flex: 2.2 1 0;
}

#angle-controls #angle-reset-btn {
  flex: 0.8 1 0;
}

/* 角度の値はスライダーの左に */
.angle-slider-row .angle-value {
  flex: 0 0 auto;
  min-width: 3.4em;
  text-align: left;
  padding-left: 4px;
}

.angle-slider-row #angle-slider {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
}

/* ============================================================
   紙面を主役にしたスマホ画面（2026年10月20日）
   ・幅600px以下：紙面の左右の余白を小さくし、紙面を広く表示する
   ・パネルを開いている間は下のツールバーを隠す（パネルの「閉じる」で戻る）。
     紙面はパネルの実際の高さの分だけ縮める（refreshCanvasWrapReserve / applySheetDock）
   ・「配置」の先頭に、切り抜き直し・補正の大きな入口を置く
   ============================================================ */
@media (max-width: 600px) {
  #canvas-viewport {
    margin: 4px 4px 2px;
  }
  #canvas-wrap {
    padding-left: 6px;
    padding-right: 6px;
  }
  /* パネルを開いている間も道具の帯は隠さない（2026-11-07。パネルは帯の上に置く＝sheetToolbarClearance） */
}

/* --- 「配置」：切り抜き直し・補正の入口（アイコン＋説明つきの大きなボタン） --- */
.place-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.place-action-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: inset 0 0 0 2px var(--color-border);
  text-align: left;
}

#recrop-btn.place-action-btn {
  box-shadow: inset 0 0 0 2px var(--color-accent);
}
.place-action-btn[hidden] {
  display: none;
}

.place-action-btn svg {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  color: var(--color-accent);
}

.place-action-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.place-action-text strong {
  font-size: 1rem;
}

.place-action-text small {
  font-size: 0.85rem;
  color: var(--color-text-soft);
  line-height: 1.35;
}

/* 出力の縦横比：狭い画面で文字が1文字に縮まっていたため、3列の格子にして折り返す */
#canvas-ratio-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

#canvas-ratio-buttons .ratio-mode-btn {
  min-width: 0;
  min-height: 44px;
  padding: 6px 4px;
  white-space: normal;
  line-height: 1.25;
  font-size: 0.9rem;
}

/* --- 切り抜き直しの見通し（確定したら今の編集がどうなるか） --- */
.crop-impact {
  margin: 6px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--color-blue-bg);
  color: var(--color-blue);
  font-size: 0.9rem;
  line-height: 1.45;
}

/* --- 「見せる」：候補の確認を大きな主ボタンに、詳しく読み直すも幅いっぱいに --- */
#review-open-btn,
#ocr-full-reread-btn {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: 8px;
  font-size: 1rem;
  font-weight: bold;
}

.sheet-panel[data-panel="show"] .headline-detect-block {
  margin-top: 8px;
  padding-top: 4px;
}

#review-ocr-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
}

/* --- 「仕上げ」：プレビューと保存を、外側の表示のすぐ下に --- */
.sheet-panel[data-panel="finish"] .preview-btn {
  min-height: 48px;
  font-weight: bold;
}

/* 「仕上げ」：プレビューと保存を横に並べ、パネルを開いてすぐ届く位置に */
.finish-actions {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 8px;
  margin-top: 10px;
}

.finish-actions .preview-btn,
.finish-actions #save-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 52px;
  margin: 0;
  font-size: 1rem;
  font-weight: bold;
}

.finish-actions svg {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.sheet-panel[data-panel="finish"] .mask-param-row input[type="range"] {
  margin-top: 2px;
}

/* 必須の印も読める大きさに */
.required {
  font-size: 0.85rem;
}

/* ---- 切り抜き画面：「次へ」と「枠を解除」、下書きの自動保存の状態（2026年10月） ---- */
#crop-actions #crop-whole-btn {
  flex: 0.9 1 0;
}

.autosave-status {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: var(--color-text-soft);
}

.autosave-status.error {
  padding: 6px 8px;
  border-radius: 6px;
  background: #f6d3d3;
  color: var(--color-required);
  font-weight: bold;
}

/* ============================================================
   連打で画面全体が拡大されないようにする（2026年10月20日）
   iPhoneのSafariは、同じ場所を素早く2回たたくと「ダブルタップで拡大」として扱い、2回目のタップが操作に
   ならないことがある。押す要素と、その入れ物（パネル・確認画面・窓など、中だけスクロールする所を含む）に
   touch-action: manipulation を指定して、ダブルタップ拡大だけを止める。2本指での画面の拡大縮小と
   スクロールはそのまま使える。紙面などのキャンバスは、より具体的な指定（touch-action: none）のまま
   アプリが2本指の操作を受け取る。
   ============================================================ */
html,
body,
button,
a,
input,
select,
textarea,
label,
summary,
[role="button"],
#step-load,
#step-edit,
#bottom-sheet,
#sheet-body,
#review-screen,
#review-more,
#review-info,
#review-actions,
.modal-overlay,
.modal-box,
#draft-list {
  touch-action: manipulation;
}

/* 連打したときに、ボタンの文字が選択（青く反転）されないようにする */
button,
summary,
.tool-tab-btn,
.file-btn {
  -webkit-user-select: none;
  user-select: none;
}

/* 続けて押すボタンは、隣との間を8px以上あけて押し間違えを減らす */
.angle-row,
#angle-controls .angle-row,
.stepper-row,
.font-buttons,
#review-actions {
  gap: 8px;
}

/* ヘッダー：「戻す」と「やり直す」の間を8pxに（狭い画面では左右の余白を少し詰めて幅を保つ） */
#redo-btn {
  margin-left: 4px;
}

@media (max-width: 430px) {
  #editor-header {
    padding-left: 6px;
    padding-right: 6px;
  }
}

/* 角度の「0°」も幅44px以上に */
#angle-controls #angle-reset-btn {
  flex: 0 0 48px;
}

/* --- 自分のライブラリ（この端末）：作品のサムネイル一覧と、作品の窓 --- */
.library-block {
  margin-top: 12px;
}
.library-grid {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 10px;
}
.library-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 6px;
  background: var(--color-bg, #fff);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  text-align: left;
  font-weight: normal;
  touch-action: manipulation;
}
.library-card img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: 4px;
  background: var(--color-surface);
}
.library-card-title {
  font-size: 0.85rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-all;
}
.library-card-meta {
  font-size: 0.75rem;
  color: var(--color-muted, #666);
}
.library-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.library-badge {
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  color: var(--color-muted, #666);
}
.library-badge.share {
  border-color: #c98a00;
  color: #8a5d00;
  background: #fff6db;
}
.library-modal-box {
  text-align: left;
}
.library-modal-box h2 {
  padding-right: 48px;
  word-break: break-all;
}
#library-modal-img {
  display: block;
  max-width: 100%;
  max-height: 46dvh;
  margin: 8px auto;
  border: 1px solid var(--color-border);
}
.library-version-list {
  list-style: none;
  margin: 8px 0;
  padding: 0;
  display: flex;
  gap: 8px;
  overflow-x: auto;
}
.library-version {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 84px;
  min-height: 44px;
  margin: 0;
  padding: 4px;
  background: var(--color-surface);
  color: var(--color-text);
  border: 2px solid transparent;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: normal;
  touch-action: manipulation;
}
.library-version[aria-pressed="true"] {
  border-color: var(--color-accent);
}
.library-version img {
  width: 56px;
  height: 70px;
  object-fit: cover;
  border-radius: 3px;
}
.library-version-date {
  font-size: 0.7rem;
  color: var(--color-muted, #666);
}
#library-resume-btn {
  width: 100%;
  margin-top: 8px;
}
.library-export {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--color-border);
}
.library-export button {
  width: 100%;
  margin-top: 8px;
}
.library-block .more-info {
  margin-top: 12px;
}
/* ライブラリの補助の文字も読める大きさに */
.library-card-meta,
.library-badge,
.library-version-date {
  font-size: 0.82rem;
}
.library-version {
  font-size: 0.88rem;
  width: 96px;
}

/* --- 自動加工：完成プレビュー（画像を大きく見せ、主な操作は大きなボタン2つ） --- */
#step-auto {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: var(--vv-height);
  padding: calc(6px + var(--safe-top)) calc(10px + var(--safe-right)) calc(14px + var(--safe-bottom)) calc(10px + var(--safe-left));
  background: var(--color-bg);
}
#step-auto[hidden] {
  display: none;
}
#auto-header {
  display: flex;
  align-items: center;
  gap: 8px;
}
#auto-header .secondary-btn {
  width: auto;
  flex: 0 0 auto;
  margin: 0;
  padding: 8px 12px;
  font-size: 0.95rem;
  touch-action: manipulation;
}
#auto-title {
  flex: 1 1 auto;
  margin: 0;
  text-align: center;
  font-weight: bold;
  font-size: 1rem;
}
#auto-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 6px;
}
/* 記事と写真を選ぶ画面の見え方の切り替え（拡大・枠／紙面／仕上がり） */
.auto-view-bar {
  display: flex;
  gap: 6px;
  align-self: stretch;
  justify-content: center;
  margin-bottom: 6px;
}
.auto-view-bar[hidden] {
  display: none;
}
.auto-view-seg {
  display: flex;
  border: 2px solid var(--color-border);
  border-radius: 999px;
  overflow: hidden;
}
.auto-view-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin: 0;
  min-height: 40px;
  padding: 0 12px;
  background: var(--color-surface);
  color: var(--color-text);
  border: 0;
  font-size: 0.95rem;
  font-weight: bold;
  touch-action: manipulation;
}
#auto-view-zoom {
  border: 2px solid var(--color-border);
  border-radius: 999px;
  min-width: 64px;
  justify-content: center;
}
.auto-view-seg .auto-view-btn + .auto-view-btn {
  border-left: 1px solid var(--color-border);
}
.auto-view-seg .auto-view-btn[aria-pressed="true"] {
  background: var(--color-text);
  color: var(--color-surface);
}
#auto-viewport {
  max-width: 100%;
}
/* 拡大中：紙面を枠の中でスクロールして見る（枠の操作はそのまま） */
#auto-viewport.zoomed {
  align-self: stretch;
  overflow: auto;
  max-height: calc(var(--vv-height) * 0.62);
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--color-border);
}
/* 選ぶ画面：紙面の上の2本指・ダブルタップはアプリの拡大に使う（ページ全体を拡大しない）。1本指のスクロールはそのまま */
#auto-viewport.choosing,
#auto-viewport.choosing #auto-canvas {
  touch-action: pan-x pan-y;
}
#auto-viewport.zoomed #auto-canvas {
  max-width: none;
  max-height: none;
  border: 0;
  box-shadow: none;
}
#auto-canvas {
  display: block;
  max-width: 100%;
  max-height: calc(var(--vv-height) * 0.62);
  width: auto;
  height: auto;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
  background: #fff;
  touch-action: manipulation;
  cursor: zoom-in;
}
#auto-busy {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: max-content;
  max-width: 86%;
  padding: 12px 16px;
  border-radius: 10px;
  background: rgba(43, 36, 29, 0.82);
  color: #fff;
  text-align: center;
}
#auto-busy[hidden] {
  display: none;
}
#auto-busy p {
  margin: 0;
  font-size: 0.95rem;
}
.auto-summary {
  margin: 8px 2px 0;
  font-size: 0.95rem;
  line-height: 1.5;
}
.auto-summary.error {
  color: var(--color-accent-ink);
  background: var(--color-notice-bg);
  padding: 8px 10px;
  border-radius: 8px;
}
#auto-source-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
#auto-source-row[hidden] {
  display: none;
}
.auto-source-field {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.85rem;
}
.auto-source-field select,
.auto-source-field input {
  width: 100%;
  min-height: var(--touch-min);
  font-size: 16px;
}
#auto-actions {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 10px;
  margin-top: 10px;
}
.auto-big-btn {
  margin: 0;
  width: 100%;
  min-height: 56px;
  font-size: 1.08rem;
  font-weight: bold;
  touch-action: manipulation;
}
#auto-actions .secondary-btn {
  margin: 0;
}
#auto-save-btn[hidden] {
  display: none;
}
#auto-save-btn:disabled {
  opacity: 0.5;
}
.auto-share-extra {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
#auto-actions:has(#auto-save-btn[hidden]) + .auto-share-extra,
#step-auto[hidden] .auto-share-extra {
  display: none;
}
#auto-img-save-btn[hidden] {
  display: none;
}
#auto-save-btn[hidden] + #auto-adjust-btn {
  grid-column: 1 / -1;
}
#auto-reapply-btn {
  touch-action: manipulation;
}
.auto-flow-hint {
  margin-top: 12px;
}
.settings-open-btn {
  touch-action: manipulation;
}

/* 拡大表示 */
.auto-zoom {
  position: fixed;
  inset: 0;
  z-index: 120;
  overflow: auto;
  background: rgba(0, 0, 0, 0.88);
  padding: calc(52px + var(--safe-top)) 8px calc(16px + var(--safe-bottom));
}
.auto-zoom[hidden] {
  display: none;
}
.auto-zoom img {
  display: block;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  cursor: zoom-in;
}
.auto-zoom img.zoomed {
  width: 220%;
  max-width: none;
  cursor: zoom-out;
}
.auto-zoom .modal-close {
  position: fixed;
  top: calc(8px + var(--safe-top));
  right: 8px;
  z-index: 1;
}

/* --- 自動加工の設定 --- */
.settings-overlay {
  align-items: stretch;
  padding: calc(8px + var(--safe-top)) 8px calc(8px + var(--safe-bottom));
}
.settings-box {
  text-align: left;
  max-width: 560px;
  max-height: none;
  height: 100%;
}
.settings-box h2 {
  padding-right: 48px;
}
.settings-section {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--color-border);
}
.settings-section h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}
.settings-fixed {
  margin: 4px 0;
  font-size: 0.92rem;
}
.settings-label {
  margin: 10px 0 2px;
  font-size: 0.92rem;
  font-weight: bold;
}
.settings-box select,
.settings-box input[type="text"] {
  width: 100%;
  min-height: var(--touch-min);
  font-size: 16px;
}
.settings-add-row {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.settings-add-row .secondary-btn {
  width: auto;
  flex: 0 0 auto;
  margin: 0;
}
.settings-slider-row input[type="range"] {
  width: 100%;
}
.settings-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.settings-swatch {
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 2px solid var(--color-border);
  border-radius: 50%;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.8rem;
  touch-action: manipulation;
}
.settings-swatch.active {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-bg);
}
#settings-done-btn {
  width: 100%;
  margin-top: 12px;
}
.settings-box .mode-btn,
.settings-box .checkbox-row,
.settings-box button {
  touch-action: manipulation;
}
.auto-mask-note {
  margin: 8px 2px 0;
  padding: 6px 10px;
  border-left: 4px solid var(--color-accent);
  background: var(--color-surface);
  font-size: 0.88rem;
  line-height: 1.5;
}
.auto-mask-note[hidden] {
  display: none;
}

/* --- 写真の向き（「配置」の先頭）：大きく押しやすい3つのボタン --- */
.orient-block {
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-border);
}
.orient-title {
  margin: 0 0 6px;
  font-weight: bold;
  font-size: 0.95rem;
}
.orient-now {
  font-weight: normal;
  font-size: 0.85rem;
  color: var(--color-text-soft);
}
.orient-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.orient-btn {
  margin: 0;
  width: 100%;
  min-height: 52px;
  font-size: 1.05rem;
  font-weight: bold;
  touch-action: manipulation;
}
#orient-reset-btn {
  grid-column: 1 / -1;
  min-height: 48px;
  font-size: 1rem;
}

/* --- 大きさの縦のつまみ（選んだ文字・スタンプ）：右端に細く置き、紙面と文字を隠さない --- */
#size-rail {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 7;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: min(46%, 300px);
  min-height: 170px;
  pointer-events: none;
}
#size-rail[hidden] {
  display: none;
}
.size-rail-label {
  font-size: 0.8rem;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}
#size-rail-track {
  position: relative;
  flex: 1 1 auto;
  width: 44px;
  border-radius: 22px;
  background: rgba(43, 36, 29, 0.38);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  pointer-events: auto;
  touch-action: none;
  cursor: ns-resize;
}
#size-rail-fill {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 6px;
  transform: translateX(-50%);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.85);
}
#size-rail-thumb {
  position: absolute;
  left: 50%;
  width: 40px;
  height: 40px;
  margin-left: -20px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--color-accent);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

/* --- 文字の見た目：文字だけ／背景あり（目立つ2択） --- */
.text-look-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0;
  margin: 6px 0 10px;
  border: 2px solid var(--color-accent);
  border-radius: 10px;
  overflow: hidden;
}
.text-look-btn {
  margin: 0;
  border-radius: 0;
  min-height: 46px;
  background: var(--color-surface);
  color: var(--color-text);
  font-weight: bold;
  touch-action: manipulation;
}
.text-look-btn.active {
  background: var(--color-accent);
  color: var(--color-accent-contrast);
}

/* --- 簡易編集：編集画面の道具を隠し、下の帯（＋文字・＋スタンプ・削除・完了）だけにする --- */
#step-edit.simple-mode #toolbar,
#step-edit.simple-mode #export-btn,
#step-edit.simple-mode #autosave-chip,
#step-edit.simple-mode #change-image-btn,
#step-edit.simple-mode #editor-header-text,
#step-edit.simple-mode #canvas-topbar {
  display: none !important;
}
#simple-bar {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 8px;
  z-index: 8;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--safe-bottom);
}
#simple-bar[hidden] {
  display: none;
}
.simple-main-row {
  display: grid;
  grid-template-columns: 1fr 1fr 0.8fr 0.9fr;
  gap: 6px;
  padding: 6px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--color-panel-bg) 94%, transparent);
  box-shadow: 0 4px 18px rgba(43, 36, 29, 0.22);
}
.simple-btn {
  margin: 0;
  min-height: 48px;
  padding: 6px 4px;
  font-size: 0.98rem;
  font-weight: bold;
  touch-action: manipulation;
}
.simple-btn.secondary-btn {
  width: auto;
}
.simple-done {
  background: var(--color-blue);
}
#simple-text-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--color-panel-bg) 94%, transparent);
  box-shadow: 0 4px 14px rgba(43, 36, 29, 0.2);
  flex-wrap: wrap;
}
#simple-text-row[hidden] {
  display: none;
}
.simple-look {
  margin: 0;
  flex: 1 1 100%;
}
.simple-colors {
  display: flex;
  gap: 6px;
  flex: 1 1 auto;
}
.simple-color {
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  touch-action: manipulation;
}
.simple-color.active {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-bg);
}
.simple-small-btn {
  margin: 0;
  min-height: 44px;
  padding: 6px 10px;
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  touch-action: manipulation;
}

/* --- 完成プレビューの任意の書き足し（小さく1行） --- */
.auto-extras {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.auto-extras[hidden] {
  display: none;
}
.auto-extra-btn {
  flex: 1 1 0;
  margin: 0;
  min-height: 44px;
  padding: 6px 4px;
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  font-size: 0.95rem;
  touch-action: manipulation;
}
.auto-extra-btn[hidden] {
  display: none;
}

/* --- 完成プレビューの「判定の詳細」 --- */
.auto-detail {
  margin-top: 8px;
  padding: 4px 8px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface);
  font-size: 0.9rem;
}
.auto-detail[hidden] {
  display: none;
}
.auto-detail summary {
  min-height: var(--touch-min);
  display: flex;
  align-items: center;
  font-weight: bold;
  cursor: pointer;
}
.auto-detail-list {
  margin: 4px 0;
  padding-left: 1.6em;
  line-height: 1.5;
}
.auto-detail-list li.ok::marker {
  color: #1b7f3b;
  font-weight: bold;
}
.auto-detail-list li.ng::marker {
  color: #b35a00;
  font-weight: bold;
}
/* --- 完成プレビューの「向きが違うとき」（いまの向きから回した見本3つ。1回のタップで直す） --- */
.auto-orient-row {
  margin-top: 8px;
  padding: 6px 8px 8px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface);
}
.auto-orient-row[hidden] {
  display: none;
}
.auto-orient-row.attention {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px var(--color-accent-bg);
}
.auto-orient-label {
  margin: 0 0 4px;
  font-size: 0.9rem;
  font-weight: bold;
}
.auto-orient-choices {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.auto-orient-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  margin: 0;
  padding: 4px;
  min-height: 72px;
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: bold;
  touch-action: manipulation;
}
.auto-orient-choice canvas {
  max-width: 100%;
  max-height: 64px;
  width: auto;
  height: auto;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
/* 「マーカー・囲み」は2行にする（iPhone幅で8つの道具が重ならないように） */
.tool-tab-label-2 {
  white-space: normal;
  text-align: center;
  line-height: 1.05;
  font-size: 0.68rem;
}
/* 下のツールバー：iPhone幅（600px未満）では、よく使う5つ（見せる・コメント・スタンプ・出典・仕上げ）と
   「その他」の6つだけを並べ、ラベルを小さくしない。配置・マーカー・囲み・個別加工は「その他」のメニューから開く */
#toolbar .tool-tab-label {
  font-size: 0.8rem;
}
.tool-more-btn {
  display: none;
}
@media (max-width: 599px) {
  #toolbar .tool-secondary {
    display: none;
  }
  .tool-more-btn {
    display: flex;
  }
}
#tool-more-menu {
  position: absolute;
  right: 8px;
  bottom: calc(80px + var(--safe-bottom));
  z-index: 9;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: min(300px, calc(100% - 16px));
  padding: 8px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--color-panel-bg) 98%, transparent);
  box-shadow: 0 6px 22px rgba(43, 36, 29, 0.28);
}
#tool-more-menu[hidden] {
  display: none;
}
.tool-more-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  margin: 0;
  min-height: 56px;
  padding: 8px 12px;
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  text-align: left;
  touch-action: manipulation;
}
.tool-more-item strong {
  font-size: 1rem;
}
.tool-more-item small {
  font-size: 0.85rem;
  color: var(--color-text-soft);
}
.tool-more-item.active {
  border-color: var(--accent, #dd654e);
  box-shadow: inset 4px 0 0 var(--accent, #dd654e);
}
/* 選んだものが右寄りのときは、大きさのつまみを左に出す（文字を隠さない） */
#size-rail.rail-left {
  right: auto;
  left: 6px;
}

/* ============================================================
   紙面中心の配置（2026-10-23-9）
   ・パネルは固定（横長＝右、縦長＝下）。ドラッグで動かす「つまみ」は出さない
   ・パネルの地は不透明にし、後ろの紙面の文字が透けて操作の文字が読みにくくならないようにする
   ・パネルを開いても紙面は暗くしない（タップで閉じる働きは残す）
   ・横長の画面：道具の帯を左の縦列、表示の操作を右の縦列にし、紙面を高さいっぱいに使う
   ============================================================ */
#bottom-sheet {
  background: var(--color-panel-bg);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
#bottom-sheet::before {
  display: none;
}
#sheet-scrim {
  background: transparent;
}
/* 紙面の上に重ねる操作の文字：読みやすい背景を付ける */
.size-rail-label {
  min-width: 26px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(43, 36, 29, 0.82);
  text-align: center;
  text-shadow: none;
}
#size-rail-track {
  background: rgba(43, 36, 29, 0.62);
}

#step-edit.layout-side #toolbar {
  left: 6px;
  right: auto;
  top: 6px;
  bottom: 6px;
  width: 84px;
  flex-direction: column;
  margin-bottom: 0;
}
#step-edit.layout-side .tool-tab-btn {
  min-height: 44px;
  padding: 4px 2px;
  border-top: none;
  border-left: 3px solid transparent;
}
#step-edit.layout-side .tool-tab-btn.active {
  border-left-color: var(--color-accent);
}
#step-edit.layout-side #tool-more-menu {
  left: 96px;
  right: auto;
  bottom: 8px;
}
#step-edit.layout-side #canvas-topbar {
  left: auto;
  right: 6px;
  top: 6px;
  width: 72px;
  height: auto;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}
#step-edit.layout-side #finished-view-toggle,
#step-edit.layout-side #image-move-toggle {
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-height: 56px;
  padding: 4px 2px;
  border-radius: 12px;
  font-size: 0.78rem;
  white-space: normal;
  text-align: center;
  line-height: 1.1;
}
#step-edit.layout-side #zoom-hud {
  margin-left: 0;
  flex-direction: column;
  border-radius: 12px;
}
#step-edit.layout-side .zoom-hud-btn {
  width: 100%;
  min-height: 44px;
}
#step-edit.layout-side .zoom-hud-fit {
  flex-direction: column;
  gap: 2px;
  min-height: 56px;
  padding: 4px 2px;
  border-left: none;
  border-top: 1px solid rgba(255, 255, 255, 0.25);
  margin-left: 0;
  font-size: 0.78rem;
  white-space: normal;
  line-height: 1.1;
}
#step-edit.layout-side #simple-bar {
  left: 6px;
  right: auto;
  top: 6px;
  bottom: 6px;
  width: 156px;
  justify-content: flex-end;
  margin-bottom: 0;
}
#step-edit.layout-side .simple-main-row {
  grid-template-columns: 1fr;
}
#step-edit.layout-side #simple-text-row {
  display: flex;
  flex-direction: column;
}
#step-edit.layout-side #simple-text-row[hidden] {
  display: none;
}
/* 横長で高さの低い画面（横向きのiPhone）：道具は、よく使う5つと「その他」に絞る */
@media (max-height: 560px) {
  #step-edit.layout-side #toolbar .tool-secondary {
    display: none;
  }
  #step-edit.layout-side .tool-more-btn {
    display: flex;
  }
  #step-edit.layout-side #editor-header {
    padding-top: calc(2px + var(--safe-top));
    padding-bottom: 2px;
  }
}
#step-edit.layout-side #canvas-action-row {
  bottom: 12px;
}
/* 横長でさらに高さの低い画面（横向きのiPhone）：左の道具は2列、右は「仕上がり・画像を動かす・全体表示」だけ（拡大縮小は2本指で）。
   操作の案内（#edit-status）は、紙面の上部に重ねる細い帯にする（空のときは出さない） */
@media (max-height: 460px) {
  #step-edit.layout-side {
    position: relative;
  }
  #step-edit.layout-side #toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: minmax(52px, auto);
    align-content: center;
    width: 132px;
  }
  #step-edit.layout-side #zoom-out-btn,
  #step-edit.layout-side #zoom-in-btn,
  #step-edit.layout-side #zoom-reset-btn {
    display: none;
  }
  #step-edit.layout-side #edit-status {
    position: absolute;
    z-index: 6;
    left: 50%;
    top: calc(var(--safe-top) + 46px);
    transform: translateX(-50%);
    max-width: 60%;
    height: auto;
    margin: 0;
    padding: 2px 10px;
    border-radius: 999px;
    background: rgba(43, 36, 29, 0.86);
    color: #ffffff;
  }
  #step-edit.layout-side #edit-status:empty {
    display: none;
  }
}

/* 完成プレビュー（2026-10-23-9）：iPad縦では幅の上限を広げ、横長の画面では「左に完成画像・右に操作」の2列にする */
main:has(> #step-auto:not([hidden])) {
  max-width: 760px;
}
@media (min-width: 640px) and (orientation: landscape) {
  main:has(> #step-auto:not([hidden])) {
    max-width: none;
    padding: 0;
  }
  #step-auto {
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(300px, 36vw, 420px);
    grid-auto-rows: min-content;
    column-gap: 14px;
    align-content: start;
    height: var(--vv-height);
    overflow-y: auto;
  }
  #auto-header {
    grid-column: 1 / -1;
  }
  #auto-stage {
    grid-column: 1;
    grid-row: 2 / span 30;
    align-self: start;
    position: sticky;
    top: 0;
  }
  #auto-canvas {
    max-height: calc(var(--vv-height) - 70px - var(--safe-top) - var(--safe-bottom));
  }
  #auto-viewport.zoomed {
    max-height: calc(var(--vv-height) - 120px - var(--safe-top) - var(--safe-bottom));
  }
  #step-auto > :not(#auto-header):not(#auto-stage) {
    grid-column: 2;
  }
}
/* 設定画面：広い画面（iPad横・Mac）では項目を2列に並べ、スクロールを減らす */
@media (min-width: 900px) {
  .settings-box {
    max-width: min(980px, calc(100vw - 32px));
    columns: 2;
    column-gap: 24px;
  }
  .settings-box > h2,
  .settings-box > .modal-close,
  .settings-box > p,
  .settings-box > #settings-done-btn {
    column-span: all;
  }
  .settings-section {
    break-inside: avoid;
  }
}

/* 文字の見た目の「色を反転」：3択の下に横いっぱいで置く */
.text-invert-btn {
  grid-column: 1 / -1;
  margin: 0;
  border-radius: 0;
  min-height: 44px;
  background: var(--color-bg);
  color: var(--color-text);
  border-top: 1px solid var(--color-border);
  font-weight: bold;
  touch-action: manipulation;
}

/* 完成プレビューの「写真：」の1行（状態ごとに左の線の色を変える） */
.auto-photo-status {
  margin: 6px 2px 0;
  padding: 6px 10px;
  border-left: 4px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  font-size: 0.9rem;
  line-height: 1.5;
}
.auto-photo-status[hidden] {
  display: none;
}
.auto-photo-status[data-kind="picked"] {
  border-left-color: #1b7f3b;
}
.auto-photo-status[data-kind="none"],
.auto-photo-status[data-kind="unlinked"] {
  border-left-color: #b35a00;
}

/* 大きさのつまみ：位置と長さはJSが選んだ物と重ならない端の区間に決める（2026-10-24から縦向きのみ） */
#size-rail {
  right: auto;
  transform: none;
  min-height: 0;
}

/* 文字の飾りの切り替え（1つのボタン）：いまの見た目 ▸ 次の見た目の見本 */
.look-cycle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 88px;
  min-height: 44px;
  background: var(--color-surface);
  color: var(--color-text);
  border: 2px solid var(--color-accent);
  touch-action: manipulation;
}
.look-cycle-btn[hidden] {
  display: none;
}
.look-cycle-wide {
  width: 100%;
  margin: 6px 0 10px;
  padding: 6px 10px;
  border-radius: 10px;
  font-weight: bold;
}
.look-cycle-wide .look-label {
  margin-left: 8px;
  font-size: 0.92rem;
}
.look-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  font-weight: 900;
  font-size: 18px;
  line-height: 1;
}
.look-ico.look-next {
  width: 24px;
  height: 24px;
  font-size: 14px;
  opacity: 0.8;
}
.look-arrow {
  font-size: 0.8rem;
  color: var(--color-text-soft);
}
.look-ico.look-box {
  background: #e8e7e2;
  color: #1a1a1a;
  box-shadow: inset 0 0 0 1px #bdb8ad;
}
.look-ico.look-plain {
  background: transparent;
  color: #1a1a1a;
  text-shadow: 0 0 3px #ffffff, 0 0 3px #ffffff;
}
.look-ico.look-outline {
  background: transparent;
  color: #ffffff;
  text-shadow: 1px 0 0 #1a1a1a, -1px 0 0 #1a1a1a, 0 1px 0 #1a1a1a, 0 -1px 0 #1a1a1a, 1px 1px 0 #1a1a1a, -1px -1px 0 #1a1a1a, 1px -1px 0 #1a1a1a, -1px 1px 0 #1a1a1a;
}
.look-ico.look-invert {
  background: #1a1a1a;
  color: #e8e7e2;
}
/* 色の小さな帯 */
#text-color-btn .color-dot {
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 6px;
  border-radius: 50%;
  vertical-align: -3px;
  box-shadow: 0 0 0 2px #ffffff, 0 0 0 3px rgba(0, 0, 0, 0.35);
}
.text-color-pop {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 6px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--color-surface);
  box-shadow: 0 4px 14px rgba(43, 36, 29, 0.28);
}
.text-color-pop[hidden] {
  display: none;
}
.text-color-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: bold;
}
.text-color-row > span {
  min-width: 4.5em;
}
.text-color-swatches {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.pop-swatch {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  margin: 0;
  padding: 0;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.25);
}
.pop-swatch.active {
  box-shadow: 0 0 0 3px var(--color-blue);
}

/* ============================================================
   編集画面の上の帯（2026-10-23-10）：写真選びへ・戻す・やり直す・ⓘ・下書きの状態・書き出す
   ============================================================ */
.header-leave-btn {
  font-weight: bold;
}
#editor-header-text {
  flex: 0 0 auto;
}
#editor-header-text > summary {
  min-width: var(--touch-min);
  min-height: var(--touch-min);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}
.autosave-chip {
  flex: 1 1 auto;
  min-width: 0;
  min-height: var(--touch-min);
  margin: 0;
  padding: 2px 4px;
  background: transparent;
  color: var(--color-text-soft);
  font-size: 0.82rem;
  font-weight: normal;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: none;
  box-shadow: none;
}
.autosave-chip[data-state="error"] {
  color: var(--color-accent-ink);
  font-weight: bold;
  text-decoration: underline;
}
.header-export-btn {
  gap: 4px;
  min-width: 96px;
  background: var(--color-accent);
  color: var(--color-accent-contrast);
  font-weight: bold;
  font-size: 0.95rem;
}
@media (max-width: 460px) {
  #undo-btn .header-btn-label,
  #redo-btn .header-btn-label {
    display: none;
  }
  .header-leave-btn {
    padding-left: 6px;
    padding-right: 6px;
  }
  .header-export-btn {
    min-width: 88px;
  }
}

/* 書き出しの窓 */
.export-box {
  width: min(640px, 100%);
  max-height: calc(var(--vv-height) - 32px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.export-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.export-head h2 {
  margin: 0;
  font-size: 1.1rem;
}
.export-head .secondary-btn {
  width: auto;
  margin: 0;
}
#export-preview {
  display: block;
  max-width: 100%;
  max-height: calc(var(--vv-height) * 0.5);
  margin: 0 auto;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
  background: #ffffff;
  cursor: zoom-in;
}
.export-fix-row {
  display: flex;
  gap: 8px;
}
.export-fix-row[hidden] {
  display: none;
}
.export-fix-row .secondary-btn {
  margin: 0;
}
#export-share-btn:disabled,
#export-save-btn:disabled {
  opacity: 0.5;
}
#export-share-btn[hidden],
.export-share-hint[hidden] {
  display: none;
}
.export-share-hint {
  margin: 0;
}
.export-fallback {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.export-fallback[hidden] {
  display: none;
}
.export-fallback .secondary-btn,
.export-fallback .hint {
  margin: 0;
}

/* 離れるときの窓 */
.leave-box {
  width: min(460px, 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.leave-box h2 {
  margin: 0;
}
.leave-fail-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.leave-fail-actions[hidden] {
  display: none;
}
.leave-discard-btn {
  background: transparent;
  color: var(--color-accent-ink);
  text-decoration: underline;
  box-shadow: none;
  border: none;
}

/* 上の操作帯は「仕上がり」と「全体表示」だけ（拡大縮小は2本指。2026-10-23-10） */
#zoom-out-btn,
#zoom-in-btn,
#zoom-reset-btn {
  display: none;
}
/* 「画像を動かす」は「配置」パネルの中のボタンにした */
.sheet-panel #image-move-toggle {
  width: 100%;
  justify-content: center;
  margin: 8px 0;
  min-height: 48px;
  background: var(--color-surface);
  color: var(--color-text);
  border: 2px solid var(--color-border);
  border-radius: 12px;
}
.sheet-panel #image-move-toggle[aria-pressed="true"] {
  background: #1a5fb4;
  color: #ffffff;
  border-color: #1a5fb4;
}
/* 操作の案内：紙面の上部に重ねる短い通知（数秒で消える。場所を取らない） */
#step-edit {
  position: relative;
}
#edit-status {
  position: absolute;
  z-index: 12;
  left: 50%;
  top: calc(var(--safe-top) + 112px);
  transform: translateX(-50%);
  max-width: min(92%, 560px);
  height: auto;
  margin: 0;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(43, 36, 29, 0.88);
  color: #ffffff;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
#edit-status:empty {
  display: none;
}
#edit-status.error {
  background: #7a2c1c;
  white-space: normal;
}

/* 完成プレビューから開いた設定：下（広い画面では右）に寄せ、完成プレビューを見ながら変えられるようにする */
.settings-overlay.settings-docked {
  align-items: flex-end;
  background: rgba(0, 0, 0, 0.18);
  padding: 0;
}
.settings-overlay.settings-docked .settings-box {
  width: 100%;
  max-width: none;
  max-height: 52vh;
  overflow-y: auto;
  border-radius: 16px 16px 0 0;
  columns: auto;
}
@media (min-width: 640px) and (orientation: landscape) {
  .settings-overlay.settings-docked {
    justify-content: flex-end;
    align-items: stretch;
  }
  .settings-overlay.settings-docked .settings-box {
    width: min(440px, 42vw);
    max-height: none;
    border-radius: 16px 0 0 16px;
  }
}
.settings-live-row {
  margin: 4px 0 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--color-blue-bg);
  font-weight: bold;
}
.settings-live-row[hidden] {
  display: none;
}

#step-edit.layout-side #edit-status {
  top: calc(var(--safe-top) + 56px);
}

.export-source-row {
  display: flex;
  gap: 8px;
}
.export-source-row.needs select,
.export-source-row.needs input {
  outline: 2px solid var(--color-accent);
}
#export-preview {
  max-height: calc(var(--vv-height) * 0.42);
}

/* 選んだ物の操作の行：狭い画面でもはみ出さないよう詰め、入りきらないときは折り返す（2026-10-23-10） */
#action-buttons {
  flex-wrap: wrap;
  justify-content: center;
  max-width: calc(100vw - 16px);
  gap: 6px;
}
#action-buttons .tool-btn {
  min-width: 0;
  min-height: 44px;
  padding: 6px 10px;
}
#action-buttons .look-cycle-btn {
  min-width: 76px;
}
#canvas-action-row {
  width: max-content;
  max-width: calc(100% - 12px);
}

/* ボタンの長い説明は出さず、アイコン・短いラベル・選択状態で伝える（2026-10-23-10） */
.tool-more-item small,
.place-action-text small {
  display: none;
}
.tool-more-item {
  min-height: 48px;
  justify-content: center;
}
@media (max-width: 460px) {
  #editor-header {
    gap: 4px;
  }
  .autosave-chip {
    flex: 0 0 auto;
    padding: 2px 0;
    font-size: 0.8rem;
  }
  #editor-header-text {
    margin-left: auto;
  }
}

/* 「仕上げ」の「書き出す」（上の帯の「書き出す」と同じ窓を開く） */
.finish-export-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  font-weight: bold;
}
.finish-export-btn svg {
  width: 22px;
  height: 22px;
}
.pre-edit-save-btn[hidden] {
  display: none;
}

/* ============================================================
   2026-10-24：完成プレビューの進み具合・記事を選ぶ・ボタンの記号
   ============================================================ */
/* 進み具合の3つの印（向き・文字・記事）。状態は記号（✓ ? ✕ … –）と言葉で示し、色は補助 */
.auto-steps {
  display: flex;
  gap: 6px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  justify-content: center;
  flex-wrap: wrap;
}
.auto-step {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px 3px 4px;
  border-radius: 999px;
  border: 1.5px solid var(--color-border);
  background: var(--color-surface);
  font-size: 0.85rem;
  font-weight: bold;
  line-height: 1.3;
}
.auto-step-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--color-border);
  color: #fff;
  font-size: 0.8rem;
}
.auto-step[data-state="ok"] { border-color: #1b7f3b; }
.auto-step[data-state="ok"] .auto-step-ico { background: #1b7f3b; }
.auto-step[data-state="warn"] { border-color: #b35a00; }
.auto-step[data-state="warn"] .auto-step-ico { background: #b35a00; }
.auto-step[data-state="ng"] { border-color: #b3402a; }
.auto-step[data-state="ng"] .auto-step-ico { background: #b3402a; }
.auto-step[data-state="busy"] .auto-step-ico { background: #6b6358; }
.auto-step[data-state="skip"] { opacity: 0.6; }

/* 記事を選ぶ：番号・色・見出しの見本付きの大きなボタン（色だけで区別しない） */
.auto-choose-row {
  margin-top: 8px;
}
.auto-choose-row[hidden] {
  display: none;
}
.auto-choose-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
@media (min-width: 520px) {
  .auto-choose-list {
    grid-template-columns: 1fr 1fr;
  }
}
.auto-choose-btn {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 10px;
  row-gap: 4px;
  margin: 0;
  padding: 8px 10px;
  min-height: 72px;
  background: var(--color-surface);
  color: var(--color-text);
  border: 3px solid var(--choice-color, var(--color-accent));
  border-radius: 12px;
  text-align: left;
  touch-action: manipulation;
}
.auto-choose-btn .choice-num {
  grid-row: 1 / span 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--choice-color, var(--color-accent));
  color: #fff;
  font-size: 1.4rem;
  font-weight: 900;
  box-shadow: 0 0 0 3px #fff inset;
}
.auto-choose-btn .choice-thumb {
  max-width: 100%;
  max-height: 56px;
  width: auto;
  height: auto;
  justify-self: start;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.auto-choose-btn .choice-cut {
  font-size: 0.85rem;
  font-weight: bold;
  color: #b3402a;
}
/* 近い見出しをまとめた枠：まとめた数（「分ける」で個別に選び直せる） */
.auto-choose-btn .choice-merged {
  justify-self: start;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--choice-color);
  color: #fff;
}
/* 選んでいない候補：細い点線。選んだ候補：太い実線と ✓・色の地（紙面の枠と同じ区別） */
.auto-choose-btn:not(.selected) {
  border-style: dashed;
  border-width: 2px;
}
.auto-choose-btn:not(.selected) .choice-num {
  background: #fff;
  color: var(--choice-color, var(--color-accent));
  box-shadow: 0 0 0 3px var(--choice-color, var(--color-accent)) inset;
}
.auto-choose-btn.selected {
  border-width: 4px;
  background: color-mix(in srgb, var(--choice-color, var(--color-accent)) 12%, var(--color-surface));
}
/* 写真の候補：見出しの丸い番号と違い、四角い📷の印（紙面の枠と同じ区別） */
.auto-choose-btn.photo-choice .choice-num {
  border-radius: 10px;
  font-size: 1.3rem;
}
/* 確定のボタンは、候補が多くて一覧が長くても画面の下に見えたままにする */
.auto-choose-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 0 calc(8px + var(--safe-bottom));
  background: var(--color-bg);
}
.auto-choose-actions .auto-big-btn {
  flex: 1 1 auto;
  width: auto;
}
.auto-choose-actions .secondary-btn {
  flex: 0 0 auto;
  width: auto;
  min-height: 56px;
  margin: 0;
  padding: 0 18px;
}
.auto-choose-actions .secondary-btn[hidden] {
  display: none;
}
.auto-choose-actions .auto-big-btn:disabled {
  opacity: 0.55;
}

/* ボタンの記号（言葉の前に置く。読み上げは aria-label） */
.btn-ico {
  display: inline-block;
  margin-right: 4px;
  font-weight: 900;
}
.btn-svg {
  width: 22px;
  height: 22px;
  margin-right: 6px;
  vertical-align: -5px;
}

/* 文字の飾りのボタン：見本のアイコン＋短い名前（いま）▸ 次の見本 */
.look-cycle-btn .look-label {
  margin: 0 2px;
  font-size: 0.86rem;
  font-weight: bold;
  white-space: nowrap;
}
.look-cycle-wide .look-label {
  margin: 0 4px;
  font-size: 0.95rem;
}

/* 大きさのつまみ（2026-10-24）：常に画面の左右どちらかの端に縦向き。横向き（rail-horizontal）はやめた */
#size-rail.rail-left {
  right: auto;
}

/* 完成プレビューの整理（2026-10-24） */
.auto-step {
  font-size: 0.78rem;
  padding: 2px 8px 2px 3px;
}
.auto-step-ico {
  width: 20px;
  height: 20px;
}
.auto-orient-row {
  padding: 4px 8px;
}
button.auto-orient-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto;
  margin: 0;
  padding: 6px 4px;
  min-height: 40px;
  background: transparent;
  color: var(--color-text);
  border: none;
  font-weight: bold;
  touch-action: manipulation;
}
.auto-orient-row.attention button.auto-orient-label {
  color: var(--color-accent-ink, var(--color-text));
}
.auto-orient-choices[hidden] {
  display: none;
}
#auto-source-row.needs select,
#auto-source-row.needs input[type="date"] {
  border: 2px solid #b3402a;
}
/* 読込み画面の流れ（2026-10-24）：写真 → 記事 → 文字・スタンプ → 書き出す */
.flow-steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin: 14px 0 4px;
  padding: 0;
  list-style: none;
  counter-reset: flow;
}
.flow-steps li {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 2px;
  font-size: 0.8rem;
  font-weight: bold;
  text-align: center;
  line-height: 1.2;
  counter-increment: flow;
}
.flow-steps li::before {
  content: counter(flow);
  position: absolute;
  top: 0;
  left: 6px;
  font-size: 0.7rem;
  color: var(--color-text-soft);
}
.flow-steps li + li::after {
  content: "›";
  position: absolute;
  left: -6px;
  top: 12px;
  font-size: 1.1rem;
  color: var(--color-text-soft);
}
.flow-steps svg {
  width: 28px;
  height: 28px;
  color: var(--color-accent);
}

/* ============================================================
   スタンプ＝第一声（2026-11-05）
   ・見た目（ポップ／シール／吹き出し／明朝）と色を上で選び、下の見本を押すと紙面に置く
   ・見本は紙面に載ったときと同じ描き方（canvas）で、紙面の地の上に描く。感情別の分類・色分けはしない
   ・iPhone幅では3列、広い画面では4〜5列。見本は指で押しやすい高さ（64px以上）にする
   ============================================================ */
.voice-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.voice-look-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  padding: 3px;
  border-radius: 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}
.voice-look-btn {
  min-height: 40px;
  margin: 0;
  padding: 4px 2px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--color-text);
  font-weight: bold;
  font-size: 0.86rem;
  touch-action: manipulation;
}
.voice-look-btn[aria-pressed="true"] {
  background: var(--color-text);
  color: #fff;
}
.voice-color-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.voice-color-btn {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1;
  margin: 0;
  padding: 0;
  border-radius: 50%;
  border: 2px solid rgba(43, 36, 29, 0.25);
  touch-action: manipulation;
}
.voice-color-btn[aria-pressed="true"] {
  box-shadow: 0 0 0 2px var(--color-panel-bg), 0 0 0 4px var(--color-text);
}
.voice-target-note {
  margin: 0;
  font-size: 0.8rem;
  color: var(--color-text-soft);
}
.voice-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
@media (min-width: 600px) {
  .voice-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
#step-edit.layout-side .voice-grid {
  grid-template-columns: repeat(3, 1fr);
}
.voice-tile {
  position: relative;
  height: 66px;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border-radius: var(--radius-tile);
  border: 1px solid var(--color-border);
  background: var(--color-panel-bg);
  touch-action: manipulation;
}
.voice-tile canvas {
  display: block;
  width: 100%;
  height: 100%;
}
/* 固定のスタンプ（画像。白台紙版 2026-11-18-x3）：紙面に置くのと同じ画像を、縦横比のまま見せる。
   黒い線と白い台紙がどちらも見えるよう、地はテーマによらず少し濃い紙の色にする */
.voice-tile.voice-tile-image {
  height: auto;
  aspect-ratio: 6 / 5;
  padding: 6px;
  background: #d9d3c4;
  border-color: rgba(0, 0, 0, 0.12);
}
.voice-tile.voice-tile-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  -webkit-user-drag: none;
}
.voice-tile:active {
  transform: scale(0.96);
}
.voice-tile:focus-visible {
  outline: 3px solid var(--color-blue);
  outline-offset: 1px;
}

/* スタンプの入口（トレイ）：フレーム／スタンプ／絵文字（2026-11-15） */
.stamp-tray-tabs {
  display: flex;
  gap: 4px;
  margin: 0 0 10px;
}
.stamp-tray-tab {
  flex: 1;
  padding: 9px 4px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-btn);
  background: var(--color-panel-bg);
  color: var(--color-text-soft);
  font-size: 0.85rem;
  font-weight: 600;
  touch-action: manipulation;
}
.stamp-tray-tab[aria-selected="true"] {
  background: #ffffff;
  border-color: var(--color-blue);
  color: var(--color-blue);
}

/* フレーム：吹き出し・集中線・コマ枠・網点。紙面に置いたときの形が分かる見本 */
.frame-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.frame-tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 0 0 6px;
  border-radius: var(--radius-tile);
  border: 1px solid var(--color-border);
  background: var(--color-panel-bg);
  overflow: hidden;
  touch-action: manipulation;
}
.frame-tile canvas {
  display: block;
  width: 100%;
  height: 88px;
}
.frame-tile-label {
  font-size: 0.78rem;
  color: var(--color-text-soft);
}
.frame-tile:active {
  transform: scale(0.97);
}

/* 絵文字：コンパクトな一覧。幅360〜390pxを目安に7〜8個並ぶ。指で押す範囲は44pxを確保する */
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 0px;
}
.emoji-tile {
  aspect-ratio: 1;
  min-height: 44px;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-btn);
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  touch-action: manipulation;
}
.emoji-tile:active {
  background: var(--color-panel-bg);
  transform: scale(0.92);
}

/* 置いた後の控えめな入口：コメントは必須ではない */
#action-buttons .voice-comment-btn.just-placed {
  background: #ffffff;
  border-color: var(--color-blue);
  color: var(--color-blue);
}

/* 図形（マーカー・囲みの中）：記号と短い名前 */
#stamp-palette .stamp-btn {
  flex-direction: column;
  gap: 2px;
  font-size: 0.75rem;
}

/* 飾りのボタン：第一声のスタンプを選んでいるときの見た目の見本 */
.look-ico.voice-look-ico {
  color: var(--voice-ink, #1a1a1a);
  background: transparent;
  box-shadow: none;
}
.look-ico.voice-look-pop {
  transform: rotate(-6deg);
  text-shadow: 2px 0 0 #fff, -2px 0 0 #fff, 0 2px 0 #fff, 0 -2px 0 #fff, 2px 2px 0 #fff, -2px -2px 0 #fff, 2px -2px 0 #fff, -2px 2px 0 #fff, 3px 3px 0 rgba(0, 0, 0, 0.3);
}
.look-ico.voice-look-seal {
  background: #fff;
  border: 2px solid var(--voice-ink, #1a1a1a);
  border-radius: 9px;
  transform: rotate(4deg);
  font-family: "Hiragino Maru Gothic ProN", sans-serif;
}
.look-ico.voice-look-bubble {
  background: #fff;
  border: 2px solid #1a1a1a;
  border-radius: 50%;
}
.look-ico.voice-look-brush {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  text-shadow: 0 0 4px #fff, 0 0 4px #fff;
}
/* 2026-11-13：朱色の丸印・角印、漫画風（太い縁取り） */
.look-ico.voice-look-hanko,
.look-ico.voice-look-kakuin {
  background: rgba(255, 255, 255, 0.9);
  border: 3px solid var(--voice-ink, #c8321f);
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
}
.look-ico.voice-look-hanko {
  border-radius: 50%;
  transform: rotate(-8deg);
}
.look-ico.voice-look-kakuin {
  border-radius: 4px;
  transform: rotate(4deg);
}
.look-ico.voice-look-manga {
  font-weight: 900;
  transform: rotate(-6deg);
  text-shadow: 2px 0 0 #1a1a1a, -2px 0 0 #1a1a1a, 0 2px 0 #1a1a1a, 0 -2px 0 #1a1a1a, 2px 2px 0 #1a1a1a, -2px -2px 0 #1a1a1a, 2px -2px 0 #1a1a1a, -2px 2px 0 #1a1a1a, 4px 0 0 #fff, -4px 0 0 #fff, 0 4px 0 #fff, 0 -4px 0 #fff;
}
/* スタンプの分類の見出しと、沖縄のことばの使いどころ */
.voice-group-label {
  grid-column: 1 / -1;
  margin: 6px 0 0;
  font-size: 0.8rem;
  font-weight: bold;
  color: var(--color-text-soft);
}
.voice-tile.has-note {
  height: 84px;
  display: flex;
  flex-direction: column;
}
.voice-tile.has-note canvas {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
}
.voice-note {
  display: block;
  padding: 0 4px 4px;
  font-size: 0.62rem;
  line-height: 1.25;
  color: var(--color-text);
  background: rgba(236, 232, 222, 0.92);
}

/* ============================================================
   大きさのつまみを細く（2026-11-05）：「大」「小」の文字はやめ、上ほど太く下ほど細い縦長の逆三角形の目盛りで大小を伝える。
   触れられる幅（透明）は34px（SIZE_RAIL_W）にとどめ、紙面のタップを必要以上に奪わない。つまみの丸は小さく白く
   ============================================================ */
#size-rail {
  gap: 0;
}
#size-rail-track,
#step-edit #size-rail-track {
  width: 34px;
  isolation: isolate;
  border-radius: 0;
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
#size-rail-track::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 4px;
  bottom: 4px;
  width: 14px;
  transform: translateX(-50%);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  background: rgba(255, 255, 255, 0.92);
  filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.9));
  pointer-events: none;
}
/* 逆三角形のふち：暗い紙面・明るい紙面のどちらでも見えるよう、一回り大きい暗い三角形を後ろに置く */
#size-rail-track::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 2px;
  bottom: 1px;
  width: 18px;
  transform: translateX(-50%);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  background: rgba(43, 36, 29, 0.55);
  z-index: -1;
  pointer-events: none;
}
#size-rail-fill {
  display: none;
}
#size-rail-thumb {
  width: 26px;
  height: 26px;
  margin-left: -13px;
  border-width: 2px;
  z-index: 1;
}

/* 色と飾りはアイコン1つ（2026-11-05）：飾りはいまの見た目の「あ」1つ、色はいまの文字色の丸（背景色の輪）だけ。
   押せる大きさ（48px角）と、開いている状態（.active）は残す */
.look-cycle-btn,
#action-buttons .look-cycle-btn {
  min-width: 48px;
  width: 48px;
  min-height: 48px;
  padding: 0;
  gap: 0;
}
.look-cycle-wide {
  width: 56px;
  min-width: 56px;
  margin: 6px 0 10px;
}
.look-cycle-btn .look-ico {
  width: 32px;
  height: 32px;
  font-size: 20px;
}
#text-color-btn {
  min-width: 48px;
  width: 48px;
  min-height: 48px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#text-color-btn[hidden] {
  display: none;
}
#text-color-btn .color-dot {
  width: 26px;
  height: 26px;
  margin: 0;
  vertical-align: middle;
  box-shadow: 0 0 0 3px var(--color-dot-ring, #ffffff), 0 0 0 4px rgba(0, 0, 0, 0.4);
}
#text-color-btn.active {
  box-shadow: 0 0 0 3px var(--color-accent) inset;
}
/* スタンプの見た目のボタン：名前の文字ではなく、その見た目で描いた「あ」1つ。選んだものは地の色と太い枠で示す */
.voice-look-btn {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.voice-look-btn[aria-pressed="true"] {
  background: color-mix(in srgb, var(--color-accent) 18%, var(--color-surface));
  color: var(--color-text);
  box-shadow: 0 0 0 3px var(--color-accent) inset;
}
.voice-look-btn .look-ico {
  width: 34px;
  height: 34px;
  font-size: 21px;
}

/* 書き出しの確認（2026-11-05）：完成画像を大きく。出典は入力済みなら1行の要約（押すと入力欄を開く） */
#export-preview {
  max-height: calc(var(--vv-height) * 0.66);
}
.export-source-summary {
  width: 100%;
  margin: 0;
  padding: 8px 12px;
  min-height: 44px;
  text-align: left;
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  font-size: 0.95rem;
}
.export-source-summary::after {
  content: "✎";
  float: right;
  color: var(--color-text-soft);
}
.export-source-summary[hidden],
.export-source-row[hidden],
#export-check[hidden] {
  display: none;
}
.export-source-row .auto-source-field.needs label {
  color: var(--color-accent);
  font-weight: bold;
}
.export-source-row .auto-source-field.needs select,
.export-source-row .auto-source-field.needs input:not([hidden]) {
  outline: 3px solid var(--color-accent);
}
.export-source-row.needs select,
.export-source-row.needs input {
  outline: none;
}

/* 紙面の上の表示の操作（仕上がり・全体表示）は、パネルを開いたときの透明な幕（z-index 7）より上に置く（2026-11-05）。
   以前は幕の下にあり、「仕上がり」を押すと幕が受け取ってパネルを閉じていた */
#canvas-topbar {
  z-index: 8;
}

/* 文章のまとまりで選ぶ（2026-11-06） */
.block-open-btn {
  width: 100%;
  margin: 6px 0;
  font-weight: bold;
}
.block-open-btn[hidden],
.block-overlay[hidden],
.block-zoom-overlay[hidden] {
  display: none;
}
.block-box,
.block-zoom-box {
  width: min(760px, 100%);
  max-height: calc(var(--vv-height) - 16px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
}
.block-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.block-head h2 {
  margin: 0;
  font-size: 1.05rem;
}
.block-head .secondary-btn {
  width: auto;
  margin: 0 0 0 auto;
  min-height: 44px;
}
.block-count {
  font-size: 0.85rem;
  color: var(--color-text-soft);
}
.block-stage {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: #fff;
  border: 1px solid var(--color-border);
}
#block-canvas {
  display: block;
  touch-action: manipulation;
}
.block-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.block-actions .tool-btn {
  margin: 0;
  min-height: 48px;
}
.block-actions .tool-btn:disabled {
  opacity: 0.45;
}
#block-merge-btn.active {
  box-shadow: 0 0 0 3px var(--color-accent) inset;
  background: color-mix(in srgb, var(--color-accent) 15%, var(--color-surface));
}
.block-zoom-overlay {
  z-index: 210;
}
.block-zoom-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}
.block-zoom-img {
  width: 100%;
  height: auto;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.block-zoom-list.split .block-line-img {
  max-width: 100%;
  height: auto;
  align-self: flex-start;
  background: #fff;
}
.block-zoom-list.split.vertical {
  flex-direction: row-reverse;
  flex-wrap: wrap;
  align-items: flex-start;
}
.block-zoom-list.split.vertical .block-line-img {
  max-height: 60vh;
  width: auto;
}
.block-cut-btn {
  margin: 0;
  min-height: 40px;
  min-width: 44px;
  padding: 0 10px;
  border: 1px dashed var(--color-accent);
  background: var(--color-surface);
  color: var(--color-accent);
  font-weight: bold;
}
.block-split-all {
  width: auto;
  margin: 8px 0 0;
}
.block-head h2 {
  white-space: nowrap;
}
.block-count {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.block-head .secondary-btn {
  white-space: nowrap;
  padding: 0 14px;
}
.block-cut-btn {
  min-height: 32px;
}

/* 体験版：画面内の架空紙面 */
.fake-page-row { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 8px; margin: 4px 0 12px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.fake-page-btn { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 4px; width: 84px; padding: 6px; border: 1px solid rgba(43, 36, 29, 0.2); border-radius: 10px; background: #fff; font: inherit; font-size: 12px; color: inherit; scroll-snap-align: start; cursor: pointer; }
.fake-page-btn img { width: 70px; height: 90px; object-fit: cover; border-radius: 4px; background: #eee; }

/* 体験版：狭い画面の短い「仕上げ」（隠し方とぼかしの強さのつまみだけ。紙面を大きく出す） */
.finish-compact-note { display: none; }
#bottom-sheet.finish-compact [data-panel="finish"] > .hint,
#bottom-sheet.finish-compact [data-panel="finish"] > .finish-actions,
#bottom-sheet.finish-compact [data-panel="finish"] > .status,
#bottom-sheet.finish-compact [data-panel="finish"] > .legal-hint,
#bottom-sheet.finish-compact [data-panel="finish"] > .fine-adjust { display: none; }
#bottom-sheet.finish-compact .finish-compact-note { display: block; margin: 4px 0 0; font-size: 11px; line-height: 1.4; color: #6b6158; }
#bottom-sheet.finish-compact [data-panel="finish"] .mode-buttons { margin: 0; }
#bottom-sheet.finish-compact [data-panel="finish"] .mode-btn { min-height: 36px; padding-top: 4px; padding-bottom: 4px; }
#bottom-sheet.finish-compact [data-panel="finish"] .mask-param-row { margin-top: 6px; }
#bottom-sheet.finish-compact [data-panel="finish"] .mask-param-row label { font-size: 13px; }
#canvas-viewport.finish-compact #canvas-topbar { display: none; }
#bottom-sheet.finish-compact [data-panel="finish"] .mask-param-row { display: flex; align-items: center; gap: 8px; }
#bottom-sheet.finish-compact [data-panel="finish"] .mask-param-row[hidden] { display: none; }
#bottom-sheet.finish-compact [data-panel="finish"] .mask-param-row label { flex: none; white-space: nowrap; }
#bottom-sheet.finish-compact [data-panel="finish"] .mask-param-row input[type="range"] { flex: 1; min-width: 0; margin: 0; }
/* 体験版：幅390px未満では上の帯が画面からはみ出し「書き出す」が欠けたため、説明の ⓘ を省く（同じ説明は最初の画面にある） */
@media (max-width: 389px) {
  #editor-header-text { display: none; }
}

/* 2026-11-13：トリミングの下の操作。狭い画面では「← 戻る」「紙面全体で進む」を上の行、「次へ →」を下の行いっぱいに */
@media (max-width: 480px) {
  #crop-actions {
    flex-wrap: wrap;
  }
  #crop-cancel-btn,
  #crop-whole-btn {
    flex: 1 1 0 !important;
  }
  #crop-confirm-btn {
    order: 3;
    flex: 1 0 100% !important;
    margin-left: 0 !important;
  }
}

/* 詳細編集 → 簡易編集へ戻るボタン（2026-11-16-6）。幅の狭い画面でも上の帯に収める */
.to-simple-btn {
  flex: 0 1 auto;
  min-width: 0;
  padding-left: 6px;
  padding-right: 6px;
  font-size: 0.82rem;
  white-space: nowrap;
}
#step-edit.simple-mode #to-simple-btn {
  display: none !important;
}
@media (max-width: 460px) {
  #editor-header .autosave-chip {
    flex-basis: 0;
    min-width: 44px; /* 「保存済み」などの状態は省略しても見える幅を残す */
  }
  #editor-header .header-export-btn .header-btn-svg {
    display: none;
  }
  #editor-header .header-export-btn {
    min-width: 0;
    padding-left: 8px;
    padding-right: 8px;
  }
}

/* 出典の欄のそばの短い注意（書き出し・保存を押したときだけ。2026-11-16-6） */
.field-error {
  margin: 4px 0 0;
  color: #c0392b;
  font-size: 0.85rem;
  font-weight: bold;
  line-height: 1.4;
}

/* 数値の調整：長いスライダー＋数値の欄（2026-11-16-6） */
.num-control {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 8px 0;
}
.num-control.disabled {
  opacity: 0.45;
}
.num-control-label {
  font-size: 0.9rem;
}
.num-control-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
}
.num-control-inputs input[type="range"] {
  flex: 1 1 auto;
  min-width: 0;
  min-height: var(--touch-min, 44px);
}
.num-control-value {
  flex: 0 0 auto;
  width: 5em;
  min-height: 40px;
  font-size: 1rem;
  text-align: right;
}
.num-control-unit {
  flex: 0 0 auto;
  min-width: 1.4em;
  font-size: 0.85rem;
}
.page-angle-block {
  margin-top: 8px;
}

/* 「追加」の6つの入口：狭い画面では1行のまま横にすべらせる（2026-11-16-6） */
.add-tray-tabs {
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.add-tray-tabs::-webkit-scrollbar {
  display: none;
}
.add-tray-tabs .stamp-tray-tab {
  flex: 0 0 auto;
  min-width: 4.4em;
  padding: 9px 8px;
  white-space: nowrap;
  min-height: 40px;
}

/* このアプリについて（2026-11-16-6） */
.about-box {
  width: min(560px, 100%);
  text-align: left;
  color: #2b241d;
  max-height: calc(var(--vv-height, 100vh) - 32px);
  overflow-y: auto;
}
.about-section {
  border-top: 1px solid #d9d2c7;
  padding: 8px 0;
}
.about-section > summary {
  min-height: var(--touch-min, 44px);
  display: flex;
  align-items: center;
  font-weight: bold;
  cursor: pointer;
}
.about-section p,
.about-section li {
  line-height: 1.6;
  color: #2b241d;
}
.about-section a {
  color: #1a5fb4;
}
.about-box h2 {
  color: #2b241d;
}
.about-steps,
.about-section ul {
  padding-left: 1.3em;
  margin: 4px 0;
}

/* 選ぶ画面の短い補足（2026-11-17）：数秒で消える。消えても高さを保ち、ボタンの位置を動かさない */
.auto-choose-note {
  min-height: 1.5em;
  margin: 4px 0;
  font-size: 0.85rem;
}

/* 数値の欄を付けたスライダーのラベル（2026-11-17）：上の行に置き、スライダーと欄を横いっぱいに並べる */
.num-control-label-block {
  display: block;
  width: 100%;
  margin: 8px 0 2px;
}
.num-control-inputs {
  width: 100%;
}
.num-control-inputs .num-control-value {
  width: 4.2em;
  padding-left: 4px;
  padding-right: 4px;
}
.num-control-host {
  flex-wrap: wrap;
}
.num-control-host > .num-control-label-block,
.num-control-host > .num-control-inputs {
  flex: 1 1 100%;
}

/* 完成プレビューの説明の行（2026-11-17-4）：空のときは場所を取らない（候補画面の誤りなど、文があるときだけ出す） */
.auto-summary:empty {
  display: none;
}

/* 大きさのつまみの数値（2026-11-17-4） */
.size-rail-num {
  pointer-events: auto;
  flex: 0 0 auto;
  width: 46px;
  min-height: 34px;
  padding: 2px 4px;
  font-size: 0.85rem;
  text-align: center;
  border-radius: 8px;
}

/* 簡易編集では、追加の中の「テキスト」を出さない（文字は帯の「＋文字」から。2026-11-17-4） */
/* 2026-11-18-x1：簡易編集でも「追加」の中に「テキスト」を出す（文字の入口を「追加」にまとめる） */
.about-theme-row {
  white-space: nowrap;
}
.about-theme-row .theme-toggle-btn {
  flex: 0 0 auto;
  width: auto;
  min-width: 7.5em;
  margin: 0;
}

/* 簡易編集の1画面（2026-11-17-5） */
.simple-sel-label {
  margin: 4px 2px 0;
  min-height: 1.2em;
  font-size: 0.8rem;
  font-weight: bold;
  color: var(--color-text-soft);
}
.simple-sel-label[data-kind="frame"] {
  color: #1a5fb4;
}
/* 件数の印（文字◯行・選べる記事◯件など）は出さない */
#auto-steps {
  display: none;
}
.save-original-btn {
  margin-top: 8px;
}
.auto-save-original {
  display: block;
  width: 100%;
}
/* 共有に失敗したときだけ出す「元のファイルをダウンロード」（2026-11-18-2） */
.save-original-dl-btn {
  margin-top: 6px;
}
.save-original-dl-btn[hidden] {
  display: none;
}

/* ============================================================
   2026-11-18-x1：共通仕様（design-tokens.css）の紙色・濃いインク・コーラル。ライト／ダークの選択はそのまま
   ============================================================ */
:root[data-theme="light"] {
  --paper: #fbfaf5;
  --surface: #fff;
  --ink: #292c30;
  --muted: #737980;
  --line: #e3e0d8;
  --accent: #dd654e;
  --accent-soft: #f9e3dc;
  --color-bg: var(--paper);
  --color-surface: var(--surface);
  --color-text: var(--ink);
  --color-text-soft: var(--muted);
  --color-accent: var(--accent);
  --color-accent-bg: var(--accent-soft);
  --color-accent-ink: #b0412b;
  --color-accent-contrast: #ffffff;
  --color-border: var(--line);
  --color-panel-bg: #f4f2ec;
  --color-comment-bg: #f6efe6;
}
:root[data-theme="dark"] {
  --paper: #24272b;
  --surface: #303438;
  --ink: #f4f1e9;
  --muted: #b6b9bc;
  --line: #4a4e52;
  --accent: #f18b73;
  --accent-soft: #553c37;
  --color-bg: var(--paper);
  --color-surface: var(--surface);
  --color-text: var(--ink);
  --color-text-soft: var(--muted);
  --color-accent: var(--accent);
  --color-accent-bg: var(--accent-soft);
  --color-accent-ink: #f6b3a3;
  --color-accent-contrast: #24272b;
  --color-border: var(--line);
  --color-panel-bg: #2b2e32;
  --color-comment-bg: #3a3431;
}
:root { --tap: 44px; --motion: 150ms; }

/* アイコン（24px・線1.8px）と、アイコンのボタン（44px以上・押した状態・フォーカス・無効） */
.icon { width: 24px; height: 24px; flex: none; }
.icon-button {
  min-width: var(--tap);
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--color-text);
  background: transparent;
  font: inherit;
  cursor: pointer;
  transition: background-color var(--motion), color var(--motion), border-color var(--motion);
}
.icon-button[aria-pressed="true"],
.icon-button[aria-expanded="true"] {
  background: var(--color-accent-bg);
  color: var(--color-accent-ink);
  border-color: var(--color-accent);
}
.icon-button:focus-visible,
.ratio-card:focus-visible,
.seg-btn:focus-visible,
.layer-pick:focus-visible,
.fav-star:focus-visible,
.inspect-stage:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}
.icon-button:disabled { opacity: 0.4; cursor: default; }
.icon-label-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.primary-btn {
  min-height: 48px;
  border: 0;
  border-radius: 14px;
  background: var(--color-accent);
  color: var(--color-accent-contrast);
  font: inherit;
  font-weight: 700;
  padding: 0 16px;
  cursor: pointer;
}
.primary-btn:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 3px; }
.primary-btn:disabled { opacity: 0.45; }
.btn-svg, .auto-big-btn .icon { width: 22px; height: 22px; }
.auto-big-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* 操作の列（紙面の下・上に浮かぶ小さな列） */
.floatbar { display: flex; justify-content: center; gap: 8px; margin: 10px 0 0; }
.floatbar .icon-button { background: var(--color-surface); border-color: var(--color-border); }
.floatbar .icon-button[aria-pressed="true"],
.floatbar .icon-button[aria-expanded="true"] { background: var(--color-accent-bg); border-color: var(--color-accent); color: var(--color-accent-ink); }
.floatbar[hidden] { display: none; }

/* 下部バー：範囲・追加・重なり・仕上げ（＋その他）。どの幅でも同じ4つ */
#toolbar [hidden] { display: none !important; }
#toolbar .tool-more-btn { display: flex; }
#toolbar .tool-tab-icon { width: 24px; height: 24px; }
.tool-tab-btn:focus-visible { outline: 3px solid var(--color-accent); outline-offset: -3px; }

/* 紙面の上の切替（選んだ枠だけ・位置合わせ・選んだスタンプの星）：右上に縦に並べる */
.edit-float {
  position: absolute;
  right: 6px;
  top: 56px;
  z-index: 6;
  flex-direction: column;
  margin: 0;
  gap: 6px;
}
#step-edit.simple-mode .edit-float { top: 8px; }
.edit-float .icon-button { box-shadow: 0 2px 8px rgba(41, 44, 48, 0.16); padding: 0; }
.fav-selected-btn[aria-pressed="true"] .icon { fill: currentColor; }

/* 共有：主ボタン＋保存のアイコン。説明はⓘの中 */
#auto-actions { align-items: stretch; }
.save-icon-btn { border-color: var(--color-border); background: var(--color-surface); min-width: 52px; }
.share-hint-row { display: flex; align-items: center; gap: 6px; margin: 4px 0; font-size: 0.85rem; color: var(--color-text-soft); }
.share-info-text { flex: 1; }
.export-share-hint.hint { display: none; }

/* 比率の図形カード */
.ratio-cards { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.ratio-cards[hidden] { display: none; }
.ratio-card {
  flex: 1 1 0;
  min-width: 48px;
  min-height: 64px;
  margin: 0;
  padding: 6px 2px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  font-size: 0.72rem;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 6px;
  cursor: pointer;
}
.ratio-card[aria-pressed="true"] { border-color: var(--color-accent); color: var(--color-accent-ink); background: var(--color-accent-bg); font-weight: 700; }
.ratio-shape { display: block; border: 1.8px solid currentColor; border-radius: 2px; }
.ratio-shape-free { border-style: dashed; }
.ratio-free-row { flex-basis: 100%; display: flex; align-items: center; gap: 6px; }
.ratio-free-row[hidden] { display: none; }
.ratio-free-row input { width: 6em; min-height: 44px; }

/* 投稿文メモ */
.memo-panel { margin: 8px 0; text-align: left; }
.memo-panel[hidden] { display: none; }
.memo-head { display: flex; align-items: center; gap: 4px; }
.memo-title { flex: 1; font-weight: 700; font-size: 0.95rem; }
.memo {
  width: 100%;
  min-height: 80px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-bg);
  color: var(--color-text);
  padding: 10px;
  font: inherit;
  font-size: 16px; /* iPhoneで拡大しない */
  margin-top: 6px;
}

/* 追加：すべて／お気に入り／最近使ったもの・お気に入りの星 */
.stamp-filter-row { display: flex; gap: 6px; justify-content: flex-end; margin-bottom: 6px; }
.stamp-pick-panel[hidden], .add-tray-tabs[hidden] { display: none; }
.stamp-pick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.stamp-pick-grid .pick-emoji { font-size: 34px; min-height: 66px; aspect-ratio: auto; width: 100%; }
.stamp-pick-empty { text-align: center; padding: 18px 0; }
.pick-fallback { display: grid; place-items: center; height: 100%; font-weight: 700; color: #292c30; }
.fav-wrap { position: relative; display: grid; }
.fav-wrap > .voice-tile, .fav-wrap > .frame-tile, .fav-wrap > .emoji-tile { width: 100%; }
.fav-star {
  position: absolute;
  top: 0;
  right: 0;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 4px;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  border: 0;
  background: transparent;
  color: #737980;
  cursor: pointer;
}
.fav-star .icon { width: 20px; height: 20px; background: rgba(251, 250, 245, 0.92); border-radius: 50%; padding: 2px; }
.fav-star[aria-pressed="true"] { color: #dd654e; }
.fav-star[aria-pressed="true"] .icon { fill: #dd654e; }

/* 重なり */
.layer-list { list-style: none; margin: 0; padding: 0; }
.layer-row { display: flex; align-items: center; gap: 2px; border-bottom: 1px solid var(--color-border); padding: 4px 0; }
.layer-row.selected { background: var(--color-accent-bg); border-radius: 10px; }
.layer-row.is-hidden .layer-thumb, .layer-row.is-hidden .layer-label { opacity: 0.45; }
.layer-pick {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  margin: 0;
  padding: 2px 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--color-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.layer-pick[aria-pressed="true"] { border-color: var(--color-accent); }
.layer-thumb { width: 40px; height: 40px; border-radius: 8px; border: 1px solid var(--color-border); flex: none; }
.layer-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.85rem; }
.layer-row .icon-button { padding: 0; }
.layer-eye[aria-pressed="false"] { color: var(--color-text-soft); }

/* 下から出るシート（設定・フィードバック） */
.sheet-overlay, .settings-overlay { align-items: flex-end; padding: 0; }
.sheet-overlay .modal-box, .settings-overlay .modal-box {
  max-width: 560px;
  border-radius: 20px 20px 0 0;
  padding: 14px 16px calc(16px + var(--safe-bottom));
  text-align: left;
  background: var(--color-surface);
  color: var(--color-text);
  max-height: 88dvh;
}
.sheet-box-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-box-head h2, #settings-title { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 1.05rem; }
.seg { display: flex; gap: 6px; margin: 10px 0; }
.seg-btn {
  flex: 1;
  min-height: 44px;
  margin: 0;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  cursor: pointer;
}
.seg-btn[aria-checked="true"], .seg-btn[aria-pressed="true"] { border-color: var(--color-accent); background: var(--color-accent-bg); color: var(--color-accent-ink); font-weight: 700; }

/* いつもの設定 */
.usual-summary { list-style: none; margin: 6px 0 10px; padding: 0; display: grid; gap: 4px; }
.usual-summary li { display: flex; gap: 10px; font-size: 0.9rem; }
.usual-k { min-width: 4em; color: var(--color-text-soft); }
.usual-section .primary-btn { width: 100%; }
.usual-section .secondary-btn { width: 100%; margin-top: 8px; }
.usual-reset-confirm { border: 1px solid var(--color-accent); border-radius: 12px; padding: 10px; margin-top: 8px; }
.usual-reset-confirm[hidden] { display: none; }
.usual-reset-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ライブラリ：自分用／共有用 */
.lib-mode-seg .icon-button { flex: 1; border-color: var(--color-border); }
.library-mine[hidden], #library-modal-img[hidden] { display: none; }
.library-mine-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.library-mine-tabs .seg-btn { flex: 0 0 auto; min-width: 44px; padding: 0 10px; }
.library-mine-canvas { display: block; max-width: 100%; max-height: 60dvh; margin: 0 auto; border: 2px dashed var(--color-accent); border-radius: 8px; background: #fff; }
.lib-backup-menu { margin-top: 10px; text-align: left; }
.lib-backup-menu summary { min-height: 44px; cursor: pointer; color: var(--color-text-soft); }

/* 点検 */
.inspect-view { position: fixed; inset: 0; z-index: 120; background: #1d1f22; display: flex; flex-direction: column; }
.inspect-view[hidden] { display: none; }
.inspect-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: calc(6px + var(--safe-top)) calc(8px + var(--safe-right)) 6px calc(8px + var(--safe-left));
  background: #292c30;
}
.inspect-bar .icon-button { color: #f4f1e9; }
.inspect-bar .icon-button[aria-pressed="true"] { color: #f18b73; background: #553c37; border-color: #f18b73; }
#inspect-zoom-out { margin-left: auto; }
.inspect-zoom-val { min-width: 52px; font-variant-numeric: tabular-nums; }
.inspect-stage { flex: 1; position: relative; overflow: hidden; touch-action: none; }
#inspect-canvas { position: absolute; left: 0; top: 0; transform-origin: 0 0; background: #fff; }
.inspect-status { margin: 0; min-height: 0; color: #f4f1e9; text-align: center; font-size: 0.85rem; padding-bottom: var(--safe-bottom); }

/* 簡易編集の下の帯：範囲・追加・重なり・仕上げ（アイコン＋短いラベル）と、削除・さらに調整 */
.simple-tabs { grid-template-columns: repeat(4, 1fr); }
.simple-tab {
  margin: 0;
  min-height: 52px;
  padding: 4px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--color-text);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  touch-action: manipulation;
}
.simple-tab:focus-visible { outline: 3px solid var(--color-accent); outline-offset: -2px; }
.simple-tab.simple-done { background: var(--color-accent); color: var(--color-accent-contrast); }
.simple-sub-row { display: flex; gap: 6px; justify-content: center; }
.simple-sub-btn { background: color-mix(in srgb, var(--color-panel-bg) 94%, transparent); border-color: var(--color-border); font-size: 0.85rem; box-shadow: 0 2px 8px rgba(41, 44, 48, 0.14); }
#simple-add-text-btn[hidden] { display: none; }
/* 無効のアイコンのボタン：灰色の塗りではなく薄く（共通の button:disabled を打ち消す） */
.icon-button:disabled { background: transparent; color: var(--color-text-soft); border-color: transparent; }
.floatbar .icon-button:disabled { background: var(--color-surface); border-color: var(--color-border); }
/* 簡易編集：選んだ物の操作の列は、以前と同じく出さない（以前は下の帯の裏に隠れていた。削除は下の帯から） */
#step-edit.simple-mode #canvas-action-row { display: none; }
/* 紙面の上の切替は、上の中央に横に並べる（右・左に出る大きさのつまみと重ねない）。詳細編集では上の帯の下 */
.edit-float {
  left: 50%;
  right: auto;
  top: 54px;
  transform: translateX(-50%);
  flex-direction: row;
}
#step-edit.simple-mode .edit-float { top: 6px; }
#step-edit.simple-mode #edit-status { top: calc(var(--safe-top) + 60px); }
#step-edit:not(.simple-mode):not(.layout-side) #edit-status { top: calc(var(--safe-top) + 166px); }
/* 比率のカードは、360px幅でも1段（6つ）に並べる */
.ratio-cards { display: grid; grid-template-columns: repeat(6, minmax(44px, 1fr)); gap: 6px; }
.ratio-card { min-width: 0; padding: 6px 0; }
.ratio-free-row { grid-column: 1 / -1; }
/* 横長の画面：紙面の上の切替は、右の縦列の下に置く（紙面に重ねない） */
#step-edit.layout-side .edit-float,
#step-edit.layout-side.simple-mode .edit-float { left: auto; right: calc(8px + var(--safe-right)); top: auto; bottom: 10px; transform: none; flex-direction: column; }
/* 横長の画面の簡易編集：4つを2×2、削除・さらに調整・ⓘはアイコンだけの1行 */
#step-edit.layout-side .simple-tabs { grid-template-columns: 1fr 1fr; }
#step-edit.layout-side .simple-sub-row { justify-content: space-between; }
#step-edit.layout-side .simple-sub-btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#step-edit.layout-side .simple-sub-btn { padding: 0; min-width: 44px; }

/* 2026-11-18-x2：いつもの設定の色の見本・フィードバックの「本文だけ共有」 */
.usual-v { display: inline-flex; align-items: center; gap: 4px; }
.usual-swatch { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--color-border); }
.usual-summary li { flex-wrap: wrap; align-items: center; }
#library-save-fallback[hidden] { display: none; }

/* ============================================================
   2026-11-18-x3：起動画面・クレジット
   ============================================================ */
.shoot-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 10px 0 4px;
  font-size: 0.9rem;
  color: var(--color-text-soft);
}
.shoot-guide { width: 34px; height: 24px; flex: none; color: var(--accent, #dd654e); }
.hero-icon-row { display: flex; justify-content: center; gap: 10px; margin: 6px 0 2px; }
.hero-icon-row .icon-button { border: 1px solid var(--color-border); }
#app-credit {
  position: fixed;
  left: 0;
  right: 0;
  bottom: env(safe-area-inset-bottom, 0px);
  z-index: 400;
  height: var(--credit-h);
  margin: 0;
  padding: 0 8px;
  font-size: 10px;
  line-height: var(--credit-h);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--color-text-soft);
  background: var(--color-bg);
  pointer-events: none;
  user-select: none;
}
body.kb-open #app-credit { display: none; }

/* ============================================================
   2026-11-18-x3：簡易編集（上：戻る・取り消し・やり直し・表示／下：＋範囲・＋追加・仕上がり・補助）
   ============================================================ */
.simple-only { display: none !important; }
#step-edit.simple-mode .simple-only { display: inline-flex !important; }
#step-edit.simple-mode .simple-zoom { margin-left: auto; gap: 4px; }
#step-edit.simple-mode .simple-zoom .editor-header-btn { min-width: 40px; padding-left: 6px; padding-right: 6px; font-size: 1.05rem; }
#step-edit.simple-mode #undo-btn .header-btn-label,
#step-edit.simple-mode #redo-btn .header-btn-label { display: none; }
#step-edit.simple-mode #undo-btn,
#step-edit.simple-mode #redo-btn { min-width: 44px; font-size: 1.1rem; }
/* 簡易編集では半透明の幕を出さない（追加パネルを開いたままでも紙面に触れる） */
#step-edit.simple-mode #sheet-scrim { display: none !important; }
/* 選んだ物の小さな列（削除・前へ・後ろへ）は右寄せで、紙面の下の帯の上に */
.simple-sel-row { display: flex; gap: 6px; justify-content: flex-end; }
.simple-sel-row[hidden] { display: none; }
.simple-sel-row .icon-button { min-width: 44px; min-height: 44px; padding: 0; }
.simple-sel-row .icon-button[hidden] { display: none; }
.simple-tabs { grid-template-columns: 1fr 1fr 1fr 52px; }
.simple-tab { font-size: 0.82rem; }
.simple-tab.active { background: color-mix(in srgb, var(--accent, #dd654e) 18%, transparent); border-color: var(--accent, #dd654e); }
.simple-menu-btn { min-width: 0; }
.simple-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 6px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 190px;
  padding: 8px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--color-panel-bg) 98%, transparent);
  box-shadow: 0 6px 22px rgba(43, 36, 29, 0.28);
  z-index: 12;
}
.simple-menu[hidden] { display: none; }
.simple-menu .tool-more-item { min-height: 48px; }
#simple-bar { pointer-events: none; }
#simple-bar > * { pointer-events: auto; }
#simple-bar .simple-sel-row { pointer-events: none; }
#simple-bar .simple-sel-row > * { pointer-events: auto; }
/* 横長の画面：下の帯は左の縦列（2×2）。選んだ物の列もその上 */
#step-edit.layout-side .simple-tabs { grid-template-columns: 1fr 1fr; }
#step-edit.layout-side .simple-sel-row { justify-content: flex-start; }
#step-edit.layout-side .simple-menu { left: 0; right: auto; }
/* 開発モード（?dev=1）だけの欄（2026-11-18-x3） */
html:not(.dev-mode) .dev-only { display: none !important; }
/* 撮影後の元写真の保存（2026-11-18-x3）：撮影した写真のときだけ、補正画面の下の列に目立つ色で */
.correct-save-original { border: 2px solid var(--accent, #dd654e) !important; color: var(--accent, #dd654e); min-width: 48px; min-height: 48px; }
.correct-save-original[hidden] { display: none !important; }
/* 背景色（配置。2026-11-18-x3） */
.canvas-bg-label { margin: 10px 0 4px; }
.canvas-bg-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.canvas-bg-swatch {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px;
  border: 1px solid var(--color-border); border-radius: 10px; background: var(--color-surface); color: var(--color-text);
  font: inherit; font-size: 0.9rem; touch-action: manipulation;
}
.canvas-bg-swatch::before { content: ""; width: 18px; height: 18px; border-radius: 50%; background: var(--swatch, transparent); border: 1px solid rgba(0,0,0,0.25); }
.canvas-bg-custom-wrap::before { display: none; }
.canvas-bg-custom-wrap input { width: 26px; height: 26px; padding: 0; border: none; background: none; }
.canvas-bg-swatch[aria-pressed="true"] { border: 2px solid var(--accent, #dd654e); }
/* 仕上げの送り先（2026-11-18-x3） */
#auto-actions { display: grid; grid-template-columns: 1fr 52px; gap: 8px; }
#auto-actions #auto-adjust-btn { grid-column: 1 / -1; }
#auto-actions .share-icon-btn { min-height: 52px; border: 1px solid var(--color-border); }
#auto-actions .share-icon-btn[hidden] + #auto-adjust-btn { grid-column: 1 / -1; }
.dest-row { display: flex; gap: 6px; margin: 8px 0 0; }
.dest-row[hidden] { display: none; }
.dest-btn { flex: 1; min-height: 40px; padding: 0 8px; border: 1px solid var(--color-border); border-radius: 10px; background: var(--color-surface); color: var(--color-text); font: inherit; font-size: 0.88rem; font-weight: 700; touch-action: manipulation; }
.dest-btn[aria-pressed="true"], .dest-btn[aria-expanded="true"] { border: 2px solid var(--accent, #dd654e); }
.dest-panel { margin-top: 8px; padding: 10px; border: 1px solid var(--color-border); border-radius: 12px; background: var(--color-surface); }
.dest-panel[hidden] { display: none; }
.dest-text { width: 100%; box-sizing: border-box; }
.dest-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 6px; margin-top: 6px; }
.dest-step { min-height: 44px; margin: 0; font-size: 0.88rem; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.dest-num { display: inline-flex; width: 18px; height: 18px; border-radius: 50%; align-items: center; justify-content: center; font-size: 0.72rem; background: rgba(0,0,0,0.12); }
.dest-note { margin: 6px 0 0; font-size: 0.8rem; }
.rights-note { margin: 8px 0 0; font-size: 0.72rem; color: var(--color-text-soft); text-align: center; }
#auto-actions:has(.share-icon-btn[hidden]) #auto-save-btn { grid-column: 1 / -1; }
/* 2026-11-18-x6：編集画面は常に仕上がりと同じ加工で見せるため、「仕上がり」の表示切り替えは出さない */
#finished-view-toggle { display: none !important; }
/* 2026-11-18-x6：仕上げの出口は「共有」＋さらに調整。送り先6つは常に並べる（アイコン＋短い名前） */
#auto-actions { grid-template-columns: 1fr; }
#auto-actions #auto-save-btn { grid-column: 1 / -1; }
.dest-row { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; margin-top: 8px; }
.dest-row[hidden] { display: none; }
/* ロゴの周りに余白（各社のガイドラインの不可侵領域）を取り、名前とはつなげずに間を空ける（2026-11-18-x8） */
.dest-row .dest-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; min-height: 92px; padding: 10px 2px 8px; font-size: 0.72rem; }
.dest-row .dest-btn .icon { width: 34px; height: 34px; margin: 3px 0; }
/* 各社の公式ロゴ（assets/brand/。比率は変えず、色・形も加工しない） */
/* LINE のガイドライン：スマホでの最小の高さ 40px。ほかのロゴも同じ高さにそろえる（縮めるだけで形・色は変えない） */
.dest-logo { width: 40px; height: 40px; object-fit: contain; display: block; }
.dest-logo-dark { display: none; }
:root[data-theme="dark"] .dest-logo-light { display: none; }
:root[data-theme="dark"] .dest-logo-dark { display: block; }
@media (max-width: 420px) { .dest-row { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
#auto-fallback:not([hidden]) { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
/* 2026-11-18-x9：編集画面の上の控えめなⓘ（このアプリについて） */
.editor-about-btn { min-width: 36px; min-height: 36px; padding: 0; border: none; background: transparent; color: var(--color-text-soft); }
.editor-about-btn .icon { width: 20px; height: 20px; }
/* 書き出し付近の注意書きは小さな文字だけ（警告色の枠なし） */
.rights-note { margin: 10px 0 0; font-size: 0.7rem; line-height: 1.5; color: var(--color-text-soft); text-align: left; border: none; background: none; padding: 0; }
/* 試用終了の表示（2026-11-18-x9）：全面に重ね、下の画面は操作できないようにする（データは消さない） */
#trial-ended { position: fixed; inset: 0; z-index: 10000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; padding: 24px; background: var(--color-bg, #fbfaf5); color: var(--color-text, #2b241d); text-align: center; }
#trial-ended p { margin: 0; font-size: 1.05rem; line-height: 1.8; }
#trial-ended small { font-size: 0.75rem; color: var(--color-text-soft, #7a7066); }
/* 2026-11-18-x10：上の帯の「仕上がり」（点検の画面で完成画像を確かめる）。簡易・詳細の両方 */
.finished-check-btn { display: inline-flex; align-items: center; gap: 4px; }
.finished-check-btn .header-btn-svg { width: 18px; height: 18px; }
@media (max-width: 400px) { .finished-check-btn span { font-size: 0.78rem; } }
/* 2026-11-18-x10：上の帯は 戻る／写真へ・取り消し・やり直し・（表示）・仕上がり・ⓘ・（保存の状態・書き出す）の順。
   画像の扱いの説明（常設のⓘ）は出さない（このアプリについてにまとめた）。狭い詳細編集では「仕上がり」は目のアイコンだけ */
#editor-header-text { display: none !important; }
@media (max-width: 460px) {
  #step-edit:not(.simple-mode) .finished-check-btn span { display: none; }
  #step-edit:not(.simple-mode) .finished-check-btn { min-width: 40px; padding-left: 6px; padding-right: 6px; }
}
/* 2026-11-18-x10：狭い画面で上の帯がはみ出さないよう、間と幅を詰める */
@media (max-width: 460px) {
  #editor-header { gap: 4px; padding-left: 6px; padding-right: 6px; }
  #editor-header #undo-btn, #editor-header #redo-btn { min-width: 36px; padding-left: 4px; padding-right: 4px; }
  #editor-header .editor-about-btn { min-width: 30px; }
  #step-edit.simple-mode .simple-zoom { gap: 2px; }
  #step-edit.simple-mode .simple-zoom .editor-header-btn { min-width: 32px; padding-left: 4px; padding-right: 4px; }
  #step-edit.simple-mode .finished-check-btn { padding-left: 6px; padding-right: 6px; }
  #step-edit:not(.simple-mode) #to-simple-btn { flex: 0 0 auto; padding-left: 6px; padding-right: 6px; font-size: 0.78rem; }
  #step-edit:not(.simple-mode) .header-export-btn span { display: none; }
  #step-edit:not(.simple-mode) .header-export-btn { min-width: 40px; padding-left: 6px; padding-right: 6px; }
  #step-edit:not(.simple-mode) #autosave-chip { min-width: 36px; }
}
@media (max-width: 380px) {
  #step-edit.simple-mode .finished-check-btn span { display: none; }
}
@media (max-width: 380px) {
  #step-edit:not(.simple-mode) #change-image-btn,
  #step-edit:not(.simple-mode) #to-simple-btn { padding-left: 4px; padding-right: 4px; font-size: 0.74rem; }
  #step-edit:not(.simple-mode) #undo-btn, #step-edit:not(.simple-mode) #redo-btn { min-width: 32px; }
  #step-edit:not(.simple-mode) .editor-about-btn { min-width: 28px; }
}

/* 画像と感想を送る（イベント体験版 2026-11-25） */
.feedback-open-btn { width: 100%; margin-top: 8px; }
.feedback-box { text-align: left; }
.feedback-box h2 { min-height: 40px; padding-right: 52px; display: flex; align-items: center; }
.feedback-box .hint { margin: 0 0 12px; }
.feedback-field { margin: 0 0 14px; }
.feedback-label { display: block; margin: 0 0 6px; font-size: 0.85rem; font-weight: 700; }
#feedback-preview {
  display: block;
  width: 100%;
  max-height: 36dvh;
  object-fit: contain;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-panel-bg);
  margin: 0 0 8px;
}
.feedback-image-off {
  margin: 0 0 8px;
  padding: 14px;
  border: 1px dashed var(--color-border);
  border-radius: 6px;
  text-align: center;
  font-size: 0.85rem;
}
#feedback-comment, #feedback-stamp { width: 100%; box-sizing: border-box; font-size: 16px; }
#feedback-send-btn { width: 100%; }

/* 2026-11-24：紙面の上の「元の紙面／加工後」の切り替え（簡易・詳細の両方）。上の「仕上がり」は出さない */
#finished-check-btn { display: none !important; }
.paper-view-switch {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 7;
  display: flex;
  padding: 3px;
  gap: 2px;
  border-radius: 999px;
  background: var(--color-surface, #ffffff);
  border: 1px solid var(--color-border);
  box-shadow: 0 2px 8px rgba(41, 44, 48, 0.16);
}
.paper-view-switch[hidden] { display: none; }
.paper-view-switch button {
  min-height: 34px;
  margin: 0;
  padding: 0 14px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--color-text);
  font-size: 0.88rem;
  font-weight: bold;
  white-space: nowrap;
}
.paper-view-switch button[aria-pressed="true"] {
  background: var(--color-text);
  color: var(--color-bg);
}
/* 詳細編集の右上「書き出す」：狭い画面でも文字を出す（以前は朱色の無地のボタンになっていた） */
@media (max-width: 460px) {
  #step-edit:not(.simple-mode) .header-export-btn span { display: inline; }
  #step-edit:not(.simple-mode) .header-export-btn { min-width: 0; padding-left: 10px; padding-right: 10px; font-size: 0.9rem; }
}
/* 切り替えの下に案内を出す（重ねない） */
#step-edit.simple-mode #edit-status { top: calc(var(--safe-top) + 108px); }
/* 詳細編集は右上に「全体表示」があるため、切り替えは左に寄せる */
#step-edit:not(.simple-mode) .paper-view-switch { left: 8px; transform: none; }

/* 補正画面（2026-11-24）：長押しで画像の保存メニュー・文字の選択・ドラッグを出さない（この画面の中だけ） */
#step-correct, #step-correct * {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}

/* 2026-11-24：通常画面から外した入口（処理のため要素は残す） */
.retired-ui { display: none !important; }
/* 編集画面の「ホーム」。狭い画面では家の形だけ */
.home-btn { display: inline-flex; align-items: center; gap: 3px; }
.home-btn .header-btn-svg { width: 20px; height: 20px; }
@media (max-width: 460px) {
  .home-btn span { display: none; }
  .home-btn { min-width: 36px; padding-left: 6px; padding-right: 6px; }
}
/* ライブラリ：作品の削除の確かめ */
.library-delete-btn { margin-top: 10px; color: #b3261e; }
.library-delete-confirm { margin-top: 8px; padding: 10px; border: 1px solid var(--color-border); border-radius: 10px; }
.library-delete-confirm p { margin: 0 0 8px; font-size: 0.9rem; }
.library-badge.mode-mine { background: var(--color-panel-bg); }

/* 配置で画像を動かしている間の帯（2026-11-24） */
.place-mode-bar {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 12px;
  border-radius: 12px;
  background: #1a5fb4;
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: bold;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}
.place-mode-bar[hidden] { display: none; }
.place-mode-bar span { flex: 1 1 auto; line-height: 1.35; }
.place-mode-bar button {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 14px;
  border: none;
  border-radius: 10px;
  background: #ffffff;
  color: #1a5fb4;
  font-weight: bold;
  font-size: 0.92rem;
}
#canvas-viewport.image-move-mode .paper-view-switch { display: none; }
#canvas-viewport.image-move-mode { outline: 3px solid #1a5fb4; outline-offset: -3px; }

/* 詳細編集の重なりの順（2026-11-24） */
.layer-order-row { display: inline-flex; gap: 4px; }
.layer-order-row[hidden] { display: none; }
.icon-only-btn { min-width: 40px; padding-left: 8px; padding-right: 8px; }
.icon-only-btn .icon { width: 20px; height: 20px; }

/* 取り消し・やり直しは矢印だけ（2026-11-24） */
.undo-redo-btn { min-width: 40px; padding-left: 6px; padding-right: 6px; justify-content: center; }
.undo-redo-btn .header-btn-svg { width: 22px; height: 22px; }
.undo-redo-btn:disabled { opacity: 0.35; }

/* イベント版：文字の読み取り（OCR）の設定は出さない（2026-11-24。body.event-manual は script.js が付ける） */
body.event-manual .ocr-setting { display: none !important; }
/* 見せる範囲の一覧（2026-11-24）：ナイトモードでも読める色。どの枠か・選んでいるかだけ */
#rect-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--color-surface, #ffffff);
  color: var(--color-text);
}
#rect-list li.selected {
  background: var(--color-accent-bg);
  color: var(--color-text);
  font-weight: bold;
}
#rect-list .rect-swatch { flex: 0 0 auto; width: 14px; height: 14px; border-radius: 3px; border: 2px solid #1a5fb4; }
#rect-list li.selected .rect-swatch { border-color: #dd654e; background: rgba(221, 101, 78, 0.18); }
#rect-list .rect-state { margin-left: auto; font-size: 0.8rem; color: var(--color-text-soft); font-weight: normal; }
/* 「仕上げ」の中の出典（2026-11-24） */
.finish-source > summary { font-weight: bold; }

.finish-source { margin: 8px 0 4px; padding: 6px 10px; border: 1px solid var(--color-border); border-radius: 10px; }
.finish-source > summary { cursor: pointer; padding: 4px 0; font-size: 0.92rem; }
#bottom-sheet.finish-compact .finish-source { margin-top: 6px; padding: 2px 10px; }

/* ===== 2026-11-25：モード・メニューの整理 ===== */
/* スタンプ（独立）：「追加」の欄の切り替えは出さない。「追加」ではスタンプの欄を出さない */
#bottom-sheet.voice-sheet .add-tray-tabs { display: none; }
#bottom-sheet:not(.voice-sheet) .stamp-tray-tab[data-tray-tab="stamp"] { display: none; }
.voice-category-row { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.voice-category-row::-webkit-scrollbar { display: none; }
.voice-category-btn { flex: 0 0 auto; min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--color-border); background: var(--color-surface, #fff); color: var(--color-text); font-size: 0.85rem; white-space: nowrap; }
.voice-category-btn[aria-selected="true"] { background: var(--color-text); color: var(--color-bg); border-color: var(--color-text); font-weight: bold; }
.voice-grid > .voice-group-label { display: none; }
/* いまのモード（上部） */
.mode-switch { display: inline-flex; flex: 0 0 auto; padding: 2px; gap: 2px; border-radius: 999px; border: 1px solid var(--color-border); background: var(--color-surface, #fff); }
.mode-switch button { min-height: 32px; padding: 0 9px; border: none; border-radius: 999px; background: transparent; color: var(--color-text); font-size: 0.8rem; font-weight: bold; white-space: nowrap; }
.mode-switch button[aria-pressed="true"] { background: var(--color-text); color: var(--color-bg); }
#step-edit.simple-mode .simple-zoom { margin-left: auto; }
/* 紙面の上の行：元の紙面／加工後・見せる範囲を追加（全体表示は右上） */
.canvas-top-row { position: absolute; top: 8px; left: 8px; z-index: 7; display: flex; align-items: center; gap: 6px; max-width: calc(100% - 64px); }
.canvas-top-row .paper-view-switch { position: static; transform: none; }
#step-edit:not(.simple-mode) .canvas-top-row .paper-view-switch { left: auto; }
.top-add-frame-btn { display: inline-flex; align-items: center; gap: 4px; min-height: 40px; padding: 0 10px; border-radius: 999px; border: none; background: #1a5fb4; color: #fff; font-size: 0.82rem; font-weight: bold; white-space: nowrap; box-shadow: 0 2px 8px rgba(41, 44, 48, 0.2); }
.top-add-frame-btn .icon { width: 18px; height: 18px; }
#canvas-viewport.image-move-mode .canvas-top-row { display: none; }
/* 全体表示は狭い画面ではアイコンだけ（読み上げの名前は残す） */
@media (max-width: 460px) {
  #fit-view-btn span { display: none; }
  #fit-view-btn { min-width: 40px; padding-left: 8px; padding-right: 8px; }
  .paper-view-switch button { padding: 0 9px; font-size: 0.8rem; }
}
/* 下のメニュー：ふだんはアイコンだけ、選んでいる項目だけ名前を出す（幅は等分で、名前が出ても位置が跳ねない） */
#toolbar { display: grid !important; grid-template-columns: repeat(5, 1fr); }
#toolbar .tool-tab-btn { min-width: 0; }
#toolbar .tool-tab-btn .tool-tab-label { visibility: hidden; height: 1.2em; overflow: hidden; }
#toolbar .tool-tab-btn.active .tool-tab-label { visibility: visible; }
#simple-bar .simple-tabs { display: grid; grid-template-columns: 1fr 1fr 1.4fr 0.8fr; }
#simple-voice-btn span, #simple-add-stamp-btn span { visibility: hidden; height: 1.2em; overflow: hidden; }
#simple-voice-btn.active span, #simple-add-stamp-btn.active span { visibility: visible; }

.mode-choice-box h2 { font-size: 1.05rem; margin: 0 0 12px; }
.mode-choice-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 100%; margin: 0 0 10px; min-height: 64px; }
.mode-choice-btn small { font-size: 0.78rem; font-weight: normal; opacity: 0.85; }

/* 書き出すファイルの名前（2026-11-25） */
.export-filename-row { margin: 8px 0 4px; }
.export-filename-row label { display: block; font-size: 0.85rem; font-weight: bold; margin-bottom: 4px; }
.export-filename-input { display: flex; align-items: center; gap: 4px; }
.export-filename-input input { flex: 1 1 auto; min-width: 0; min-height: 40px; font-size: 16px; }
.export-filename-input span { flex: 0 0 auto; color: var(--color-text-soft); }
#export-preview { cursor: default; }

/* 紙面の記録（2026-11-25） */
.library-record { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--color-border); }
.library-record h3 { font-size: 0.95rem; margin: 0 0 4px; }
.library-record img { display: block; width: 100%; height: auto; margin: 6px 0; border-radius: 6px; border: 1px solid var(--color-border); }
.library-record-fields { display: grid; gap: 4px; margin: 6px 0; }
.library-record-fields input { min-height: 40px; font-size: 16px; }

/* ホーム（2026-11-25） */
.app-lead { margin: 6px 16px 0; text-align: center; font-size: 0.9rem; line-height: 1.6; word-break: keep-all; overflow-wrap: anywhere; font-weight: bold; color: var(--color-text); }
#step-load .file-input-row { display: flex; flex-direction: column; gap: 12px; }
#step-load .file-input-row .file-btn { width: 100%; min-height: 64px; justify-content: center; font-size: 1.08rem; font-weight: bold; border-radius: 16px; }
#step-load .file-input-row .file-btn .file-btn-icon { width: 28px; height: 28px; }
.home-illust { margin: 0 auto 12px; max-width: 420px; padding: 0 16px; }
.home-illust img { display: block; width: 100%; height: auto; border-radius: 16px; }
.home-illust-library { padding: 0; margin-bottom: 8px; }
.feedback-home-btn { width: 100%; margin-top: 12px; }
/* 狭い画面で上の帯がはみ出さないよう、モードの切り替えと保存の状態を詰める（2026-11-25） */
@media (max-width: 460px) {
  .mode-switch button { padding: 0 6px; font-size: 0.74rem; min-height: 30px; }
  #step-edit:not(.simple-mode) #autosave-chip { min-width: 24px; max-width: 24px; }
  #editor-header { gap: 3px; }
  #editor-header .home-btn { min-width: 34px; }
}
#editor-header #simple-back-btn, #editor-header .editor-about-btn { display: none !important; }
@media (max-width: 460px) {
  #editor-header .undo-redo-btn { min-width: 34px !important; padding-left: 4px !important; padding-right: 4px !important; }
  #step-edit.simple-mode .simple-zoom .editor-header-btn { min-width: 30px; }
}
/* 選んだ物の操作（角度・詳細など）：地はどの表示でも濃い色なので、文字はいつも白にする（ナイトモードで読めなかった。2026-11-25） */
#canvas-action-row #angle-toggle-btn,
#canvas-action-row .tool-btn.quiet-btn,
#canvas-action-row .look-cycle-btn { color: #ffffff; }
#canvas-action-row #angle-toggle-btn svg,
#canvas-action-row .tool-btn.quiet-btn .icon { stroke: currentColor; }

/* 発行日不明（2026-11-25-event6）：日付の欄のすぐ下に小さく。チェック中は日付の欄を使えなくする */
.date-unknown { display: inline-flex; align-items: center; gap: 6px; margin: 4px 0 2px; font-size: 0.88rem; font-weight: normal; }
.date-unknown input { width: 18px; height: 18px; margin: 0; }
input[type="date"]:disabled { opacity: 0.45; }
.date-unknown input { min-height: 0; }
/* 紙面の出典の「✎ 編集」の欄 */
.source-edit-pop { width: min(320px, calc(100vw - 32px)); gap: 8px; }
/* 紙面の上寄りに出す（出典は紙面の下に置かれることが多く、変えた結果が隠れないように） */
#source-edit-pop { position: fixed; left: 50%; transform: translateX(-50%); top: calc(118px + env(safe-area-inset-top, 0px)); z-index: 60; margin: 0; color: var(--color-text); }
#source-edit-pop .source-edit-close { align-self: flex-end; min-height: 40px; padding: 0 16px; border: 1px solid var(--color-border); border-radius: 10px; background: var(--color-surface); color: var(--color-text); font-weight: bold; }
.simple-source-edit-btn { width: auto; padding: 0 12px; font-weight: bold; white-space: nowrap; color: var(--color-text); }
.simple-source-edit-btn.active { color: var(--color-text); border-color: var(--color-accent, #c8553d); box-shadow: 0 0 0 2px var(--color-accent, #c8553d); }

/* テスト版の表示と感想フォームへのリンク（2026-11-25-event7） */
.app-test-label { margin: 8px 0 0; }
.test-badge { display: inline-block; padding: 2px 12px; border: 1.5px solid var(--color-accent-ink); border-radius: 999px; font-size: 0.85rem; font-weight: bold; letter-spacing: 0.08em; color: var(--color-accent-ink); background: var(--color-accent-bg); }
.test-form-link { display: flex; align-items: center; justify-content: center; width: 100%; min-height: var(--touch-min); margin-top: 12px; padding: 10px 18px; box-sizing: border-box; border-radius: var(--radius-btn); font-size: 1rem; text-decoration: none; color: var(--color-text); border: 1px solid var(--color-border); font-weight: bold; }

/* ============================================================
   2026-11-25-event9：ブランド「新聞で話そう／shimbuntalk」のデザイントークン（ここが最後に効く）
   ・墨 #222222、差し色（深い赤）#AB1E24、地は白、面を分けるときだけごく薄い温かみのあるグレー
   ・赤は主要ボタン・選択中・フォーカスなど意味のある所だけ。ボタンの既定は白地に細い罫線
   ・エラー・削除は赤と分ける：色（茶がかった朱）＋「⚠」・ごみ箱のアイコン＋文言で区別する
   ・角丸：ボタン・入力欄・メニュー 10px、カード・ダイアログ 14px。線は 1px の細い罫線
   ============================================================ */
:root[data-theme="light"] {
  --brand-ink: #222222;
  --brand-red: #ab1e24;
  --paper: #ffffff;
  --surface: #ffffff;
  --ink: #222222;
  --muted: #5f5b56;
  --line: #e2dfda;
  --accent: #ab1e24;
  --accent-soft: #f7e8e8;
  --color-bg: #ffffff;
  --color-surface: #ffffff;
  --color-text: #222222;
  --color-text-soft: #5f5b56;
  --color-accent: #ab1e24;
  --color-accent-bg: #f7e8e8;
  --color-accent-ink: #8e181d;
  --color-accent-contrast: #ffffff;
  --color-border: #e2dfda;
  --color-panel-bg: #f6f5f2; /* ごく薄い温かみのあるグレー（面を分けるときだけ） */
  --color-comment-bg: #f6f5f2;
  --color-danger: #9a4a12;
  --color-danger-bg: #fbf1e6;
  --color-required: #9a4a12;
  --color-rule-strong: #222222;
  --shadow-card: 0 1px 2px rgba(34, 34, 34, 0.06), 0 4px 12px rgba(34, 34, 34, 0.06);
}
:root[data-theme="dark"] {
  --brand-ink: #f2eee8;
  --brand-red: #c7353b;
  --paper: #1c1b1a;
  --surface: #262524;
  --ink: #f2eee8;
  --muted: #b5afa8;
  --line: #3e3b38;
  --accent: #c7353b;
  --accent-soft: #3d2324;
  --color-bg: #1c1b1a;
  --color-surface: #262524;
  --color-text: #f2eee8;
  --color-text-soft: #b5afa8;
  --color-accent: #c7353b;
  --color-accent-bg: #3d2324;
  --color-accent-ink: #f2a9ac;
  --color-accent-contrast: #ffffff;
  --color-border: #3e3b38;
  --color-panel-bg: #232221;
  --color-comment-bg: #2c2a28;
  --color-danger: #f0a35e;
  --color-danger-bg: #3a2a1c;
  --color-required: #f0a35e;
  --color-rule-strong: #f2eee8;
  --shadow-card: 0 4px 14px rgba(0, 0, 0, 0.35);
}
:root {
  --radius-btn: 10px;
  --radius-input: 10px;
  --radius-card: 14px;
  --radius-tile: 10px;
  --line-w: 1px;
  --font-main: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", "Meiryo", sans-serif;
  --fs-body: 1rem;
  --fs-small: 0.85rem;
  --fs-caption: 0.78rem;
}

/* ---- ロゴ（ホームは日本語版。暗い表示では明るい色の版に替える） ---- */
.logo-for-dark { display: none; }
:root[data-theme="dark"] .logo-for-light { display: none; }
:root[data-theme="dark"] .logo-for-dark { display: inline-block; }
h1.app-logo { margin: 0 auto; padding: 4px 0; line-height: 0; white-space: normal; }
h1.app-logo .logo-img { width: min(300px, 78vw); height: auto; } /* 縦横比を保つ（幅だけ決める）。周りは header の余白 */
.about-logos { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin: 4px 0 12px; }
.about-logo { width: min(240px, 70vw); height: auto; }
.about-logo-en { width: min(170px, 50vw); height: auto; }
:root[data-theme="dark"] .about-logos .logo-for-dark { display: block; }

/* ---- ボタンの既定：白地・墨の文字・細い罫線（以前は既定が差し色で、ほとんどのボタンが色付きだった） ---- */
button {
  background: var(--color-surface);
  color: var(--color-text);
  border: var(--line-w) solid var(--color-border);
  border-radius: var(--radius-btn);
  font-weight: 600;
}
button:disabled { opacity: 0.45; }
/* 主要ボタン（各画面で次に進む1つ）だけ差し色で塗る */
.primary-btn,
.file-btn-primary,
#crop-confirm-btn,
#correct-confirm-btn,
#auto-save-btn,
#export-btn,
#simple-done-btn,
#export-share-btn,
#library-resume-btn,
#leave-save-btn,
#correct-impact-ok,
.mode-choice-btn[data-start-mode="simple"] {
  background: var(--color-accent);
  color: var(--color-accent-contrast);
  border: var(--line-w) solid var(--color-accent);
  box-shadow: none;
}
/* 選んでいる状態：薄い赤の地＋赤の線＋濃い赤の文字（塗りつぶしは主要ボタンだけ） */
.mode-btn.active,
.stepper-btn.active,
.seg-btn.active,
.seg-btn[aria-pressed="true"],
.mode-btn[aria-pressed="true"] {
  background: var(--color-accent-bg);
  color: var(--color-accent-ink);
  border: var(--line-w) solid var(--color-accent);
}
/* フォーカス：差し色の輪郭 */
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, label.file-btn:focus-within {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
/* 入力欄・選択欄：同じ角丸・線・高さ */
input[type="text"], input[type="date"], input[type="number"], select, textarea {
  border: var(--line-w) solid var(--color-border);
  border-radius: var(--radius-input);
  background: var(--color-surface);
  color: var(--color-text);
}
input[type="text"]:focus, input[type="date"]:focus, input[type="number"]:focus, select:focus, textarea:focus { border-color: var(--color-accent); }
/* 差し色のチェック・つまみ */
input[type="checkbox"], input[type="radio"], input[type="range"] { accent-color: var(--color-accent); }

/* ---- エラー・削除：差し色の赤とは別の色（茶がかった朱）＋「⚠」・ごみ箱＋文言で区別する ---- */
.field-error { color: var(--color-danger); }
.field-error::before, .status.error::before, #edit-status.error::before { content: "⚠ "; }
.status.error, #edit-status.error, .autosave-status.error, .auto-summary.error { color: var(--color-danger); }
.library-delete-btn { color: var(--color-danger); background: var(--color-surface); border-color: var(--color-border); }
.library-delete-btn::before { content: "🗑 "; }
.stepper-btn.danger { color: var(--color-danger); border-color: var(--color-danger); background: var(--color-danger-bg); }
.auto-step[data-state="ng"] { border-color: var(--color-danger); }
.auto-step[data-state="ng"] .auto-step-ico { background: var(--color-danger); }

/* ---- ホーム：ロゴ・テスト版の札・リード（新聞の見出し回りのように細い罫線で区切る） ---- */
.test-badge { border: var(--line-w) solid var(--color-text); color: var(--color-text); background: transparent; font-size: var(--fs-caption); letter-spacing: 0.12em; padding: 1px 10px; border-radius: 4px; }
.app-test-label { margin: 6px 0 0; }
.app-lead {
  max-width: 340px;
  margin: 14px auto 0;
  padding: 10px 4px;
  border-top: var(--line-w) solid var(--color-text);
  border-bottom: var(--line-w) solid var(--color-border);
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.75;
  color: var(--color-text);
}
.app-version { margin-top: 8px; font-size: var(--fs-caption); }
.hero-card { box-shadow: none; padding: 22px 18px 18px; }
.hero-card .status:empty { display: none; }
#step-load .file-input-row .file-btn { border-radius: var(--radius-btn); box-shadow: none; }
#step-load .file-input-row .file-btn:not(.file-btn-primary) { border: var(--line-w) solid var(--color-border); background: var(--color-surface); color: var(--color-text); }
.test-form-link { border-radius: var(--radius-btn); font-weight: 600; }

/* ---- 編集画面：見せる範囲を追加（四隅の枠のアイコン＝ロゴの「見せたい部分を選ぶ枠」） ---- */
.top-add-frame-btn { background: var(--color-surface); color: var(--color-text); border: var(--line-w) solid var(--color-border); border-radius: var(--radius-btn); box-shadow: 0 1px 4px rgba(34, 34, 34, 0.12); }
.top-add-frame-btn .icon { color: var(--color-accent); }
/* ダイアログ・パネルの見出しの左の印：差し色ではなく墨の罫線にする */
h2, .modal-box h2 { border-left-color: var(--color-rule-strong); }
.legal-hint, .auto-mask-note { border-left-color: var(--color-border); }
/* 選んだ項目の星・簡易編集の選んだタブ：以前のコーラルを差し色に */
.fav-star[aria-pressed="true"] { color: var(--color-accent); }
.fav-star[aria-pressed="true"] .icon { fill: var(--color-accent); }
.simple-tab.active { background: var(--color-accent-bg); border-color: var(--color-accent); color: var(--color-accent-ink); }
.correct-save-original { border-color: var(--color-accent) !important; color: var(--color-accent); }
.canvas-bg-swatch[aria-pressed="true"], .dest-btn[aria-pressed="true"], .dest-btn[aria-expanded="true"] { border-color: var(--color-accent); }
.shoot-guide { color: var(--color-accent); }
/* ダイアログ・メニュー・パネル：角丸・線をそろえる */
.modal-box, .settings-box, .simple-menu, .text-color-pop { border-radius: var(--radius-card); }
.modal-box, .settings-box { border: var(--line-w) solid var(--color-border); }
/* パネルの題：墨（差し色は使わない） */
#sheet-title { color: var(--color-text); }
/* 書き出しの出典の要約：文字が長くても ✎ が枠の外に落ちないよう横に並べる */
.export-source-summary:not([hidden]) { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 500; }
.export-source-summary::after { float: none; flex: none; }
/* 幅 359px 以下（iPhone SE 第1世代など）：編集の上の帯が画面の外にはみ出さないよう詰める（event8 以前からのはみ出しの修正） */
@media (max-width: 359px) {
  #autosave-chip { display: none; }
  #export-btn { padding: 0 8px; font-size: 0.85rem; min-width: 0; }
  #mode-switch button { padding-left: 6px; padding-right: 6px; }
  #mode-switch .mode-suffix { display: none; } /* 「簡易」「詳細」だけにする（読み上げは「簡易編集」「詳細編集」のまま） */
  #step-edit #editor-header, #step-edit .editor-header { gap: 2px; }
}
