/* =========================================================
   Global
========================================================= */

html {
  box-sizing: border-box;
  width: 100%;
  /* 埋め込み時、iframe は中身より少し高い（高さ通知に余裕を持たせている）。
     visible-region.js は <html> の箱で「見えている範囲」を測るので、iframe の高さまで伸ばして揃える */
  min-height: 100%;
}
*, *::before, *::after {
  box-sizing: inherit;
}
body {
  margin: 0;
  min-height: 100%;
  width: 100%;
}

/* hidden 属性は UA スタイルシートの [hidden]{display:none} で効くが、
   .btn { display: inline-flex } のようにクラス側で display を指定すると
   詳細度で負けて表示されてしまう。属性が付いている間は必ず隠す */
[hidden] {
  display: none !important;
}

/* キャンバスの上限（900px）に揃える。指定が無いと、埋め込み先の広い列で
   ライブラリと検索欄だけが横いっぱいに伸びる */
.app-main {
  max-width: 900px;
  margin: 0 auto;
}

/* 埋め込み時は記事側に余白があるため、アプリ側の左右余白は要らない。
   狭い端末ではこの 3 層（記事・app-main・step-panel）が重なって
   キャンバスが画面幅の 2 割以上を失っていた */
.is-embedded .app-main,
.is-embedded .step-panel {
  padding-left: 0;
  padding-right: 0;
}

/* 左右は記事に任せるが、上下は本文と密着しないよう空ける */
.is-embedded .app-main {
  padding-top: 20px;
  padding-bottom: 20px;
}

/* 記事側に見出しがあるので、アプリ内の見出しは重複になる */
.is-embedded .hero-section {
  display: none;
}

/* 目には見せないが読み上げには残す */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* =========================================================
   iOS 版の案内
========================================================= */

.ios-promo {
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  margin: 0 0 24px;
  padding: 14px 44px 14px 16px;
  border: 1px solid #cfe2ff;
  border-radius: 12px;
  background: #f0f6ff;
}

.ios-promo-dismissed .ios-promo {
  display: none;
}

.ios-promo-body {
  flex: 1 1 auto;
  min-width: 0;
}

.ios-promo-title {
  margin: 0 0 4px;
  font-weight: 700;
  font-size: 1rem;
  color: #1a3d6d;
}

.ios-promo-title .fa-apple {
  margin-right: 4px;
}

.ios-promo-note {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.5;
  color: #3b4a5c;
}

.ios-promo-link {
  flex: 0 0 auto;
  margin-bottom: 0;
  white-space: nowrap;
}

.ios-promo-close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #6b7a8c;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.ios-promo-close:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #1a3d6d;
}

.ios-promo-close:focus-visible {
  outline: 3px solid #0056b3;
  outline-offset: 2px;
}

@media (max-width: 520px) {
  .ios-promo {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 40px 12px 14px;
  }

  .ios-promo-link {
    display: flex;
  }
}

/* =========================================================
   Wizard Navigation
========================================================= */

.wizard-nav {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-start;
  align-items: center;
  list-style: none;
  padding: 0 4px;
  margin: 0 0 40px;
  gap: 0;
}

.wizard-nav .wizard-step {
  /* 固定幅（旧: min-width 120px）だと 4 ステップで 480px を超え、狭い画面で横スクロールになる。
     幅を等分して必ず収める。min-width: 0 がないと flex アイテムは中身より縮まない */
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;

  padding-bottom: 6px;

  color: #888888;
  font-size: 0.95rem;
}

/* ボタンだが、見た目は従来のステッパーのまま */
.wizard-step-btn {
  display: flex;
  flex-direction: column;
  align-items: center;

  width: 100%;
  padding: 0;

  border: none;
  background: transparent;
  color: inherit;
  font: inherit;

  cursor: default;
}

/* 完了したステップだけ戻れる。押せるものだけ押せるように見せる */
.wizard-step-btn:not(:disabled) {
  cursor: pointer;
}

.wizard-step-btn:not(:disabled):hover .wizard-step-mark {
  background-color: #0056b3;
}

.wizard-step-btn:focus-visible {
  outline: 3px solid #0056b3;
  outline-offset: 3px;
  border-radius: 8px;
}

.wizard-nav .wizard-step .wizard-step-mark {
  display: inline-flex;
  justify-content: center;
  align-items: center;

  width: 36px;
  height: 36px;

  margin-bottom: 6px;

  border-radius: 50%;

  background-color: #888888;
  color: #ffffff;

  font-weight: bold;
  z-index: 1;
}

/* ラベル */
.wizard-nav .wizard-step .wizard-step-label {
  display: block;
  text-align: center;
  line-height: 1.2;
  white-space: normal;
}

/* 線 */
.wizard-nav .wizard-step::before,
.wizard-nav .wizard-step::after {
  content: "";
  position: absolute;
  top: 18px;

  width: 50%;
  height: 2px;

  background-color: #cccccc;
  z-index: 0;
}

.wizard-nav .wizard-step::before {
  left: 0;
}

.wizard-nav .wizard-step::after {
  right: 0;
}

.wizard-nav .wizard-step:first-child::before {
  display: none;
}

.wizard-nav .wizard-step:last-child::after {
  display: none;
}

/* 現在・完了 */
.wizard-nav .wizard-step.current {
  color: #007bff;
}

.wizard-nav .wizard-step.completed .wizard-step-mark,
.wizard-nav .wizard-step.current .wizard-step-mark {
  background-color: #007bff;
}

/* 状態を色だけで示さない（色覚特性で区別できない場合への対応）。
   完了にはチェックが入り、現在地は輪と太字でも示す */
.wizard-nav .wizard-step.current .wizard-step-mark {
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.3);
}

.wizard-nav .wizard-step.current .wizard-step-label {
  font-weight: bold;
}

/* パネルにフォーカスを移すが、枠線までは出さない */
.step-panel:focus {
  outline: none;
}

.wizard-nav .wizard-step.completed::before,
.wizard-nav .wizard-step.completed::after,
.wizard-nav .wizard-step.current::before {
  background-color: #007bff;
}

@media (max-width: 520px) {
  .wizard-nav {
    margin-bottom: 28px;
  }

  .wizard-nav .wizard-step {
    font-size: 0.72rem;
  }

  .wizard-nav .wizard-step .wizard-step-mark {
    width: 28px;
    height: 28px;
  }

  /* 丸が小さくなるぶん、ステップをつなぐ線の位置も合わせる */
  .wizard-nav .wizard-step::before,
  .wizard-nav .wizard-step::after {
    top: 14px;
  }
}

/* アニメーション */
.wizard-nav .wizard-step.current .wizard-step-mark {
  animation: stepPop 0.5s ease;
}

@keyframes stepPop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.3); }
  100% { transform: scale(1); }
}


/* =========================================================
   Load Error
========================================================= */

/* 描画ライブラリが読めなかったときの案内。他の UI は動かないので目立たせる */
.load-error {
  margin: 0 0 24px;
  padding: 14px 16px;

  border: 1px solid #f1b0b7;
  border-radius: 8px;

  background: #fdecee;
  color: #842029;
}


/* =========================================================
   Drop Area
========================================================= */

.drop-area {
  position: relative;

  border: 2px dashed #ccc;
  border-radius: 4px;

  padding: 20px;

  text-align: center;

  color: #555;
  background-color: #fafafa;

  transition: border-color 0.2s, background-color 0.2s;

  cursor: pointer;
  user-select: none;
}

.drop-area.dragover {
  border-color: #007bff;
  background-color: #e6f5ff;
}

.drop-area i {
  display: block;
  font-size: 1.5rem;
  margin-bottom: 8px;
}


/* =========================================================
   Buttons
========================================================= */

.btn {
  min-width: 100px;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;

  padding: 8px 14px;

  font-size: 0.95rem;

  border: none;
  border-radius: 4px;

  background-color: #007bff;
  color: #fff;

  cursor: pointer;

  text-decoration: none;

  transition: background-color 0.2s;

  margin-bottom: 8px;

  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  background-color: #0056b3;
}

.btn:focus-visible,
.wheel-card:focus-visible,
.drop-area:focus-visible {
  outline: 3px solid #0056b3;
  outline-offset: 3px;
}

.btn:disabled,
.btn[disabled] {
  background-color: #ccc;
  cursor: not-allowed;
}

.btn-secondary {
  background-color: #6c757d;
}

.btn-secondary:hover {
  background-color: #565e64;
}

.btn-danger {
  background-color: #dc3545;
}

.btn-danger:hover {
  background-color: #a71d2a;
}

.btn-link {
  background: transparent;
  color: #007bff;
  border: none;
  padding: 10px 0;
}

.wizard-buttons {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  justify-content: flex-start;
}

/* 編集ツール。主アクションと視覚的に分ける */
.wheel-tools {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.wheel-tools .btn {
  flex: 1 1 0;
  min-width: 0;
}

/* 主アクションは幅いっぱいで、他より明確に大きくする */
.btn-block {
  display: flex;
  width: 100%;
  margin-top: 16px;
  padding: 14px 18px;
  font-size: 1.05rem;
}

.wizard-buttons .btn {
  padding: 10px 20px;
}


/* =========================================================
   Affiliate Search
========================================================= */

.affiliate-search {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #e6e6e6;
}

.affiliate-search h3 {
  margin: 0 0 12px;
  font-size: 1.1rem;
}

.search-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
}

.input-text {
  flex: 1 1 42px;
  min-width: 0;
  width: 100%;
  min-height: 42px;

  padding: 10px 12px;

  border: 1px solid #ccc;
  border-radius: 6px;

  /* iOS Safari は 16px 未満の入力欄にフォーカスするとページごとズームする。
     iframe 内で起きると親ページ全体が拡大されてしまうため 16px を下回らせない */
  font-size: 1rem;
}

.search-row .btn {
  /* allow button to size to its content instead of forcing 120px */
  flex: 0 1 auto;
  min-width: 0;
  height: 42px;
  line-height: 42px;
  align-self: flex-start;
}

.affiliate-search {
  width: 100%;
  max-width: 100%;
}

@media (max-width: 520px) {
  .search-row {
    flex-direction: column;
    align-items: stretch;
  }
  .search-row .btn {
    width: 100%;
  }
}

.search-note {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: #666;
}


/* =========================================================
   Wheel Library
========================================================= */

.wheel-library-section {
  margin-bottom: 28px;
}

/* 横スクロールできることを示す。
   スクロールバーを消しているため、これが唯一の手がかりになる */
.wheel-library-scroll {
  position: relative;
}

.wheel-library-scroll::before,
.wheel-library-scroll::after {
  content: "";

  position: absolute;
  top: 0;
  bottom: 12px;
  width: 48px;
  z-index: 1;

  opacity: 0;
  transition: opacity 0.2s;

  pointer-events: none;
}

.wheel-library-scroll::before {
  left: 0;
  background: linear-gradient(to left, rgba(255, 255, 255, 0), #fff);
}

.wheel-library-scroll::after {
  right: 0;
  background: linear-gradient(to right, rgba(255, 255, 255, 0), #fff);
}

/* 実際にその方向へまだ送れるときだけ出す */
.wheel-library-scroll.can-scroll-left::before,
.wheel-library-scroll.can-scroll-right::after {
  opacity: 1;
}

.library-header p {
  color: #666;
  font-size: 0.92rem;
  margin-top: 0;
}

/* カードをタップすると何が起きるかの説明 */
.library-hint {
  margin: 0 0 8px;
  color: #666;
  font-size: 0.92rem;
}

.wheel-library {
  display: flex;
  gap: 12px;

  overflow-x: auto;

  padding: 4px 4px 12px;

  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.wheel-library::-webkit-scrollbar {
  display: none;
}

.wheel-card {
  position: relative;

  flex: 0 0 140px;

  overflow: hidden;
  border-radius: 18px;
  background: #fff;

  box-shadow: 0 4px 12px rgba(0,0,0,0.08);

  transition: .15s;

  cursor: pointer;

  -webkit-tap-highlight-color: transparent;
}

.wheel-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.10);
}

.wheel-card:active {
  transform: scale(0.98);
}

.wheel-card img {
  width: 100%;
  aspect-ratio: 1 / 1;

  object-fit: cover;

  /* background: #f5f5f5; */
}

.wheel-card-name {
  padding: 10px;

  font-size: 13px;
  font-weight: 600;

  text-align: center;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 名前を付けていないホイール。ファイル名を並べても手がかりにならない */
.wheel-card-name.is-unnamed {
  color: #999;
  font-weight: 400;
}

.wheel-card-actions {
  position: absolute;

  top: 8px;
  right: 8px;

  display: flex;
  gap: 6px;

  z-index: 20;
}

.wheel-delete-btn,
.wheel-edit-btn {
  width: 34px;
  height: 34px;

  border: none;
  border-radius: 999px;

  background: rgba(0,0,0,0.72);
  color: #fff;

  font-size: 15px;

  display: flex;
  align-items: center;
  justify-content: center;

  cursor: pointer;

  backdrop-filter: blur(6px);
}

.wheel-delete-btn:hover,
.wheel-edit-btn:hover {
  background: #000;
}


/* =========================================================
   Toast
========================================================= */

.toast {
  position: fixed;

  left: 50%;
  bottom: 24px;

  transform: translateX(-50%);

  background: #111;
  color: #fff;

  padding: 12px 18px;

  border-radius: 999px;

  font-size: 14px;

  opacity: 0;

  pointer-events: none;

  transition: .25s;

  z-index: 9999;

  display: flex;
  align-items: center;
  gap: 12px;

  /* left の値によって使える幅が変わり、短い文言でも縦に折り返していた。
     内容の幅で決めてから、画面幅で頭打ちにする */
  width: max-content;
  max-width: calc(100% - 32px);
}

.toast.show {
  opacity: 1;
}

/* 埋め込み時は iframe の下端＝読者の画面外になりがちなので、
   操作したボタンのそばに出す。left / top は JS が入れる */
.toast.is-anchored {
  position: absolute;
  bottom: auto;
}

.naming-dialog {
  position: fixed;
  inset: 0;
  z-index: 10001;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 16px;

  background: rgba(0, 0, 0, 0.45);
}

.naming-panel {
  width: 100%;
  max-width: 520px;
  max-height: 100%;

  display: flex;
  flex-direction: column;
  gap: 12px;

  padding: 20px;

  border-radius: 16px;
  background: #fff;
}

/* 読者の画面に見えている範囲の中央に出す。iframe は中身いっぱいに伸びるので、
   この文書の中央（＝iframe の中央）は読者の視界とずれる。left / top は naming.js が入れる */
.naming-dialog.is-positioned .naming-panel {
  position: absolute;
  max-width: min(520px, calc(100% - 16px));
  max-height: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.naming-panel h3 {
  margin: 0;
}

.naming-note {
  margin: 0;
  color: #666;
  font-size: 0.9rem;
}

.naming-list {
  display: flex;
  flex-direction: column;
  gap: 10px;

  overflow-y: auto;
}

.naming-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.naming-thumb {
  flex: 0 0 48px;

  width: 48px;
  height: 48px;

  border-radius: 50%;
  object-fit: cover;

  background: #f2f2f2;
}

.naming-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

/* =========================================================
   Save Result
========================================================= */

/* 保存ボタンの直下に開く。埋め込み時、画面中央のモーダルにすると
   iframe が読者の画面より高いぶん下半分が見切れるため、その場に差し込む。
   高さも詰めて、押した直後の視線の先に収まるようにする */
/* 完了パネルは名前変更ダイアログと同じく、背景を暗くして画面に被せるモーダル。
   以前は保存ボタンの位置にインラインで出していたが、画面外に出て気づかれないことがあった */
.save-result {
  position: fixed;
  inset: 0;
  z-index: 10001;

  display: flex;
  align-items: flex-start;
  justify-content: center;

  padding: 16px;

  background: rgba(0, 0, 0, 0.45);
}

.save-panel {
  position: relative;

  width: 100%;
  max-width: 520px;

  padding: 16px 16px 12px;

  border: 2px solid #007bff;
  border-radius: 14px;
  background: #f5faff;
}

/* 読者の画面に見えている範囲の上部に出す。left / top は save-dialog.js が入れる */
.save-result.is-positioned .save-panel {
  position: absolute;
  max-width: min(520px, calc(100% - 16px));
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.save-panel h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
  /* 閉じるボタンに文字がかからないようにする */
  padding-right: 36px;
}

.save-panel-note {
  margin: 0 0 12px;
  color: #555;
  font-size: 0.85rem;
}

.save-panel-close {
  position: absolute;
  top: 10px;
  right: 10px;

  width: 32px;
  height: 32px;
  padding: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  border: none;
  border-radius: 50%;

  background: rgba(0, 0, 0, 0.06);
  color: #444;

  font-size: 0.9rem;
  cursor: pointer;
}

.save-panel-close:hover {
  background: rgba(0, 0, 0, 0.12);
}

.save-panel-wheel {
  display: flex;
  align-items: center;
  gap: 10px;

  margin-bottom: 12px;
}

.save-panel-thumb {
  flex: 0 0 44px;

  width: 44px;
  height: 44px;

  border-radius: 50%;
  object-fit: cover;

  background: #fff;
}

.save-panel-wheel-body {
  flex: 1 1 auto;
  min-width: 0;
}

.save-panel-name {
  font-weight: 600;
  word-break: break-word;
}

.save-panel-search-label {
  margin: 0 0 6px;
  font-size: 0.85rem;
  color: #444;
}

.save-panel-buttons {
  display: flex;
  gap: 8px;
}

.save-panel-buttons .btn {
  flex: 1 1 0;
  min-width: 0;
  margin-bottom: 0;
}

/* 名前が入るまでは検索しても何も出てこないので、押せないことを見せる */
.save-panel-buttons .btn:disabled {
  background-color: #ccc;
  cursor: not-allowed;
}

/* 埋め込み時の枠幅（360px 前後）でも横に 2 つ入る。
   縦に積むとパネルが高くなり、下端が読者の画面から出やすくなる */
@media (max-width: 320px) {
  .save-panel-buttons {
    flex-direction: column;
  }
}


.busy {
  position: fixed;
  inset: 0;
  z-index: 10000;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;

  background: rgba(255, 255, 255, 0.82);

  color: #333;
  font-size: 0.95rem;
}

.busy-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

/* 読者の画面に見えている範囲の中央に出す（理由は .naming-dialog.is-positioned と同じ）。
   left / top は busy.js が入れる */
.busy.is-positioned .busy-box {
  position: absolute;

  padding: 14px 20px;

  border-radius: 12px;
  background: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.busy-spinner {
  width: 38px;
  height: 38px;

  border: 3px solid #d5d5d5;
  border-top-color: #007bff;
  border-radius: 50%;

  animation: busySpin 0.7s linear infinite;
}

@keyframes busySpin {
  to { transform: rotate(360deg); }
}

/* 動きを減らす設定の利用者には回転させない */
@media (prefers-reduced-motion: reduce) {
  .busy-spinner {
    animation: none;
    border-top-color: #007bff;
  }
}

/* 親が pointer-events: none でも、子で有効に戻せば押せる */
.toast-action {
  pointer-events: auto;

  padding: 4px 10px;
  border: 1px solid #ffffff;
  border-radius: 999px;

  background: transparent;
  color: #ffffff;

  font-size: 13px;
  font-weight: bold;

  cursor: pointer;
}

.toast-action:hover {
  background: #ffffff;
  color: #111111;
}

.clip-progress {
  margin: 0 0 8px;

  color: #007bff;
  font-size: 0.9rem;
  font-weight: bold;
  text-align: center;
}

/* =========================================================
   Canvas
========================================================= */

.canvas-container,
.canvas-wrapper {
  width: 100%;
  max-width: 100%;

  overflow: auto;

  -webkit-overflow-scrolling: touch;
}

.canvas-container canvas,
.canvas-wrapper canvas,
canvas {
  display: block;

  /* max-width: 100% / height: auto は付けない。
     fabric は canvas の width/height 属性と style を自分で揃えており、
     CSS で表示サイズだけ縮めると内部座標とずれる。
     結果、ドラッグの軌跡が残り、クリック位置も合わなくなる。
     万一はみ出す場合は .canvas-container の overflow がスクロールバーで見せる
     （黙って壊れるより、見える形で失敗させる） */

  /* touch-action はここでは指定しない。
     fabric がインラインで書き込むため CSS では上書きできず、canvas.js が JS で制御する */
}


/* =========================================================
   Mobile
========================================================= */

@media (max-width: 768px) {

  body {
    overflow-x: hidden;
  }

  .app-main {
    padding: 12px;
  }

  .step-panel {
    padding: 16px;
    margin-bottom: 20px;
    border-radius: 16px;
  }

  .wizard-nav .wizard-step {
    font-size: 0.8rem;
  }

  .wizard-nav .wizard-step .wizard-step-mark {
    width: 32px;
    height: 32px;
  }

  /* 丸のサイズを変えたら、線の位置も丸の中心に合わせる */
  .wizard-nav .wizard-step::before,
  .wizard-nav .wizard-step::after {
    top: 16px;
  }

  .wizard-buttons {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .wizard-buttons .btn {
    width: 100%;
    min-width: 0;

    padding: 14px 10px;

    font-size: 14px;
  }

  #saveImage {
    grid-column: 1 / -1;
  }

  .wheel-card {
    flex: 0 0 120px;
  }

  .search-row {
    flex-direction: column;
    align-items: stretch;
  }

  .input-text {
    width: 100%;
  }

}

/* =========================================================
   Wheel Comparison（ホイールを比べる）
========================================================= */

/* 単独の保存とは別の作業なので、検索欄と同じく線で区切る */
.comparison-section {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #e6e6e6;
}

.comparison-section h3 {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

.comparison-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.92rem;
  font-weight: 600;
}

.comparison-add-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.comparison-add-row .btn {
  flex: 0 0 auto;
  min-width: 0;
  min-height: 44px;
}

.comparison-select {
  min-height: 44px;
  background-color: #fff;
}

.comparison-count {
  margin: 12px 0 4px;
  font-size: 0.92rem;
  font-weight: 600;
}

.comparison-empty {
  margin: 0 0 8px;
  color: #666;
  font-size: 0.92rem;
}

.comparison-list {
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.comparison-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #f0f0f0;
}

/* 長いホイール名でも操作ボタンを押し出さない */
.comparison-item-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.comparison-item-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 4px;
}

/* 指で押せる大きさ（44px）を確保する */
.comparison-icon-btn {
  width: 44px;
  height: 44px;
  border: 1px solid #d6d6d6;
  border-radius: 6px;
  background: #fff;
  color: #333;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.comparison-icon-btn:hover {
  background: #f2f2f2;
}

.comparison-icon-btn:focus-visible {
  outline: 3px solid #0056b3;
  outline-offset: 2px;
}

.comparison-icon-btn:disabled {
  color: #c4c4c4;
  cursor: not-allowed;
  background: #fafafa;
}

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

.comparison-crop-state {
  margin-bottom: 8px;
  color: #666;
  font-size: 0.9rem;
}

.comparison-preview {
  margin-top: 8px;
  border-radius: 6px;
  overflow: hidden;
  background: #141414;
}

.comparison-preview img {
  display: block;
  width: 100%;
  height: auto;
}

/* 枠の操作にタッチを使うので、ダイアログの中でページを動かさない */
.comparison-crop-stage {
  display: flex;
  justify-content: center;
  touch-action: none;
  background: #f2f2f2;
  border-radius: 6px;
  overflow: hidden;
}

.comparison-crop-actions {
  flex-wrap: wrap;
}

.comparison-crop-actions .btn-link {
  margin-right: auto;
}

@media (max-width: 520px) {
  .comparison-add-row {
    flex-direction: column;
    align-items: stretch;
  }
}

/* 動作中バージョンの控えめな表示（キャッシュで古い版を掴んでいないかの確認用） */
.app-version {
  margin-top: 12px;
  text-align: center;
  font-size: 11px;
  color: #c4c4c4;
  user-select: text;
}
