
.page {
  flex: 1;
  max-width: var(--w-base);
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tool {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* アップロードゾーン（画像が1枚もないときだけ表示） */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease;
}

.upload-zone:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.upload-idle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 48px 24px;
  user-select: none;
  pointer-events: none;
}

.upload-icon { color: var(--muted); }

.upload-primary {
  font-size: 14px;
  font-weight: 600;
  color: var(--sub);
}

.upload-sub {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  line-height: 1.7;
}

/* ページ全体にドラッグしたときのオーバーレイ */
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(17, 24, 39, 0.55);
  pointer-events: none;
}

.drop-overlay.show { display: flex; }

.drop-overlay span {
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  padding: 20px 32px;
  border-radius: var(--radius);
  border: 2px dashed var(--accent);
}

/* プレビュー */
.stage { display: none; }

.preview-wrap {
  position: relative;
  line-height: 0;
  background:
    linear-gradient(45deg, #e9ecef 25%, transparent 25%, transparent 75%, #e9ecef 75%),
    linear-gradient(45deg, #e9ecef 25%, #f8f9fa 25%, #f8f9fa 75%, #e9ecef 75%);
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
  border-radius: calc(var(--radius) - 2px);
  overflow: hidden;
}

/* 画像の縦横比に合わせて JS が幅と高さを決める。縦長の画像は中央に寄せる */
.preview-wrap {
  display: flex;
  justify-content: center;
}

#preview {
  display: block;
  max-width: 100%;
}

/* 1か所のときは、押した位置に透かしが動く */
#preview.draggable {
  cursor: crosshair;
  touch-action: none;
}

.stage-hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

/* 設定 */
.config {
  display: none;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: grid;
  grid-template-columns: 62px 1fr;
  align-items: center;
  gap: 12px;
}

.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  user-select: none;
}

.seg {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 3px;
  width: fit-content;
}

.seg-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: "Noto Sans JP", sans-serif;
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 15px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}

.seg-btn:hover:not(.active):not(:disabled) { color: var(--sub); }

.seg-btn.active {
  background: var(--accent);
  color: #fff;
}

.seg-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}


/* 文字・ロゴの切り替えで中身を入れ替える */
.mode-pane {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.mode-pane[hidden], .field[hidden] { display: none; }

.text-input {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-family: "Noto Sans JP", sans-serif;
  font-size: 14px;
}
.text-input:focus {
  outline: none;
  border-color: var(--accent);
}

.color-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.color-input {
  width: 40px;
  height: 32px;
  padding: 0;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}
.swatches { display: flex; gap: 6px; }
.swatch {
  appearance: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  cursor: pointer;
}
.swatch:hover { border-color: var(--accent); }

.logo-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-thumb {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid var(--border);
  background:
    linear-gradient(45deg, #e9ecef 25%, transparent 25%, transparent 75%, #e9ecef 75%),
    linear-gradient(45deg, #e9ecef 25%, #f8f9fa 25%, #f8f9fa 75%, #e9ecef 75%);
  background-size: 10px 10px;
  background-position: 0 0, 5px 5px;
}
.logo-thumb[hidden] { display: none; }

.field-note {
  margin: -6px 0 0 74px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

/* 位置の 3×3 ボタン。押すと、その隅・辺・中央にそろう */
.pos-grid {
  display: grid;
  grid-template-columns: repeat(3, 28px);
  grid-template-rows: repeat(3, 28px);
  gap: 4px;
  padding: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: fit-content;
}
.pos-grid button {
  appearance: none;
  border: 1.5px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  cursor: pointer;
  position: relative;
}
.pos-grid button::after {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: var(--border);
}
.pos-grid button:hover { border-color: var(--accent); }
.pos-grid button.active { border-color: var(--accent); background: var(--accent-soft); }
.pos-grid button.active::after { background: var(--accent); }

.range-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.range-row input[type="range"] {
  flex: 1;
  appearance: none;
  -webkit-appearance: none;
  height: 4px;
  border-radius: 999px;
  background: var(--border);
  cursor: pointer;
}
.range-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}
.range-row input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}
.range-val {
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  min-width: 44px;
  text-align: right;
  user-select: none;
}

/* 一覧 */
.list {
  display: none;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 340px;
  overflow-y: auto;
}

.row {
  display: grid;
  grid-template-columns: 40px 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease;
}

.row:hover { background: var(--hover); }

.row.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.row-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--bg);
  display: block;
}

.row-main {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.row-name {
  font-size: 12.5px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-size {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-btn {
  appearance: none;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 140ms ease, color 140ms ease, background 140ms ease;
}

.row-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-deep);
  background: var(--surface);
}

.row-btn.del:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.row-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* 操作ボタン */
.actions {
  display: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.sub-btn {
  appearance: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: "Noto Sans JP", sans-serif;
  font-size: 12px;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 140ms ease, color 140ms ease;
}

.sub-btn:hover {
  border-color: var(--accent);
  color: var(--accent-deep);
}

.sub-btn.danger:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.dl-btn {
  appearance: none;
  border: none;
  background: var(--accent);
  color: #fff;
  font-family: "Noto Sans JP", sans-serif;
  font-size: 14px;
  font-weight: 600;
  padding: 13px 20px;
  border-radius: var(--radius);
  cursor: pointer;
  width: 100%;
  transition: background 140ms ease;
}

.dl-btn:hover { background: var(--accent-deep); }

.dl-btn:disabled {
  background: var(--border);
  color: var(--muted);
  cursor: not-allowed;
}

/* 注意書き */
.notice {
  display: none;
  gap: 8px;
  align-items: flex-start;
  flex-wrap: wrap;
  background: var(--bg);
  border-left: 3px solid var(--muted);
  border-radius: 4px;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--sub);
  line-height: 1.6;
}

.notice.show { display: flex; }

.notice.warn {
  background: #fffbeb;
  border-left-color: #d97706;
}

.notice-icon {
  flex-shrink: 0;
  margin-top: 1px;
  color: var(--muted);
}

.notice.warn .notice-icon { color: #d97706; }

/* 注意書きから形式を切り替えるボタン。必要なときだけ出す */
.notice-btn {
  display: none;
  margin-left: auto;
  flex-shrink: 0;
  appearance: none;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--sub);
  font-family: "Noto Sans JP", sans-serif;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.notice-btn.show { display: inline-flex; }

.notice-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-deep);
}

/* アコーディオン内 */
.howto {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: howto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 14px;
}

/* li は flex にしない。flex にすると本文中の <b> が独立した子として
   横に並んでしまい、文章が途中で分断される。番号は絶対配置で置く。 */
.howto li {
  counter-increment: howto;
  position: relative;
  padding-left: 30px;
  font-size: 13px;
  color: var(--sub);
  line-height: 1.6;
}

.howto li::before {
  content: counter(howto);
  position: absolute;
  left: 0;
  top: 1px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.about-text {
  font-size: 13px;
  color: var(--sub);
  line-height: 1.7;
  margin: 0;
  padding-top: 14px;
}

.about-text + .about-text { padding-top: 10px; }

.fmt-table-wrap {
  padding-top: 14px;
  overflow-x: auto;
}

.fmt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  min-width: 380px;
}

.fmt-table th,
.fmt-table td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  line-height: 1.6;
  color: var(--sub);
}

.fmt-table th {
  background: var(--bg);
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}

.ad-slot { margin-top: 4px; }

/* モバイル */
@media (max-width: 480px) {
  .tool { padding: 18px; }
  .upload-idle { padding: 32px 16px; }
  .upload-primary { font-size: 13px; }

  .field {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .seg-btn { padding: 7px 13px; font-size: 12px; }
  .field-note { margin-left: 0; }

  /* スマホでは設定が縦に長くなり、下の設定を触るとプレビューが画面の外に出てしまう。
     プレビューを画面の上（固定ヘッダー 52px の下）に貼り付けて、変えながら見られるようにする。
     高さは JS 側で画面の 38% までに抑えている */
  .stage {
    position: sticky;
    top: 52px;
    z-index: 5;
    background: var(--surface);
    margin: -8px -18px 0;
    padding: 8px 18px 10px;
    border-bottom: 1px solid var(--border);
  }
  .stage-hint { font-size: 11px; margin-top: 6px; }

  .row {
    grid-template-columns: 36px 1fr auto auto;
    gap: 8px;
    padding: 6px;
  }

  .row-thumb { width: 36px; height: 36px; }
  .row-name { font-size: 12px; }

  .actions .sub-btn { flex: 1; }
}
