/* ============================================================
   Simple Image — Main Stylesheet
   Simple PDF と同じ明るいテイスト(白基調 + 青アクセント)
   ============================================================ */

:root {
  /* === ベース(Simple PDF と一致) === */
  --bg: #f5f7fa;
  --surface: #ffffff;
  --text: #2c3e50;
  --text-muted: #8898a8;
  --text-dim: #b0bec5;

  /* === アクセント === */
  --primary: #5b8def;
  --primary-hover: #4a7bdc;
  --primary-light: #eef4ff;
  --primary-light-purple: #f5f0ff;
  --success: #4caf50;
  --success-hover: #43a047;
  --warn-bg: #fff7e6;
  --warn-border: #f7d68c;
  --warn-text: #6f5400;

  /* === ボーダー === */
  --border: #e0e6ed;
  --border-input: #d0d8e0;
  --border-dashed: #b0c4d8;

  /* === ボタン === */
  --btn-bg: #f5f7fa;
  --btn-hover: #e9eef5;

  /* === レイアウト === */
  --header-height: 53px;
  --sidebar-width: 88px;
  --toolbar-height: 48px;

  /* === キャンバス === */
  --canvas-bg: #fafbfc;
  --canvas-checker-a: #f0f3f7;
  --canvas-checker-b: #ffffff;

  /* === Modal / Toast === */
  --modal-backdrop: rgba(40, 50, 65, 0.55);
  --toast-bg: rgba(44, 62, 80, 0.95);

  /* === 半径 === */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;

  /* === フォント === */
  --font-en: 'Inter', sans-serif;
  --font-jp: 'Noto Sans JP', sans-serif;
}

/* ============================================================
   Reset
   ============================================================ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  font-family: var(--font-jp);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: transparent; color: inherit; }
input { font-family: inherit; }
img { max-width: 100%; display: block; }

/* ============================================================
   Header
   ============================================================ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}
.back-link {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--primary);
  background: var(--surface);
  white-space: nowrap;
  transition: background 0.2s, border-color 0.2s;
}
.back-link:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

.brand-title {
  font-family: var(--font-en);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.brand-fast { color: var(--primary); }
.brand-sub {
  font-family: var(--font-jp);
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0;
}

.header-actions {
  display: none;
  gap: 8px;
  align-items: center;
}
body:has(#screen-edit.is-active) .header-actions { display: flex; }

/* ============================================================
   Mobile Notice
   ============================================================ */
.mobile-notice {
  display: none;
  padding: 10px 16px;
  background: var(--warn-bg);
  border-bottom: 1px solid var(--warn-border);
  color: var(--warn-text);
  font-size: 0.82rem;
  text-align: center;
}
.mobile-notice strong { color: var(--warn-text); }

/* ============================================================
   Screens
   ============================================================ */
.screen { display: none; }
.screen.is-active { display: flex; }

/* ============================================================
   Screen: Drop
   ============================================================ */
#screen-drop {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  min-height: calc(100vh - var(--header-height) - 240px);
  padding: 60px 24px 40px;
}

.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: min(100%, 700px);
  padding: 70px 60px;
  background: var(--surface);
  border: 3px dashed var(--border-dashed);
  border-radius: 18px;
  text-align: center;
  transition: all 0.25s ease;
  cursor: pointer;
}
.drop-zone:hover,
.drop-zone.is-hover {
  border-color: var(--primary);
  background: var(--primary-light);
}
.drop-zone__icon { font-size: 3.6rem; }
.drop-zone__title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.drop-zone__or {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 8px 0;
}
.drop-zone__hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 10px;
}
.drop-zone__formats {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.btn-primary {
  padding: 12px 36px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
}
.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(91, 141, 239, 0.25);
}

.privacy-note {
  max-width: 640px;
  padding: 20px 28px;
  color: var(--text-muted);
  font-size: 0.88rem;
  text-align: center;
  line-height: 1.85;
}
.privacy-note strong { color: var(--text); font-weight: 700; }
.privacy-note__detail {
  display: block;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* ドロップ画面の代替ルート(結合だけしたい人向け) */
.drop-alt {
  width: min(100%, 700px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
}
.drop-alt__divider {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--text-muted);
  font-size: 0.82rem;
}
.drop-alt__divider::before,
.drop-alt__divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.drop-alt__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 24px;
  background: var(--surface);
  border: 2px dashed var(--border-dashed);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
.drop-alt__btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  transform: translateY(-1px);
}
.drop-alt__icon {
  font-size: 1.2rem;
}

/* ===== 白紙から作る(プリセット) ===== */
.drop-blank {
  width: 100%;
  max-width: 640px;
  margin: 8px auto 0;
}
.drop-blank__lead {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 4px 0 14px;
  line-height: 1.6;
}
.drop-blank__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}
.drop-blank__btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 12px 10px;
  background: var(--surface);
  border: 1px solid var(--border-dashed);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
.drop-blank__btn small {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.drop-blank__btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  transform: translateY(-1px);
}
.drop-blank__custom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}
.drop-blank__custom-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 700;
}
.drop-blank__custom input[type="number"] {
  width: 84px;
  padding: 7px 9px;
  background: var(--surface);
  border: 1px solid var(--border-dashed);
  border-radius: var(--radius-sm, 8px);
  color: var(--text);
  font-size: 0.9rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.drop-blank__times,
.drop-blank__unit {
  color: var(--text-muted);
  font-size: 0.85rem;
}
.drop-blank__custom-btn {
  padding: 8px 16px;
  background: var(--primary);
  border: none;
  border-radius: var(--radius-sm, 8px);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s, transform 0.15s;
}
.drop-blank__custom-btn:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

/* ============================================================
   Screen: Edit
   ============================================================ */
#screen-edit {
  flex-direction: row;
  height: calc(100vh - var(--header-height));
  min-height: 500px;
  background: linear-gradient(to right, var(--surface) var(--sidebar-width), transparent var(--sidebar-width));
}

/* ===== Sidebar(sticky) ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 8px 6px;
  gap: 4px;
  flex-shrink: 0;
  overflow-y: auto;
  position: sticky;
  top: var(--header-height);
  align-self: flex-start;
  max-height: calc(100vh - var(--header-height));
  z-index: 50;
}
.sidebar-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 4px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
  min-height: 64px;
}
.sidebar-btn:hover {
  background: var(--btn-hover);
  color: var(--text);
}
.sidebar-btn.is-active {
  background: var(--primary);
  color: #fff;
}
.sidebar-btn__icon {
  font-size: 1.4rem;
  font-family: var(--font-en);
  font-weight: 700;
  line-height: 1;
}
.sidebar-btn__label {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.sidebar__divider {
  height: 1px;
  background: var(--border);
  margin: 6px 8px;
}

/* ===== Main Area =====
 * min-width / min-height: 0 は flex item が overflow:auto を正しく機能させるための必須指定 */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}

/* ===== Toolbar(sticky・2 段構造)=====
 * 上段: コントロール(設定・ボタン)
 * 下段: 操作説明 / ステータス
 * 横スクロールは廃止。コントロールは flex-wrap で折り返し可能 */
.toolbar {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: sticky;
  top: var(--header-height);
  z-index: 40;
  transform: translateZ(0);
}
.toolbar-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 42px;
  padding: 6px 16px;
  flex-wrap: wrap;
  row-gap: 6px;
}
.toolbar-info {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 26px;
  padding: 4px 16px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  row-gap: 2px;
}

/* 下段の操作説明文要素 */
.ctx-info-text {
  display: none;
  white-space: nowrap;
}
.ctx-info-text.is-dynamic {
  color: var(--text);
  font-weight: 500;
}
.toolbar-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
}
/* デフォルトは表示(undo/redo / zoom グループ用)。
   ツール固有パネル([data-tool-context]付き)だけ初期非表示にする */
.toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.toolbar-group[data-tool-context] { display: none; }
.toolbar-spacer { flex: 1; }
.toolbar-label {
  font-size: 0.78rem;
  color: var(--text-muted);
}
#zoom-slider {
  width: 100px;
  accent-color: var(--primary);
}
#zoom-display {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 38px;
}

/* ツール切替に応じた表示制御 */
#screen-edit[data-active-tool="crop"]       .toolbar-main [data-tool-context="crop"],
#screen-edit[data-active-tool="resize"]     .toolbar-main [data-tool-context="resize"],
#screen-edit[data-active-tool="mosaic"]     .toolbar-main [data-tool-context="mosaic"],
#screen-edit[data-active-tool="bgremove"]   .toolbar-main [data-tool-context="bgremove"],
#screen-edit[data-active-tool="eraser"]     .toolbar-main [data-tool-context="eraser"],
#screen-edit[data-active-tool="text"]       .toolbar-main [data-tool-context="text"],
#screen-edit[data-active-tool="shape"]      .toolbar-main [data-tool-context="shape"],
#screen-edit[data-active-tool="eyedropper"] .toolbar-main [data-tool-context="eyedropper"],
#screen-edit[data-active-tool="compress"]   .toolbar-main [data-tool-context="compress"],
#screen-edit[data-active-tool="insert"]     .toolbar-main [data-tool-context="insert"] {
  display: flex;
}
/* 下段 info も同様に切替 */
#screen-edit[data-active-tool="crop"]       .toolbar-info [data-tool-context="crop"],
#screen-edit[data-active-tool="resize"]     .toolbar-info [data-tool-context="resize"],
#screen-edit[data-active-tool="mosaic"]     .toolbar-info [data-tool-context="mosaic"],
#screen-edit[data-active-tool="bgremove"]   .toolbar-info [data-tool-context="bgremove"],
#screen-edit[data-active-tool="eraser"]     .toolbar-info [data-tool-context="eraser"],
#screen-edit[data-active-tool="text"]       .toolbar-info [data-tool-context="text"],
#screen-edit[data-active-tool="shape"]      .toolbar-info [data-tool-context="shape"],
#screen-edit[data-active-tool="eyedropper"] .toolbar-info [data-tool-context="eyedropper"],
#screen-edit[data-active-tool="compress"]   .toolbar-info [data-tool-context="compress"] {
  display: inline-block;
}

#screen-edit:not([data-active-tool="none"]) .toolbar-info .toolbar-hint { display: none; }

/* ===== Canvas Area =====
 * 「centered overflow」パターン:
 *   canvas-area がスクロール容器、canvas-stage は中身を centered する内側コンテナ。
 *   flex で justify-content:center を直接 overflow:auto のスクロール容器に使うと、
 *   横方向の overflow がスクロール対象にならない既知のバグがある。
 *   stage が min-{w,h}: 100% で「canvas-area 以上の大きさ」を保証することで、
 *   wrapper が小さい時は中央寄せ、大きい時は overflow + scroll が両立する。
 */
.canvas-area {
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow: auto;
  background-color: var(--canvas-bg);
  background-image: repeating-conic-gradient(var(--canvas-checker-a) 0deg 90deg, var(--canvas-checker-b) 90deg 180deg);
  background-size: 24px 24px;
  background-position: 0 0;
}
.canvas-stage {
  min-width: 100%;
  min-height: 100%;
  padding: 24px;
  display: flex;
  /* "safe center": wrapper が容器より大きい時はスクロール先頭(左/上)に整列。
     通常の "center" だと負方向の overflow がクリップされてスクロールできない */
  align-items: safe center;
  justify-content: safe center;
  box-sizing: border-box;
  width: fit-content;  /* 中身が大きい時に親をはみ出して伸びる */
}

.canvas-wrapper {
  position: relative;
  display: inline-block;
  background: var(--surface);
  box-shadow: 0 4px 16px rgba(44, 62, 80, 0.12), 0 1px 2px rgba(44, 62, 80, 0.08);
  border: 1px solid var(--border);
}
.canvas {
  display: block;
  max-width: none;
}
.canvas--base { position: relative; z-index: 1; }
.canvas--overlay {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  pointer-events: none;
}
/* 注釈(図形)レイヤー:overlay の上・テキスト/画像 div(z-index 10)の下 */
.canvas--annotation {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 3;
  pointer-events: none;
}
/* 注釈(テキスト/挿入画像/図形)は保存まで保持されるが、操作できるのは
   その注釈のツールがアクティブなときだけ。他ツールでの作業を邪魔しない。 */
.text-overlay { pointer-events: none; }
.image-overlay { pointer-events: none; }
#screen-edit[data-active-tool="text"] .text-overlay { pointer-events: auto; }
#screen-edit[data-active-tool="insert"] .image-overlay { pointer-events: auto; }
#screen-edit[data-active-tool="shape"] .canvas--annotation { pointer-events: auto; }

/* ============================================================
   Buttons
   ============================================================ */
.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: var(--btn-bg);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.tool-btn:hover:not(:disabled) {
  background: var(--btn-hover);
  border-color: var(--primary);
}
.tool-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.tool-btn.is-primary {
  background: var(--success);
  color: #fff;
  border-color: var(--success-hover);
  font-weight: 700;
}
.tool-btn.is-primary:hover:not(:disabled) {
  background: var(--success-hover);
  border-color: var(--success-hover);
}
.tool-btn--sm {
  padding: 4px 10px;
  font-size: 0.75rem;
}
.tool-btn__icon { font-size: 0.95rem; line-height: 1; }

/* ============================================================
   Screen: Combine(画像結合専用画面)
   ============================================================ */
#screen-combine {
  flex-direction: column;
  height: calc(100vh - var(--header-height));
  min-height: 500px;
  background: var(--bg);
}
#screen-combine.is-dragover {
  outline: 3px dashed var(--primary);
  outline-offset: -16px;
  background: var(--primary-light);
}

.combine-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.combine-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}
.combine-info-text {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.combine-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  row-gap: 6px;
}
.combine-control-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.combine-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
}
.combine-layout-btn {
  padding: 5px 12px;
  background: var(--btn-bg);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text);
  transition: background 0.15s, color 0.15s;
}
.combine-layout-btn:hover {
  background: var(--btn-hover);
  border-color: var(--primary);
}
.combine-layout-btn.is-active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary-hover);
}
.combine-bg-radio {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  font-size: 0.82rem;
  cursor: pointer;
  user-select: none;
}
.combine-bg-radio input[type="color"] {
  width: 24px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.combine-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

.combine-sidebar {
  width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.combine-sidebar__header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.combine-image-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.combine-thumb {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.combine-thumb__img-wrap {
  width: 100%;
  height: 80px;
  background: repeating-conic-gradient(var(--canvas-checker-a) 0deg 90deg, var(--canvas-checker-b) 90deg 180deg) 0 0/12px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.combine-thumb__img {
  max-width: 100%;
  max-height: 100%;
  display: block;
}
.combine-thumb__meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  color: var(--text-muted);
}
.combine-thumb__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  background: var(--primary);
  color: #fff;
  border-radius: 999px;
  font-weight: 700;
}
.combine-thumb__size {
  font-family: 'SF Mono', Consolas, Monaco, monospace;
}
.combine-thumb__actions {
  display: flex;
  gap: 4px;
}
.combine-thumb__btn {
  flex: 1;
  padding: 4px 0;
  background: var(--btn-bg);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  color: var(--text);
  cursor: pointer;
}
.combine-thumb__btn:hover:not(:disabled) {
  background: var(--btn-hover);
  border-color: var(--primary);
}
.combine-thumb__btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.combine-thumb__btn--del {
  flex: 0 0 36px;
  background: #fff5f5;
  border-color: #fbb;
  color: #c33;
}
.combine-thumb__btn--del:hover:not(:disabled) {
  background: #ffe;
  border-color: #d44;
}

.combine-preview-area {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: auto;
  background-color: var(--canvas-bg);
  background-image: repeating-conic-gradient(var(--canvas-checker-a) 0deg 90deg, var(--canvas-checker-b) 90deg 180deg);
  background-size: 24px 24px;
  background-position: 0 0;
}
.combine-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  color: var(--text-muted);
  padding: 40px;
  background: var(--surface);
  border: 3px dashed var(--border-dashed);
  border-radius: var(--radius-lg);
  min-width: 420px;
}
.combine-empty__icon { font-size: 2.6rem; }
.combine-empty__title { font-size: 1rem; font-weight: 700; color: var(--text); line-height: 1.6; }
.combine-empty__detail { font-size: 0.78rem; color: var(--text-dim); }

.combine-preview {
  display: inline-block;
  box-shadow: 0 6px 24px rgba(40, 50, 65, 0.18);
  background: var(--surface);
}
.combine-preview__img {
  display: block;
  max-width: 100%;
}

.combine-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.combine-footer__actions {
  display: flex;
  gap: 10px;
  align-items: center;
}
.combine-info {
  font-size: 0.85rem;
  color: var(--text);
}

@media (max-width: 768px) {
  #screen-combine { height: auto; }
  .combine-body { flex-direction: column; }
  .combine-sidebar { width: 100%; max-height: 280px; }
}

/* ============================================================
   Toast(画面上部中央)
   ============================================================ */
.toast {
  position: fixed;
  top: 70px;
  left: 50%;
  z-index: 1000;
  padding: 12px 24px;
  background: var(--toast-bg);
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 0.85rem;
  line-height: 1.5;
  box-shadow: 0 6px 24px rgba(40, 50, 65, 0.25);
  opacity: 0;
  transform: translate(-50%, -8px);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  max-width: min(560px, 92vw);
  /* 長文は複数行で表示(エラーメッセージなど) */
  white-space: normal;
  word-break: break-word;
  text-align: center;
}
.toast.is-show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ============================================================
   Modal
   ============================================================ */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 500;
  background: var(--modal-backdrop);
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-backdrop.is-show { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 540px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(40, 50, 65, 0.35);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.modal-close {
  font-size: 1.4rem;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}
.modal-close:hover { background: var(--btn-hover); color: var(--text); }
.modal-body {
  padding: 22px;
  overflow-y: auto;
  flex: 1;
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.8;
}
.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: #fafbfc;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ============================================================
   VoiceCTA (Simple PDF と同じ)
   ============================================================ */
.voice-cta {
  padding: 36px 24px;
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary-light-purple) 100%);
  border-top: 1px solid var(--border);
  text-align: center;
}
.voice-cta__text {
  font-size: 0.92rem;
  color: var(--text);
  margin-bottom: 18px;
  line-height: 1.9;
}
.voice-cta__text strong { color: var(--primary); font-weight: 700; }
.voice-cta__btn {
  display: inline-block;
  padding: 12px 30px;
  background: var(--primary);
  color: #fff;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
}
.voice-cta__btn:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(91, 141, 239, 0.3);
}

/* ============================================================
   フィードバックモーダル & フッター常設リンク
   ============================================================ */
.site-footer__counter {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  font-size: 0.84rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.sf-counter {
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid;
}
.sf-counter--tool {
  background: linear-gradient(180deg, rgba(91,141,239,0.10), rgba(91,141,239,0.04));
  border-color: rgba(91, 141, 239, 0.25);
  color: #4a6fb8;
}
.sf-counter--total {
  background: linear-gradient(180deg, rgba(255,179,40,0.13), rgba(255,179,40,0.05));
  border-color: rgba(255, 179, 40, 0.35);
  color: #a87000;
}
.site-footer__feedback {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}
.footer-feedback {
  display: inline-block;
  padding: 8px 18px;
  background: var(--primary-light);
  color: var(--primary) !important;
  border: 1px solid #c9dcf7;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none !important;
  transition: background 0.2s, transform 0.15s;
}
.footer-feedback:hover {
  background: #dfecff;
  transform: translateY(-1px);
}

.modal--feedback { width: 480px; max-width: 92vw; }
.feedback-intro {
  margin-bottom: 16px;
  line-height: 1.8;
  font-size: 0.92rem;
}
.feedback-block__title {
  font-size: 0.92rem;
  color: var(--text);
  margin-bottom: 8px;
  font-weight: 700;
  line-height: 1.6;
}
.feedback-block__body {
  font-size: 0.84rem;
  color: var(--text);
  line-height: 1.8;
  margin-bottom: 14px;
}
.feedback-block__body strong { color: var(--primary); }
.feedback-block__note {
  font-size: 0.74rem;
  color: var(--text-dim);
  line-height: 1.6;
  margin-bottom: 14px;
}
.feedback-cta {
  display: block;
  text-align: center;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 700;
  transition: background 0.2s, transform 0.15s;
}
.feedback-cta--primary {
  background: var(--primary);
  color: #fff;
}
.feedback-cta--primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}
.feedback-cta--secondary {
  background: var(--btn-bg);
  color: var(--text);
  border: 1px solid var(--border-input);
  font-weight: 500;
}
.feedback-cta--secondary:hover {
  background: var(--btn-hover);
  border-color: var(--primary);
}
.feedback-divider {
  border-top: 1px solid var(--border);
  margin-top: 22px;
  padding-top: 18px;
}
.feedback-divider__text {
  font-size: 0.82rem;
  color: var(--text);
  line-height: 1.7;
  margin-bottom: 12px;
}

/* ============================================================
   Site Footer (Simple PDF と同じ)
   ============================================================ */
.site-footer {
  padding: 26px 24px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  text-align: center;
}
.site-footer__links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px 20px;
  margin-bottom: 12px;
  font-size: 0.82rem;
}
.site-footer__links a {
  color: var(--primary);
  transition: color 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.site-footer__links a:hover { color: var(--primary-hover); }
.site-footer__copy {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-family: var(--font-en);
}

/* ============================================================
   Tool Context Panel Common
   ============================================================ */
.ctx-select,
.ctx-num {
  padding: 5px 10px;
  background: var(--surface);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.82rem;
  transition: border-color 0.15s;
}
.ctx-select:focus,
.ctx-num:focus {
  outline: none;
  border-color: var(--primary);
}
.ctx-num {
  width: 84px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.ctx-times {
  color: var(--text-muted);
  font-size: 0.9rem;
}
.ctx-unit {
  color: var(--text-muted);
  font-size: 0.78rem;
  min-width: 24px;
}
.ctx-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.ctx-check input { accent-color: var(--primary); }
.ctx-info,
.ctx-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.toolbar-divider {
  display: inline-block;
  width: 1px;
  height: 22px;
  background: #94a3b8;  /* slate-400 相当、border-input より明確に濃い */
  margin: 0 6px;
  flex-shrink: 0;
}

/* タブ切替(resize の px/% など) */
.ctx-tabs {
  display: inline-flex;
  background: var(--btn-bg);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}
.ctx-tab {
  padding: 3px 12px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 3px;
  transition: background 0.15s, color 0.15s;
}
.ctx-tab:hover { color: var(--text); }
.ctx-tab.is-active {
  background: var(--primary);
  color: #fff;
}

/* bgremove のステップ手順表示(数字 + アクション + 矢印) */
.toolbar-group--steps {
  align-items: center;
  gap: 8px;
}
/* 番号バッジ:数字だけ、ボタンに見えないようシンプル */
.bgr-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--text-muted);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 800;
  font-family: 'SF Mono', Consolas, Monaco, monospace;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.2s;
}
.bgr-num.is-current {
  background: var(--primary);
  animation: bgr-num-pulse 1.6s ease-in-out infinite;
  box-shadow: 0 0 0 4px rgba(91, 141, 239, 0.2);
}
.bgr-num.is-done {
  background: #4caf50;
}
.bgr-num.is-done::before {
  content: "✓";
  font-size: 0.95rem;
}
.bgr-num.is-done .bgr-num__inner,
.bgr-num.is-done { color: #fff; font-size: 0; }
.bgr-num.is-done::before { font-size: 0.95rem; font-weight: 800; }
@keyframes bgr-num-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(91, 141, 239, 0.18); }
  50%      { box-shadow: 0 0 0 8px rgba(91, 141, 239, 0.08); }
}
/* 矢印:濃くハッキリ */
.bgr-arrow {
  color: var(--text-muted);
  font-size: 1.05rem;
  font-weight: 700;
  opacity: 1;
}
.bgr-arrow.is-active { color: var(--primary); }
.bgr-num[hidden],
.bgr-arrow[hidden] { display: none; }
.tool-btn--step {
  font-weight: 700;
}
/* ステップ内のタブ群は番号の近くに寄せる */
.toolbar-group--steps .ctx-tabs--bgremove { margin-left: 0; }

/* bgremove 用:2行表示のセグメント(ラベル + サイズ) */
.ctx-tabs--bgremove .ctx-tab {
  padding: 5px 12px;
  line-height: 1.25;
  text-align: center;
}
.ctx-tabs--bgremove .ctx-tab small {
  display: block;
  font-size: 0.66rem;
  opacity: 0.78;
  font-weight: 500;
}

/* スポイト UI */
.ctx-swatch {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-input);
  border-radius: var(--radius-sm);
  background:
    linear-gradient(45deg, #ccc 25%, transparent 25%),
    linear-gradient(-45deg, #ccc 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ccc 75%),
    linear-gradient(-45deg, transparent 75%, #ccc 75%);
  background-size: 8px 8px;
  background-position: 0 0, 0 4px, 4px -4px, -4px 0;
  background-color: transparent;
  vertical-align: middle;
}
.ctx-mono {
  font-family: 'SF Mono', Consolas, Monaco, monospace;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  min-width: 78px;
  text-transform: uppercase;
}
.ctx-history {
  display: inline-flex;
  gap: 4px;
}
.ctx-history__item {
  width: 22px;
  height: 22px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 0.1s, border-color 0.15s;
}
.ctx-history__item:hover {
  transform: scale(1.1);
  border-color: var(--primary);
}
.ctx-history__empty {
  font-size: 0.72rem;
  color: var(--text-dim);
}

/* ============================================================
   Eyedropper Loupe
   ============================================================ */
.eye-loupe {
  position: fixed;
  z-index: 800;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(40, 50, 65, 0.35), 0 0 0 3px var(--surface), 0 0 0 4px var(--primary);
  overflow: hidden;
  background: var(--surface);
}
.eye-loupe[hidden] { display: none; }
.eye-loupe__canvas {
  display: block;
  width: 140px;
  height: 140px;
  image-rendering: pixelated;
}
.eye-loupe__crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  margin-top: -5px;
  border: 1px solid #000;
  outline: 1px solid #fff;
  box-shadow: inset 0 0 0 1px transparent;
}

/* ============================================================
   Crop / Mosaic Selection (overlay canvas に描くので CSS なし)
   ============================================================ */

/* ============================================================
   Number Spinner(長押しで連続変化)
   ============================================================ */
.ctx-spinner {
  display: inline-flex;
  align-items: stretch;
  height: 28px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}
.ctx-spinner__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  background: var(--btn-bg);
  color: var(--text-muted);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  user-select: none;
  transition: background 0.12s, color 0.12s;
  border: none;
}
.ctx-spinner__btn:hover { background: var(--btn-hover); color: var(--text); }
.ctx-spinner__btn:active,
.ctx-spinner__btn.is-pressing {
  background: var(--primary);
  color: #fff;
}
.ctx-spinner .ctx-num {
  border: none;
  border-radius: 0;
  width: 64px;
  padding: 0 8px;
  /* ブラウザ標準の number ステッパー矢印は消す(自前 +/- で十分) */
  -moz-appearance: textfield;
  appearance: textfield;
}
.ctx-spinner .ctx-num::-webkit-outer-spin-button,
.ctx-spinner .ctx-num::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.ctx-spinner .ctx-num:focus {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--primary);
}

/* ============================================================
   HEX 色コード入力(ペースト対応)
   ============================================================ */
.ctx-hex {
  width: 88px;
  height: 28px;
  padding: 0 8px;
  background: var(--surface);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'SF Mono', Consolas, Monaco, monospace;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
}
.ctx-hex:focus {
  outline: none;
  border-color: var(--primary);
}
.ctx-hex.is-invalid {
  border-color: #d9534f;
  background: #fff5f5;
}

/* ============================================================
   Header Divider
   ============================================================ */
.header-divider {
  display: inline-block;
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
}

/* ============================================================
   Range / Color picker / Shape buttons (Phase 3)
   ============================================================ */
.ctx-range {
  width: 110px;
  accent-color: var(--primary);
}
.ctx-mono--sm {
  min-width: 28px;
  font-size: 0.78rem;
}

/* カラーチップ + 隠し input type=color */
.ctx-color-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}
.ctx-color-chip {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-input);
  border-radius: var(--radius-sm);
  background: #000;
  vertical-align: middle;
  transition: transform 0.1s, border-color 0.15s;
}
.ctx-color-label:hover .ctx-color-chip {
  border-color: var(--primary);
  transform: scale(1.05);
}
.ctx-color-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* 進捗バー(背景透過のロード/推論用) */
.ctx-progress-bar {
  display: inline-block;
  vertical-align: middle;
  width: 140px;
  height: 8px;
  background: var(--btn-bg);
  border: 1px solid var(--border-input);
  border-radius: 999px;
  overflow: hidden;
}
.ctx-progress-bar--large { width: 100%; height: 14px; }
.ctx-progress-bar__fill {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--primary-hover));
  transition: width 0.18s ease;
}

/* 背景透過モーダル */
.modal--bgremove .modal-list {
  margin: 8px 0 16px 20px;
  padding: 0;
  font-size: 0.86rem;
  color: var(--text);
  line-height: 1.85;
}
.modal--bgremove .modal-list li {
  margin: 4px 0;
}
.modal--bgremove .modal-list strong { color: var(--primary); }
.modal-progress-wrap {
  margin: 14px 0 0;
  padding: 12px;
  background: var(--btn-bg);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-md);
}
.modal-progress-label {
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: 'SF Mono', Consolas, Monaco, monospace;
  text-align: center;
}

/* ===== 案内 ON/OFF トグル(ヘッダー) ===== */
.tip-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.tip-toggle.is-off {
  background: #f5f5f5;
  color: var(--text-muted);
  border-color: #e0e0e0;
}
.tip-toggle.is-off .tip-toggle__icon { filter: grayscale(1) opacity(0.5); }
.tip-toggle__icon { font-size: 1rem; }
.tip-toggle__label { font-size: 0.8rem; font-weight: 600; }

/* ===== 選択枠の下に出す floating アクション(モザイク・消しゴム等) ===== */
.floating-actions {
  position: absolute;
  display: inline-flex;
  gap: 6px;
  padding: 5px 6px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--border-input);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
  z-index: 30;
  white-space: nowrap;
  backdrop-filter: blur(4px);
}
.floating-actions[hidden] { display: none; }
.floating-actions .tool-btn--sm { font-size: 0.78rem; padding: 4px 10px; }

/* ===== 推論中モーダル(中央表示・経過時間カウント) ===== */
.modal--running {
  max-width: 460px;
  text-align: center;
}
.modal-header--center { justify-content: center; }
.modal-body--center { text-align: center; }
.running-spinner {
  width: 56px;
  height: 56px;
  margin: 8px auto 18px;
  border: 5px solid rgba(91, 141, 239, 0.18);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: running-spin 0.9s linear infinite;
}
@keyframes running-spin { to { transform: rotate(360deg); } }
.running-elapsed {
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--primary);
  font-family: 'SF Mono', Consolas, Monaco, monospace;
  letter-spacing: 0.05em;
  margin-bottom: 14px;
}
.running-note {
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.7;
  margin: 0 0 8px;
}
.running-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0 0 16px;
}
.running-cancel-btn {
  display: inline-block;
  padding: 8px 22px;
  background: #fff;
  color: var(--text-muted);
  border: 1.5px solid var(--border-input);
  border-radius: 8px;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.running-cancel-btn:hover {
  background: #fff0f0;
  color: #c0392b;
  border-color: #e74c3c;
}

/* ===== 汎用ツールチップ(JS 完全制御 / サイドバー・bgremove タブ共通) ===== */
.sf-tooltip {
  position: absolute;
  background: #1e2a38;
  color: #fff;
  font-size: 0.8rem;
  line-height: 1.6;
  padding: 12px 14px 12px;
  border-radius: 10px;
  width: 280px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
  z-index: 80;
  opacity: 0;
  transition: opacity 0.14s ease;
  pointer-events: none;
}
.sf-tooltip.is-show {
  opacity: 1;
  pointer-events: auto;
}
.sf-tooltip.is-measuring { opacity: 0; pointer-events: none; }
.sf-tooltip[hidden] { display: none; }
.sf-tooltip__arrow {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #1e2a38;
}
.sf-tooltip__title {
  margin: 0 0 6px;
  font-size: 0.88rem;
  font-weight: 700;
}
.sf-tooltip__body {
  margin: 0 0 12px;
  white-space: pre-line;
  color: rgba(255, 255, 255, 0.92);
  /* 連続する括弧やカタカナの途中で改行されないように */
  word-break: keep-all;
  overflow-wrap: break-word;
  line-break: strict;
}
/* 「今後表示しない」ボタン — はっきりした白枠で目立たせる */
.sf-tooltip__dismiss {
  display: block;
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  padding: 7px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
  letter-spacing: 0.02em;
}
.sf-tooltip__dismiss:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: #fff;
}
.sf-tooltip__dismiss:active { transform: translateY(1px); }

/* 圧縮ツール:品質スライダー(PNG 時は無効化) */
.ctx-quality-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: opacity 0.15s;
}
.ctx-quality-wrap.is-disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* 圧縮ツール:削減率表示 */
.ctx-compress-savings {
  font-weight: 600;
}
.ctx-compress-savings.is-good { color: var(--success); }
.ctx-compress-savings.is-bad { color: #d9534f; }

/* 図形ツール:線幅ビジュアルプレビュー */
.ctx-line-preview {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 28px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}
.ctx-line-preview__bar {
  display: block;
  width: 80%;
  background: currentColor;
  border-radius: 999px;
  min-height: 1px;
  transition: height 0.1s ease, background 0.1s ease;
}

/* Shape タイプ切替ボタン */
.ctx-shape-types {
  display: inline-flex;
  background: var(--btn-bg);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}
.ctx-shape-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 26px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.05rem;
  border-radius: 3px;
  transition: background 0.15s, color 0.15s;
}
.ctx-shape-btn:hover { color: var(--text); }
.ctx-shape-btn.is-active {
  background: var(--primary);
  color: #fff;
}

/* ============================================================
   Text Overlay(text ツールのレイヤー型テキスト)
   - .is-editing  入力中(枠線 + 半透明背景 + キャレット)
   - .is-placed   配置済み(枠なし、ホバーで枠表示・移動カーソル)
   - .is-dragging 移動中(青枠)
   ============================================================ */
.text-overlay {
  position: absolute;
  min-width: 12px;
  min-height: 1em;
  padding: 2px 6px;
  white-space: nowrap;
  line-height: 1.2;
  z-index: 10;
  user-select: text;
  background: transparent;
}
.text-overlay.is-editing {
  outline: 2px dashed var(--primary);
  outline-offset: 1px;
  background: rgba(255, 255, 255, 0.6);
  caret-color: var(--primary);
  cursor: text;
}
.text-overlay.is-placed {
  cursor: move;
  outline: 1px dashed transparent;
}
.text-overlay.is-placed:hover {
  outline: 1px dashed var(--primary);
  outline-offset: 1px;
  background: rgba(91, 141, 239, 0.06);
}
.text-overlay.is-dragging {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  background: rgba(91, 141, 239, 0.12);
  cursor: grabbing;
}

/* ===== 画像挿入オーバーレイ(insert ツール)===== */
.image-overlay {
  position: absolute;
  z-index: 10;
  cursor: move;
  user-select: none;
  box-sizing: border-box;
  outline: 1px dashed transparent;
}
.image-overlay img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}
.image-overlay:hover {
  outline: 1px dashed var(--primary);
}
.image-overlay.is-selected {
  outline: 2px solid var(--primary);
  outline-offset: 0;
}
.image-overlay__resize {
  position: absolute;
  right: -8px;
  bottom: -8px;
  width: 16px;
  height: 16px;
  background: #fff;
  border: 2px solid #2c3e50;
  border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  cursor: nwse-resize;
  display: none;
}
.image-overlay__del {
  position: absolute;
  right: -11px;
  top: -11px;
  width: 22px;
  height: 22px;
  background: #ef4444;
  color: #fff;
  border-radius: 50%;
  font-size: 15px;
  line-height: 20px;
  text-align: center;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  display: none;
}
.image-overlay.is-selected .image-overlay__resize,
.image-overlay.is-selected .image-overlay__del {
  display: block;
}

/* 太字チェックボックス用の B 装飾 */
.ctx-check--bold b {
  font-family: var(--font-en);
  margin-right: 2px;
}

/* ============================================================
   Tablet / 中間サイズ:ヘッダーボタンが増えて狭くなった時の崩れ防止
   ============================================================ */
@media (max-width: 1180px) {
  .brand-sub { display: none; }
}
@media (max-width: 960px) {
  /* さらに狭ければボタンのラベルも縮める(アイコンだけ残す)*/
  .header-actions .tool-btn__label { display: none; }
  .tip-toggle__label { display: none; }
  .header-actions .tool-btn { padding: 6px 10px; }
}

/* ============================================================
   Mobile Responsive
   ============================================================ */
@media (max-width: 768px) {
  .mobile-notice { display: block; }

  .brand-sub { display: none; }
  .brand-title { font-size: 1rem; }
  .back-link { font-size: 0.78rem; padding: 4px 10px; }

  .header-actions .tool-btn__label { display: none; }

  #screen-edit {
    flex-direction: column;
    height: auto;
    background: var(--bg);
  }

  .sidebar {
    width: 100%;
    height: auto;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 6px 8px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    /* モバイルでも sticky は維持(横並びサイドバーが上に固定される) */
    position: sticky;
    top: var(--header-height);
    align-self: stretch;
    max-height: none;
  }
  .sidebar-btn {
    flex-shrink: 0;
    min-width: 62px;
    padding: 6px 8px;
  }
  .sidebar__divider {
    width: 1px;
    height: auto;
    margin: 4px 6px;
  }

  .toolbar {
    /* モバイルではサイドバー(横並び)の下に重ねず、normal scroll に戻す
       (両方 sticky だと重なり合うため) */
    position: static;
  }
  .toolbar-main { padding: 5px 10px; gap: 8px; }
  .toolbar-info { padding: 3px 10px; gap: 10px; }
  .toolbar-group--zoom .tool-btn--sm { display: none; }
  #zoom-slider { width: 70px; }

  .canvas-area { padding: 12px; }

  .drop-zone { padding: 42px 24px; }
  .drop-zone__icon { font-size: 2.8rem; }

  .site-footer__links { gap: 10px 14px; font-size: 0.78rem; }
}

@media (max-width: 480px) {
  .brand-title { font-size: 0.9rem; }
  /* モバイルではトーストを画面幅いっぱい・サイドバー(横並びツールバー)の下に
     transform の -50% は無効化(でないと画面左外へ飛ぶ)*/
  .toast {
    left: 10px;
    right: 10px;
    max-width: none;
    top: 140px;
    transform: translateY(-8px);
  }
  .toast.is-show {
    transform: translateY(0);
  }
}
