/* 画像の背景透過・白フチ付けツール */
.tool { padding-top: 16px; }

.tool-error {
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: #fef3f2;
  border: 1px solid #fecdca;
  color: var(--color-danger);
  font-size: 0.92rem;
}
.tool-error.is-info {
  background: var(--color-primary-soft);
  border-color: #c7cbff;
  color: #3730a3;
}

/* 透過部分を示す市松模様 */
.checker {
  background-color: #ffffff;
  background-image: conic-gradient(#dfe4ea 25%, transparent 0 50%, #dfe4ea 0 75%, transparent 0);
  background-size: 20px 20px;
}
.checker.is-dark {
  background-color: #64748b;
  background-image: conic-gradient(#4b5a6f 25%, transparent 0 50%, #4b5a6f 0 75%, transparent 0);
}

/* 画面1：編集 */
.editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  align-items: start;
}

.stage-column {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
}

.stage-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.stage-title { font-weight: 700; font-size: 0.95rem; }
.stage-toolbar-actions { display: flex; gap: 8px; }

.stage {
  position: relative;
  height: min(68vh, 620px);
  min-height: 280px;
  border-radius: var(--radius-sm);
  background: #f1f3f8;
  overflow: hidden;
}
.stage.is-dragover { outline: 3px dashed var(--color-primary); outline-offset: -6px; }

.dropzone {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  border: 2px dashed #c9cfdc;
  border-radius: var(--radius-sm);
}
.dropzone-title { margin: 0; font-weight: 700; font-size: 1.05rem; }
.dropzone-note { margin: 0; color: var(--color-muted); font-size: 0.85rem; }

.panes {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 12px;
}
.panes.is-compare { grid-template-columns: 1fr 1fr; }

.pane {
  margin: 0;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.pane canvas {
  display: block;
  max-width: 100%;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.08);
}
.pane figcaption {
  display: none;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-muted);
  line-height: 1.2;
}
.panes.is-compare .pane figcaption { display: block; }

.stage.is-picking canvas { cursor: crosshair; }

.stage-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.75);
  color: #fff;
  font-size: 0.8rem;
  pointer-events: none;
}

.pick-hint {
  margin: 10px 0 0;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--color-primary-soft);
  color: #3730a3;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
}

/* 設定パネル */
.controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.controls-body {
  margin: 0;
  padding: 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  box-shadow: var(--shadow);
  min-width: 0;
}
.controls-body:disabled { opacity: 0.55; }

.control + .control, .control + .advanced { margin-top: 18px; }
.control-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.control-label { font-weight: 700; font-size: 0.92rem; }
.control output {
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
  color: var(--color-primary);
  font-weight: 700;
}
.control-help { margin: 4px 0 0; color: var(--color-muted); font-size: 0.8rem; line-height: 1.55; }

.color-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.swatch {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  flex: none;
}
.swatch.is-auto {
  background-image: conic-gradient(#dfe4ea 25%, #fff 0 50%, #dfe4ea 0 75%, #fff 0);
  background-size: 12px 12px;
}
.color-text { font-variant-numeric: tabular-nums; font-size: 0.9rem; min-width: 5.5em; }

input[type="range"] {
  width: 100%;
  margin: 8px 0 0;
  accent-color: var(--color-primary);
  height: 28px;
  cursor: pointer;
}
input[type="range"]:disabled { cursor: not-allowed; }

.advanced {
  border-top: 1px solid var(--color-border);
  padding-top: 14px;
}
.advanced summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--color-muted);
}
.advanced-body { padding-top: 12px; }
.advanced-body .control { margin-top: 14px; }
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 0.9rem;
  cursor: pointer;
}
.check input { width: 18px; height: 18px; accent-color: var(--color-primary); flex: none; }
.advanced-body .btn { margin-top: 16px; }

/* 画面2：ダウンロード */
.download {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  text-align: center;
}
.download-title { margin: 0 0 12px; font-size: 1.15rem; outline: none; }
.stage-final {
  display: flex;
  align-items: center;
  justify-content: center;
  height: auto;
  min-height: 240px;
  padding: 16px;
}
.stage-final canvas {
  display: block;
  max-width: 100%;
  max-height: 62vh;
  width: auto;
  height: auto;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.08);
}
.final-meta {
  margin: 10px 0 0;
  min-height: 1.5em;
  color: var(--color-muted);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}
.download-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}
.download-note {
  max-width: 640px;
  margin: 14px auto 0;
  color: var(--color-muted);
  font-size: 0.82rem;
}

/* スマホ */
@media (max-width: 860px) {
  .editor { grid-template-columns: 1fr; gap: 12px; }
  .stage-column {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 8px;
    border-radius: 0 0 var(--radius) var(--radius);
  }
  .stage { height: 42vh; min-height: 220px; }
  .stage-toolbar { margin-bottom: 6px; }
  .panes { padding: 8px; gap: 8px; }
  .pick-hint { margin-top: 6px; padding: 6px 10px; font-size: 0.85rem; }
  #btn-next {
    position: sticky;
    bottom: 12px;
    z-index: 4;
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.35);
  }
  #btn-next:disabled { position: static; box-shadow: none; }
  .download-actions .btn { flex: 1 1 100%; }
}
