/* ================================================
   StreetArt Maker — page-specific styles
   Prefix: sa-
   Inherits: base.css, layout.css, tool.css
   ================================================ */

/* ── [hidden] 強制非表示 ────────────────────────────────────────────────────
   display: flex / grid など CSS が hidden 属性の display:none を上書きするのを防ぐ。
   "写真を変更" 後にエディタが残る問題の根本修正。                              ── */
.sa-editor[hidden],
.sa-progress-card[hidden],
.sa-spinner-card[hidden],
.sa-scale-hint[hidden],
.gz-card[hidden] {
  display: none !important;
}

/* ── Hero — TraceLine デザイン踏襲（自前 sa-hero-* クラス、gz-* 依存なし） ── */

.sa-hero-wrap {
  padding: 2rem 1.5rem 0.5rem; /* 左右余白を全体（gz-section）と同じ 1.5rem に揃え / 下余白でツール部との間隔を確保 */
}

.sa-hero-card {
  position: relative;
  max-width: 1100px;
  margin: 0 auto;
  border-radius: 28px;
  overflow: hidden;
  background: #111;
}

.sa-hero-card::before {
  content: "";
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(90deg, rgba(0,0,0,.28) 0%, rgba(0,0,0,.14) 38%, rgba(0,0,0,0) 62%);
}

.sa-hero-media {
  position: relative;
  display: block;
  width: 100%;
  height: clamp(380px, 46vh, 480px);
  overflow: hidden;
}

.sa-hero-media picture { display: contents; }

.sa-hero-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: 65% 30%;
  display: block;
}

.sa-hero-copy {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column;
  justify-content: center; align-items: flex-start;
  padding: 48px 55px; max-width: 620px;
}

.sa-hero-title {
  margin: 0 0 14px; color: #fff; font-weight: 800;
  letter-spacing: -0.02em; font-size: clamp(2.0rem, 3.6vw, 2.8rem);
  text-shadow: 0 2px 12px rgba(0,0,0,.3);
}

.sa-hero-lead {
  margin: 0 0 22px; color: rgba(255,255,255,.92);
  line-height: 1.55; font-size: 0.95rem; max-width: 52ch;
  font-weight: 600; letter-spacing: 0.5px;
  text-shadow: 0 1px 8px rgba(0,0,0,.3);
}

.sa-hero-cta {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 26px; border-radius: 999px; text-decoration: none;
  background: #2f6bff; color: #fff; font-weight: 700; font-size: 0.95rem;
  box-shadow: 0 6px 18px rgba(0,0,0,.20);
  transition: transform .18s ease, opacity .18s ease;
}
.sa-hero-cta:hover { opacity: .92; transform: translateY(-1px); }
.sa-hero-arrow { transition: transform .18s ease; }
.sa-hero-cta:hover .sa-hero-arrow { transform: translateX(4px); }

/* SP */
@media (max-width: 640px) {
  .sa-hero-wrap { padding: 0 0 25px; }
  .sa-hero-card { border-radius: 22px; margin: 0 1.25rem; }
  .sa-hero-card::before {
    background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0) 40%, rgba(0,0,0,.30) 70%, rgba(0,0,0,.50) 100%);
  }
  .sa-hero-media { height: auto; aspect-ratio: 4/5; }
  .sa-hero-img { object-position: 60% 20%; }
  .sa-hero-copy { justify-content: flex-end; align-items: stretch; padding: 28px 28px 32px; max-width: none; }
  .sa-hero-title { text-align: center; font-size: 1.9rem; margin-bottom: 10px; }
  .sa-hero-lead  { text-align: center; margin-bottom: 18px; }
  .sa-hero-cta   { width: 100%; justify-content: center; }
}

/* ── Before/After Samples ── */
.sa-samples-section {
  padding: 60px 24px 48px; /* horizontal padding prevents edge-to-edge on SP */
  background: #f8f9fb;
}

@media (max-width: 480px) {
  .sa-samples-section {
    padding-left: 14px;
    padding-right: 14px;
  }
}

.sa-samples-heading {
  font-size: clamp(18px, 2.5vw, 24px);
  font-weight: 700;
  text-align: center;
  margin-bottom: 32px;
  color: #111;
}

.sa-samples-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

@media (max-width: 680px) {
  .sa-samples-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

.sa-sample-card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  padding: 16px;
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
}

.sa-sample-pair {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.sa-sample-fig {
  flex: 1;
  min-width: 0;
  margin: 0;
}

.sa-sample-img {
  width: 100%;
  aspect-ratio: 4/3;
  border-radius: 8px;
  object-fit: cover;
  background: #e5e7eb;
  overflow: hidden;
}

/* Placeholder colors (replaced by real images later) */
.sa-sample-img--ph1-before { background: linear-gradient(135deg, #ddd 0%, #ccc 100%); }
.sa-sample-img--ph1-after  { background: linear-gradient(135deg, #555 0%, #222 80%), repeating-linear-gradient(45deg, transparent, transparent 4px, rgba(255,255,255,.03) 4px, rgba(255,255,255,.03) 8px); background-blend-mode: normal; background: #3a3a3a; }
.sa-sample-img--ph2-before { background: linear-gradient(135deg, #e8d5c0 0%, #d4b896 100%); }
.sa-sample-img--ph2-after  { background: #5c3a1e; }
.sa-sample-img--ph3-before { background: linear-gradient(135deg, #c5d8e8 0%, #a8c4d8 100%); }
.sa-sample-img--ph3-after  { background: #888; }

.sa-sample-arrow {
  font-size: 18px;
  color: #9ca3af;
  flex-shrink: 0;
  font-weight: 300;
}

.sa-sample-cap {
  display: block;
  font-size: 11px;
  color: #9ca3af;
  text-align: center;
  margin-top: 5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.sa-sample-desc {
  font-size: 13px;
  color: #555;
  text-align: center;
  margin: 0;
}

/* ── Upload card / Dropzone ── */
.sa-upload-card {
  width: 100%;
  margin-bottom: 1.5rem;
  /* Remove default gz-card padding so dropzone fills edge-to-edge */
  padding: 0 !important;
  overflow: hidden;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

/* Override gz-dropzone to give a dark canvas-like look */
.sa-dropzone.gz-dropzone {
  background: #111 !important;
  border: none !important;
  border-radius: 14px;
  min-height: 240px;
  color: rgba(255,255,255,0.55);
  cursor: pointer;
  transition: background 0.18s;
}

.sa-dropzone.gz-dropzone:hover,
.sa-dropzone.gz-dropzone.is-dragover {
  background: #1a1a1a !important;
  color: rgba(255,255,255,0.80);
}

/* New dark drop-content layout */
.sa-drop-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 40px 20px;
}

.sa-drop-icon {
  color: rgba(255,255,255,0.45);
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.sa-drop-main {
  font-size: 17px;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  margin: 0;
}

.sa-drop-sub {
  font-size: 13px;
  color: rgba(255,255,255,0.40);
  margin: 0;
}

.sa-upload-formats {
  font-size: 12px;
  color: #9ca3af;
  margin-top: 6px;
}

/* Model notice line */
/* Model notice: always hidden — "AI ready" text removed per user request */
.sa-model-notice {
  display: none !important;
}

.sa-model-notice-icon {
  flex-shrink: 0;
  margin-top: 1px;
}

.sa-model-notice--ready {
  color: #22c55e;
}

/* ── Progress card ── */
.sa-progress-card {
  max-width: 640px;
  margin: 0 auto 1.5rem;
  text-align: center;
}

.sa-progress-title {
  font-weight: 700;
  font-size: 15px;
  color: #111;
  margin-bottom: 14px;
}

.sa-progress-track {
  background: #e5e7eb;
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
  margin-bottom: 8px;
}

.sa-progress-bar {
  height: 100%;
  background: #1f6fff;
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* Indeterminate state: sliding pulse (used when @imgly doesn't report total size) */
.sa-progress-bar.is-indeterminate {
  width: 40% !important;
  transition: none;
  animation: sa-indeterminate 1.5s ease-in-out infinite;
}

@keyframes sa-indeterminate {
  0%   { transform: translateX(-150%); }
  100% { transform: translateX(350%); }
}

.sa-progress-mb {
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 12px;
  font-variant-numeric: tabular-nums;
}

.sa-progress-desc {
  font-size: 13px;
  color: #9ca3af;
  line-height: 1.6;
}

.sa-fallback-btn {
  display: inline-block;
  margin-top: 16px;
  font-size: 13px;
  color: #1f6fff;
  background: none;
  border: 1px solid #1f6fff;
  border-radius: 6px;
  padding: 6px 14px;
  cursor: pointer;
  transition: background 0.15s;
}

.sa-fallback-btn:hover {
  background: #f0f5ff;
}

/* ── Spinner card ── */
.sa-spinner-card {
  max-width: 640px;
  margin: 0 auto 1.5rem;
  text-align: center;
  padding: 40px;
}

.sa-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e5e7eb;
  border-top-color: #1f6fff;
  border-radius: 50%;
  animation: sa-spin 0.9s linear infinite;
  margin: 0 auto 16px;
}

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

.sa-spinner-text {
  font-size: 14px;
  color: #6b7280;
  font-weight: 500;
}

/* ── Export size selector ── */
.sa-export-size {
  display: flex;
  gap: 4px;
}

.sa-export-size-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 2px 5px;
  border: 1px solid #e5e7eb;
  border-radius: 7px;
  background: #fff;
  cursor: pointer;
  color: #6b7280;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  user-select: none;
}

.sa-export-size-btn input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.sa-export-size-btn.is-active {
  background: #f0f5ff;
  border-color: #1f6fff;
  color: #1f6fff;
}

.sa-export-size-name {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
}

.sa-export-size-ratio {
  font-size: 10px;
  opacity: 0.7;
  line-height: 1.2;
}

/* ── Action button (Download / Share combined) ── */
.sa-action-wrap {
  position: relative;
  margin-top: 4px;
  margin-bottom: 8px;
}

.sa-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  background: #1f6fff;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  padding: 11px 0;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.18s;
}

.sa-action-btn:hover { background: #1459d4; }

.sa-action-chevron {
  transition: transform 0.18s;
}

.sa-action-btn[aria-expanded="true"] .sa-action-chevron {
  transform: rotate(180deg);
}

.sa-action-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.13);
  overflow: hidden;
  z-index: 200;
}

.sa-action-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 600;
  color: #111;
  background: none;
  border: none;
  cursor: pointer;
  transition: background 0.1s;
  text-align: left;
}

.sa-action-item + .sa-action-item {
  border-top: 1px solid #f3f4f6;
}

.sa-action-item:hover { background: #f3f4f6; }
.sa-action-item:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Editor layout ── */
.sa-editor {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

@media (max-width: 768px) {
  .sa-editor {
    flex-direction: column;
    align-items: stretch;
    overflow: hidden; /* backstop: prevent any child from breaking out */
  }

  /* Canvas comes first on mobile */
  .sa-canvas-col {
    order: -1;
    min-width: 0;
    width: 100%;     /* explicit 100% in case flex stretch doesn't apply */
    max-width: 100%; /* never exceed the editor container */
    overflow: hidden;
  }
}

/* ── Sidebar ── */
.sa-sidebar {
  width: 300px;
  flex-shrink: 0;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

@media (max-width: 768px) {
  .sa-sidebar {
    width: 100%;
  }
}

.sa-sidebar-section {
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid #f3f4f6;
}

.sa-sidebar-section:last-of-type {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.sa-sidebar-label {
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 10px;
  display: block;
}

/* Wall thumbnail grid
   PC  : 3-column grid → all 6 walls visible at once (300px sidebar ÷ 3 = ~85px each)
   SP  : horizontal scroll → ~4.2 visible so the cut-off signals "more to scroll" */
.sa-wall-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

@media (max-width: 768px) {
  .sa-wall-grid {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: visible;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .sa-wall-grid::-webkit-scrollbar { display: none; }

  .sa-wall-thumb {
    /* ~4.2 thumbs visible in the full-width SP sidebar */
    flex: 0 0 calc((100% - 6px * 3) / 4.2);
    min-width: 44px;
    scroll-snap-align: start;
  }
}

.sa-wall-thumb {
  aspect-ratio: 4/3;
  border-radius: 6px;
  border: 2px solid transparent;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
  background: #e5e7eb;
  padding:0;
}

.sa-wall-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.sa-wall-thumb:hover {
  border-color: #93c5fd;
  transform: scale(1.04);
}

.sa-wall-thumb.is-active {
  border-color: #1f6fff;
}

/* Placeholder label shown when wall image file is not yet present */
.sa-wall-thumb-lbl {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 4px;
  font-size: 9px;
  font-weight: 600;
  color: rgba(255,255,255,0.7);
  pointer-events: none;
  text-align: center;
  line-height: 1.2;
}

.sa-wall-thumb {
  position: relative; /* needed for absolute labels */
}

/* Always-visible wall name label (bottom strip) */
.sa-wall-thumb-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  font-size: 9px;
  font-weight: 700;
  color: #fff;
  background: rgba(0, 0, 0, 0.48);
  text-align: center;
  padding: 3px 2px 4px;
  pointer-events: none;
  line-height: 1.1;
  letter-spacing: .02em;
  text-transform: uppercase;
}

/* Slider */
.sa-slider-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Style preset buttons ── */
.sa-style-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

/* PC: 2×2 grid — all 4 buttons visible */
.sa-style-scroll {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

/* SP: horizontal scroll — compact single row */
@media (max-width: 768px) {
  .sa-style-scroll {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -ms-overflow-style: none;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .sa-style-scroll::-webkit-scrollbar { display: none; }
  .sa-style-scroll .sa-style-btn {
    flex: 0 0 auto;
    width: 76px;
    scroll-snap-align: start;
  }
}

.sa-style-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 7px 4px 6px;
  background: #f3f4f6;
  border: 1.5px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  text-align: center;
}

.sa-style-btn:hover { background: #e9eaec; }

.sa-style-btn.is-active {
  background: #eff6ff;
  border-color: #1f6fff;
}

.sa-style-name {
  font-size: 12px;
  font-weight: 700;
  color: #111;
  line-height: 1.2;
}
.sa-style-btn.is-active .sa-style-name { color: #1f6fff; }

.sa-style-desc {
  font-size: 10px;
  color: #9ca3af;
  line-height: 1.3;
  margin-top: 2px;
}

/* ── Slider with inline label (SIZE / INK rows) ── */
.sa-slider-inline-section {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
  margin-bottom: 12px;
}
.sa-inline-label {
  margin-bottom: 0 !important;
  white-space: nowrap;
  min-width: 30px;
}
.sa-slider-inline-section .sa-slider-row {
  flex: 1;
}

/* ── Color + Spray single row (no label) ── */
.sa-color-spray-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.sa-color-spray-section .sa-color-row {
  flex-wrap: nowrap;
}

/* ── Color + Spray header (legacy, kept for reference) ── */
.sa-color-spray-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.sa-color-spray-header .sa-sidebar-label {
  margin-bottom: 0;
}

.sa-spray-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #374151;
  cursor: pointer;
  user-select: none;
}

.sa-spray-label input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: #1f6fff;
  cursor: pointer;
}

/* ── Stencil color buttons ── */
.sa-color-row {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.sa-color-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background-color: var(--c, #111);
  border: 2px solid #e5e7eb;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
  padding: 0;
}

.sa-color-btn:hover {
  transform: scale(1.14);
}

.sa-color-btn.is-active {
  border-color: #1f6fff;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #1f6fff;
}

/* White button: add visible border so it's not invisible on white backgrounds */
.sa-color-btn[data-color="#ffffff"] {
  border-color: #d1d5db;
}
.sa-color-btn[data-color="#ffffff"].is-active {
  border-color: #1f6fff;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #1f6fff;
}

.sa-slider-edge-label {
  font-size: 11px;
  color: #9ca3af;
  flex-shrink: 0;
}

.sa-range {
  flex: 1;
  height: 4px;
  accent-color: #1f6fff;
}

.sa-slider-val-label {
  font-size: 12px;
  color: #6b7280;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

/* Buttons */
.sa-download-btn {
  display: block;
  width: 100%;
  background: #1f6fff;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  padding: 11px 0;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.18s;
  margin-top: 16px;
  margin-bottom: 8px;
}

.sa-download-btn:hover {
  background: #1459d4;
}

.sa-share-btn {
  display: block;
  width: 100%;
  background: none;
  color: #1f6fff;
  font-weight: 600;
  font-size: 13px;
  padding: 8px 0;
  border: 1.5px solid #1f6fff;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 6px;
}

.sa-share-btn:hover {
  background: #f0f5ff;
}

.sa-change-btn {
  display: block;
  width: 100%;
  background: none;
  color: #6b7280;
  font-size: 13px;
  padding: 7px 0;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.sa-change-btn:hover {
  background: #f9fafb;
  color: #374151;
}

/* ── Canvas column ── */
.sa-canvas-col {
  flex: 1;
  /*min-width: 400px;*/
  display: flex;
  flex-direction: column;
  align-items: center;

  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.sa-canvas-wrap {
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
  background: #111;
  position: relative;
  cursor: grab;
  user-select: none;
  /* touch-action is NOT set on the wrap.
     - Desktop: mouse events don't use touch-action → no effect.
     - Mobile:  wrap defaults to touch-action:auto (browser default),
                so the transparent side-margins always allow page scroll.
                The canvas element itself manages touch-action via JS
                (_updateCanvasTouchAction in editor.js). */
}

/* SP portrait: canvas may be narrower than wrap.
   Transparent wrap lets page background show as white-space margins.
   Canvas element itself gets the dark background + border-radius. */
@media (max-width: 768px) {
  .sa-canvas-wrap { background: transparent; }
  #saCanvas { border-radius: 10px; background: #111; }
}

.sa-canvas-wrap:active {
  cursor: grabbing;
}

/* Drag/bg-mode: outline indicator only.
   touch-action is NOT set on the wrap so the transparent side-margins
   remain scrollable. The canvas element itself handles touch-action via JS. */
.sa-canvas-wrap.is-drag-mode {
  outline: 2px solid #1f6fff;
  outline-offset: 2px;
}

#saCanvas {
  display: block;
  width: 100%;
  height: auto;
  /* touch-action must be on the element that receives pointer events.
     Relying on parent inheritance is unreliable on iOS Safari. */
  touch-action: none;
}

.sa-drag-hint {
  font-size: 12px;
  color: #9ca3af;
  margin-top: 8px;
  text-align: center;
}

/* Mobile: show tap hint, hide drag hint */
.sa-drag-hint-mobile { display: none; }

@media (max-width: 768px) {
  .sa-drag-hint-desktop { display: none; }
  .sa-drag-hint-mobile  { display: inline; }
}

/* Reposition button — mobile only */
.sa-reposition-btn {
  display: none; /* hidden on desktop */
}

@media (max-width: 768px) {
  .sa-reposition-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding: 9px 20px;
    font-size: 13px;
    font-weight: 600;
    color: #1f6fff;
    background: #f0f5ff;
    border: 1.5px solid #1f6fff;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
  }

  .sa-reposition-btn.is-active {
    background: #1f6fff;
    color: #fff;
  }
}

/* ── How it works ── */
.sa-howto-section {
  background: #f8f9fb;
}

.sa-howto-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
  margin-top: 16px;
}

@media (max-width: 640px) {
  .sa-howto-steps {
    grid-template-columns: 1fr;
    gap: 20px;
  }
}

.sa-howto-step {
  text-align: center;
}

.sa-howto-num {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #1f6fff;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
}

.sa-howto-step-title {
  font-size: 15px;
  font-weight: 700;
  color: #111;
  margin-bottom: 8px;
}

/* ── Mode button row (Move stencil / Adjust bg) ── */
/* SP: canvas と mode ボタンの間に余白 */
@media (max-width: 768px) {
  .sa-canvas-col {
    padding-bottom: 4px; /* canvas 下の余白 */
  }
}

.sa-mode-btn-row {
  display: flex;
  gap: 8px;
  margin-top: 14px; /* ボタンとキャンバスの距離を増やす */
  margin-bottom: 4px;
}

.sa-mode-btn {
  flex: 1;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;  /* prevent 2-line wrap */
  color: #1f6fff;
  background: #f0f5ff;
  border: 1.5px solid #1f6fff;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.sa-mode-btn:hover    { background: #dbeafe; }
.sa-mode-btn.is-active { background: #1f6fff; color: #fff; }

/* Mode buttons: show on ALL screen sizes (PC + SP).
   On PC, shown below the canvas for background adjust access. */
@media (min-width: 769px) {
  .sa-mode-btn-row {
    margin-top: 12px;
    max-width: 320px;  /* don't stretch too wide on desktop */
    align-self: center;
  }
  .sa-mode-btn {
    font-size: 12px;
    padding: 7px 10px;
  }
}

.sa-dynamic-slider-row[hidden] { display: none !important; }

/* ── View / Fit button group ── */
.sa-mode-btn-sep {
  width: 1px;
  background: #d1d5db;
  align-self: stretch;
  margin: 4px 2px;
  flex-shrink: 0;
}

/* Fit button: outlined style（常時有効・モード非依存） */
.sa-fit-btn {
  color: #6b7280 !important;
  background: #f9fafb !important;
  border-color: #d1d5db !important;
}
.sa-fit-btn:hover {
  background: #f3f4f6 !important;
  color: #374151 !important;
}
/* Fitはis-activeにならないのでoverrideなし */

/* Scale hint below canvas */
.sa-scale-hint {
  font-size: 11px;
  color: #9ca3af;
  margin: 5px 0 0;
  text-align: center;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

/* Background adjust mode: outline only — touch-action handled by JS on canvas */
.sa-canvas-wrap.is-bg-mode {
  outline: 2px solid #f59e0b;
  outline-offset: 2px;
}

/* ── Rough pen brush size row ── */
.sa-brush-size-row[hidden] { display: none !important; }
.sa-brush-size-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 6px 10px;
  background: #eff6ff;
  border: 1.5px solid #bfdbfe;
  border-radius: 999px;
  animation: sa-fadein 0.15s ease;
}
@keyframes sa-fadein {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.sa-brush-dot {
  color: #1f6fff;
  flex-shrink: 0;
}
.sa-brush-range {
  flex: 1;
  accent-color: #1f6fff;
}

/* ── Rough pen (erase) mode ── */
.sa-canvas-wrap.is-erase-mode canvas { cursor: none; }
.sa-canvas-wrap.is-erase-mode {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* ── Reposition btn (legacy, now hidden in favour of sa-mode-btn-row) ── */
.sa-reposition-btn { display: none !important; }

/* ── How it works ── */
.sa-howto-step-body {
  font-size: 14px;
  color: #6b7280;
  line-height: 1.6;
}
/* ── Mode hint text ── */
.sa-mode-hint {
  font-size: 11px;
  color: #9ca3af;
  text-align: center;
  margin: 4px 0 0;
  min-height: 1.4em;
  letter-spacing: 0.01em;
}

/* ── Dynamic slider row (canvas下) ── */
.sa-dynamic-slider-row {
  width: 100%;
  max-width: 320px;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sa-dynamic-slider-label {
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: .05em;
}

@media (min-width: 769px) {
  .sa-dynamic-slider-row {
    align-self: center;
  }
}

/* Ad banner */
.sa-ad-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  box-shadow: 0 -2px 12px rgba(0,0,0,.15);
  padding: 12px 16px 16px;
  z-index: 9999;
  transform: translateY(100%);
  transition: transform .3s ease;
}
.sa-ad-banner.is-visible {
  transform: translateY(0);
}
.sa-ad-close {
  position: absolute;
  top: 8px; right: 12px;
  background: none; border: none;
  font-size: 16px; cursor: pointer;
  color: #888;
}