/* SPORTS POSTER MAKER（Figma「ポスターアプリPJ」準拠） */
:root {
  --navy-900: #0f172a;
  --slate-800: #1e293b;
  --slate-600: #475569;
  --slate-400: #94a3b8;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-50: #f8fafc;
  --white: #ffffff;
  --blue-600: #2563eb;
  --blue-100: #dbeafe;
  --blue-tint: rgb(37 99 235 / 0.13);
  --green-500: #10b981;
  --green-100: #d1fae5;
  --red-500: #ef4444;
  --line: #06c755;
  --instagram: #e1306c;

  --navbar-height: 64px;
  --font-ui: "Inter", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", system-ui, sans-serif;
  --font-brand: "Outfit", var(--font-ui);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--slate-200);
  color: var(--navy-900);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: normal;
}
body[data-step="1"] { background: var(--slate-50); }

h1, h2, h3, p, figure, ul, ol { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.5; }
img { display: block; }

:focus-visible { outline: 2px solid var(--blue-600); outline-offset: 2px; }

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ステップごとの表示切り替え（data-show-on="2 3" のように表示するステップを並べる） */
body[data-step="1"] [data-show-on]:not([data-show-on~="1"]),
body[data-step="2"] [data-show-on]:not([data-show-on~="2"]),
body[data-step="3"] [data-show-on]:not([data-show-on~="3"]),
body[data-step="4"] [data-show-on]:not([data-show-on~="4"]) { display: none !important; }

/* 編集画面の左パネル：選んだレイヤーの種類（data-kind）に合う項目（data-for）だけ表示 */
.props-panel[data-kind="none"] [data-for]:not([data-for~="none"]),
.props-panel[data-kind="photo"] [data-for]:not([data-for~="photo"]),
.props-panel[data-kind="placeholder"] [data-for]:not([data-for~="placeholder"]),
.props-panel[data-kind="text"] [data-for]:not([data-for~="text"]),
.props-panel[data-kind="logo"] [data-for]:not([data-for~="logo"]) { display: none !important; }

/* ---------- 上部ナビ ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--navbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  background: var(--navy-900);
  color: var(--white);
}

.brand { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  border-radius: 6px;
  background: var(--blue-600);
  font-family: var(--font-brand);
  font-weight: 800;
  font-size: 18px;
}
.brand-name { font-family: var(--font-brand); font-weight: 800; font-size: 16px; white-space: nowrap; }

.steps { flex: 1; display: flex; justify-content: center; min-width: 0; }
.steps-list { display: flex; align-items: center; gap: 16px; }
.steps-list li { display: flex; align-items: center; gap: 8px; }
.step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--slate-400);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.step:disabled { opacity: 1; cursor: default; }
.step-badge {
  display: grid;
  place-items: center;
  width: 24px; height: 24px;
  border-radius: 12px;
  background: var(--slate-800);
  color: var(--white);
  font-size: 11px;
  font-weight: 700;
}
.step.is-current { color: var(--white); font-weight: 700; }
.step.is-current .step-badge { background: var(--blue-600); }
.step.is-done { color: var(--green-500); }
.step.is-done .step-badge { background: var(--green-500); }
.step-chevron { flex-shrink: 0; }

.save-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-shrink: 0; }
.save-status { font-size: 11px; color: var(--slate-400); white-space: nowrap; }
.nav-btn {
  padding: 6px 10px;
  border: 1px solid var(--slate-600);
  border-radius: 6px;
  background: none;
  color: var(--slate-200);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.nav-btn:hover { background: var(--slate-800); }
.label-short { display: none; }

/* ---------- 共通パーツ ---------- */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  text-decoration: none;
}
.btn-primary { background: var(--blue-600); color: var(--white); }
.btn-primary:hover { background: #1d4ed8; }
.btn-cta { padding: 12px; font-size: 14px; }
.btn-secondary { background: var(--slate-50); border-color: var(--slate-300); color: var(--slate-600); font-weight: 600; }
.btn-secondary:hover { background: var(--slate-200); }
.btn-outline { background: var(--white); border-color: var(--slate-300); color: var(--slate-600); font-weight: 600; }
.btn-outline:hover { background: var(--slate-50); }
.btn-line { background: var(--line); color: var(--white); font-size: 12px; }
.btn-instagram { background: var(--instagram); color: var(--white); font-size: 12px; }
.btn-line:hover, .btn-instagram:hover { filter: brightness(0.95); }

.icon-btn {
  display: grid;
  place-items: center;
  padding: 2px;
  border: 0;
  border-radius: 4px;
  background: none;
}
.icon-btn:hover { background: rgb(15 23 42 / 0.06); }

.button-row { display: flex; gap: 12px; }
.button-row > * { flex: 1 1 0; min-width: 0; }

.select-box {
  position: relative;
  display: flex;
  align-items: center;
}
.select-box select {
  width: 100%;
  appearance: none;
  padding: 8px 36px 8px 12px;
  border: 1px solid var(--slate-300);
  border-radius: 8px;
  background: var(--slate-50);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.select-box img { position: absolute; right: 12px; pointer-events: none; }

/* スライダー（つまみは Figma の slider-thumb） */
.range {
  width: 100%;
  height: 16px;
  margin: 0;
  appearance: none;
  background: none;
  cursor: pointer;
}
.range::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--slate-200); }
.range::-moz-range-track { height: 4px; border-radius: 2px; background: var(--slate-200); }
.range::-webkit-slider-thumb {
  appearance: none;
  width: 12px; height: 12px;
  margin-top: -4px;
  border: 0;
  background: url("../../images/icons/slider-thumb.svg") center / 12px 12px no-repeat;
}
.range::-moz-range-thumb {
  width: 12px; height: 12px;
  border: 0;
  background: url("../../images/icons/slider-thumb.svg") center / 12px 12px no-repeat;
}

.range-field { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.label-row { display: flex; justify-content: space-between; font-size: 12px; }
.label-row label { color: var(--slate-600); }
.label-row output { font-weight: 700; }

/* ---------- STEP 1：テンプレート選択 ---------- */
.resume-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 20px;
  border: 1px solid var(--blue-600);
  border-radius: 12px;
  background: var(--blue-100);
}
.resume-text { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.resume-text span { font-size: 12px; color: var(--slate-600); }
.resume-actions { display: flex; gap: 8px; }

.screen-templates {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 32px 48px 48px;
}

.section-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.title-group { display: flex; flex-direction: column; gap: 8px; }
.page-title { font-size: 24px; font-weight: 800; }
.page-lead { font-size: 14px; color: var(--slate-600); }

.controls-group { display: flex; align-items: center; gap: 12px; }
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 280px;
  padding: 8px 12px;
  border: 1px solid var(--slate-300);
  border-radius: 8px;
  background: var(--white);
}
.search-bar input { flex: 1; min-width: 0; padding: 0; border: 0; outline: 0; background: none; font-size: 14px; }
.search-bar input::placeholder { color: var(--slate-400); }
.search-bar:focus-within { border-color: var(--blue-600); }
.sort-select select { background: var(--white); font-weight: 400; font-size: 14px; color: var(--slate-600); padding-right: 34px; }

.filter-bar { display: flex; flex-direction: column; gap: 12px; }
.filter-group { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filter-label { width: 84px; flex-shrink: 0; font-size: 12px; font-weight: 700; color: var(--slate-600); }
.filter-tab {
  padding: 8px 16px;
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  background: var(--white);
  color: var(--slate-600);
  font-size: 14px;
  font-weight: 600;
}
.filter-tab:hover { border-color: var(--slate-300); }
.filter-tab[aria-pressed="true"] { background: var(--blue-600); border-color: transparent; color: var(--white); }

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
  align-items: start;
}
.template-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  background: var(--white);
}
.template-card.is-selected { border-color: var(--blue-600); box-shadow: 0 0 0 1px var(--blue-600); }
/* ポスター全体の完成イメージを、ポスターと同じ縦長の比率で切らずに見せる */
.template-preview { display: block; width: 100%; height: auto; aspect-ratio: 1000 / 1414; object-fit: cover; background: var(--slate-200); }
.card-info { display: flex; flex-direction: column; gap: 12px; padding: 12px; }
.tag-row { display: flex; gap: 6px; }
.tag { padding: 2px 8px; border-radius: 4px; font-size: 10px; }
.tag-sport { background: var(--blue-100); color: var(--blue-600); font-weight: 600; }
.tag-layout { background: var(--slate-200); color: var(--slate-600); font-weight: 500; }
.meta-row { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.card-name { font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-sub { font-size: 12px; color: var(--slate-400); }
.empty { grid-column: 1 / -1; padding: 48px 0; text-align: center; color: var(--slate-600); }

/* ---------- STEP 2〜5：ワークスペース ---------- */
.workspace {
  display: flex;
  height: calc(100dvh - var(--navbar-height));
}

.center-stage {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: hidden;
}

/* ポスターは 1:√2。高さは画面に収まる範囲でデザイン寸法を上限にする */
.poster-frame {
  --frame-pad: 0px;
  --poster-h: min(720px, calc(100dvh - var(--navbar-height) - 48px));
  position: relative;
  padding: var(--frame-pad);
}
.stage {
  position: relative;
  height: calc(var(--poster-h) - var(--frame-pad) * 2);
  aspect-ratio: 1000 / 1414;
  overflow: hidden;
  border-radius: 16px;
  background: #111b3d;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.15);
}

/* STEP 3・4：完成画像だけを見せる */
body[data-step="3"] .stage,
body[data-step="4"] .stage { position: absolute; visibility: hidden; }
.poster-finished {
  height: min(664px, calc(100dvh - var(--navbar-height) - 48px));
  aspect-ratio: 1000 / 1414;
  border-radius: 16px;
  object-fit: cover;
  filter: drop-shadow(0 12px 16px rgb(0 0 0 / 0.2));
}

/* テンプレートの写真枠のうち、写真もダミーも入っていない枠（位置は JS で % 指定） */
.photo-slots { position: absolute; inset: 0; pointer-events: none; }
.photo-slot {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px;
  border: 2px dashed var(--blue-600);
  border-radius: 12px;
  background: var(--blue-tint);
  text-align: center;
  pointer-events: auto;
}
.photo-slot:hover { background: rgb(37 99 235 / 0.22); }
.slot-title { color: var(--white); font-size: 13px; font-weight: 700; text-shadow: 0 1px 3px rgb(0 0 0 / 0.6); }
.slot-note { color: var(--slate-200); font-size: 11px; text-shadow: 0 1px 3px rgb(0 0 0 / 0.6); }

.guide { position: absolute; pointer-events: none; visibility: hidden; }
.stage.is-snap-y .guide-h,
.stage.is-snap-x .guide-v { visibility: visible; }
.guide-h { left: 0; top: 50%; width: 100%; height: 1px; }
/* 縦のガイドは横長画像を 90° 回転して使う */
.guide-v { left: 50%; top: 50%; width: var(--poster-h); height: 1px; translate: -50% -50%; rotate: 90deg; }

.size-label {
  position: absolute;
  translate: -50% -100%;
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--blue-600);
  color: var(--white);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
}

/* ---------- サイドバー ---------- */
.sidebar {
  flex-shrink: 0;
  width: 420px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px;
  overflow-y: auto;
  border-left: 1px solid var(--slate-300);
  background: var(--white);
}

/* 編集画面：左に操作パネル、中央にキャンバス、右にレイヤー一覧 */
.props-panel { order: -1; width: 340px; border-left: 0; border-right: 1px solid var(--slate-300); }
.layers-panel { width: 300px; gap: 16px; }
.add-buttons { display: flex; gap: 8px; }
.add-buttons .btn { flex: 1 1 0; cursor: pointer; }
.layers-panel .layer-list { gap: 8px; }
.layers-panel .layer-card { padding: 8px 10px; }
.layer-card:hover { border-color: var(--blue-600); }
.layers-panel .btn-cta { margin-top: auto; }
/* 3列でもポスターが横にはみ出さないよう、空いている幅からも高さを決める */
body[data-step="2"] .poster-frame {
  --poster-h: min(720px, calc(100dvh - var(--navbar-height) - 48px), calc((100vw - 688px) * 1.414));
}
.btn-danger { color: #b91c1c; border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }

/* 「なし / 10% / 30% / 50%」のような択一ボタン */
.segmented {
  display: flex;
  height: 36px;
  overflow: hidden;
  border: 1px solid var(--slate-300);
  border-radius: 8px;
  background: var(--slate-50);
}
.segmented button {
  flex: 1 1 0;
  border: 0;
  border-left: 1px solid var(--slate-300);
  background: none;
  color: var(--slate-600);
  font-size: 12px;
  font-weight: 700;
}
.segmented button:first-child { border-left: 0; }
.segmented button[aria-checked="true"] { background: var(--blue-100); color: var(--blue-600); }

.sidebar-header { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
/* 左パネルの見出し：いま操作しているレイヤーのサムネイル＋名前 */
.props-header { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; row-gap: 6px; align-items: center; }
.props-header > :not(.layer-thumb) { grid-column: 2; }
.props-header .layer-thumb { grid-row: 1 / span 2; }
.props-header .layer-thumb[hidden] + .sidebar-title,
.props-header .layer-thumb[hidden] ~ .sidebar-lead { grid-column: 1 / -1; }
.sidebar-title { font-size: 18px; font-weight: 800; }
.sidebar-title.is-large { font-size: 20px; }
.sidebar-lead { font-size: 13px; color: var(--slate-600); }

.sidebar-section { display: flex; flex-direction: column; gap: 16px; }
.sidebar-section.gap-14 { gap: 14px; }
.sidebar-section.gap-10 { gap: 10px; }
.sidebar-section.gap-8 { gap: 8px; }
.section-label { font-size: 13px; font-weight: 700; color: var(--slate-600); }
.section-note { margin-top: -8px; font-size: 11px; color: var(--slate-400); }
.btn-small { width: auto; padding: 6px 10px; font-size: 12px; gap: 6px; }

/* STEP 2 */
.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 32px 16px;
  border: 2px dashed var(--blue-600);
  border-radius: 8px;
  background: var(--slate-50);
  text-align: center;
  cursor: pointer;
}
.drop-zone:hover, .drop-zone.is-dragover { background: var(--blue-100); }
.drop-zone:focus-within { outline: 2px solid var(--blue-600); outline-offset: 2px; }
.upload-icon-circle { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 24px; background: var(--blue-100); }
.drop-title { margin-top: 0; font-size: 14px; font-weight: 700; }
.drop-note { margin-top: -8px; font-size: 12px; color: var(--slate-400); }

.upload-status {
  margin-top: -12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--blue-100);
  color: var(--blue-600);
  font-size: 13px;
  font-weight: 700;
}

.thumbnails { display: flex; flex-wrap: wrap; gap: 8px; }
.thumb {
  width: 64px; height: 64px;
  padding: 0;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 6px;
  background: var(--slate-200);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb[aria-pressed="true"] { border-color: var(--blue-600); }
.thumb.is-removed img { opacity: 0.4; }
/* 切り抜き画像の透明部分が分かるよう市松模様を敷く */
.thumb { background: repeating-conic-gradient(var(--slate-200) 0 25%, var(--white) 0 50%) 0 0 / 12px 12px; }

.ai-card { display: flex; flex-direction: column; gap: 12px; padding: 16px; border-radius: 12px; background: var(--blue-100); }
.ai-header { display: flex; align-items: center; justify-content: space-between; }
.ai-badge { display: flex; align-items: center; gap: 6px; color: var(--blue-600); font-size: 14px; font-weight: 700; }
.ai-note { font-size: 12px; color: var(--slate-600); }

/* スイッチ：ON は Figma の switch-active、OFF はグレー */
.switch {
  position: relative;
  width: 48px; height: 26px;
  margin: 0;
  appearance: none;
  border-radius: 13px;
  background: var(--slate-300);
  cursor: pointer;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 22px; height: 22px;
  border-radius: 11px;
  background: var(--white);
}
.switch:checked { background: url("../../images/icons/switch-active.svg") center / 48px 26px no-repeat; }
.switch:checked::after { display: none; }

.side-by-side { display: flex; align-items: flex-start; justify-content: center; gap: 12px; }
.compare { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; color: var(--slate-600); }
.compare figcaption.is-accent { color: var(--blue-600); font-weight: 600; }
.compare-box {
  position: relative;
  display: grid;
  place-items: center;
  width: 120px; height: 120px;
  overflow: hidden;
  border-radius: 6px;
  background: rgb(255 255 255 / 0.6);
}
.compare-box.is-dark { background: var(--slate-800); }
.compare-box img { width: 100%; height: 100%; object-fit: cover; }
.compare-box.is-dark img { object-fit: contain; }
.compare-status { position: absolute; padding: 8px; color: var(--white); font-size: 11px; text-align: center; }
.compare-arrow { align-self: center; margin-top: -16px; }

/* STEP 3 */
.field-row { display: flex; gap: 12px; }
.field-row > * { flex: 1 1 0; min-width: 0; }
.inline-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--slate-300);
  border-radius: 8px;
  background: var(--slate-50);
  font-size: 14px;
  font-weight: 700;
}
.inline-input span { font-size: 12px; font-weight: 400; color: var(--slate-400); white-space: nowrap; }
.inline-input input { width: 100%; min-width: 0; padding: 0; border: 0; outline: 0; background: none; font-weight: 700; text-align: right; }
.inline-input:focus-within { border-color: var(--blue-600); }

.layer-list { display: flex; flex-direction: column; gap: 16px; }
.layer-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  background: var(--white);
}
.layer-card.is-active { border-color: var(--blue-600); background: var(--blue-100); }
.layer-card[draggable="true"] { cursor: grab; }
.layer-card.is-dragging { opacity: 0.4; }
.layer-card.drop-before { box-shadow: 0 -3px 0 var(--blue-600); }
.layer-card.drop-after { box-shadow: 0 3px 0 var(--blue-600); }
.layer-select {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--slate-600);
  font-size: 13px;
  text-align: left;
}
.layer-select { flex: 1; }
/* レイヤーの中身を写した正方形のサムネイル。白い文字も見えるよう暗い市松模様に載せる */
.layer-thumb {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  overflow: hidden;
  border: 1px solid var(--slate-300);
  border-radius: 6px;
  background: repeating-conic-gradient(#334155 0 25%, #1e293b 0 50%) 0 0 / 10px 10px;
}
.layer-thumb img { width: 100%; height: 100%; object-fit: contain; }
.layer-thumb.is-large { width: 56px; height: 56px; }
.layer-card.is-active .layer-thumb { border: 2px solid var(--blue-600); }
.layer-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.layer-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-type { font-size: 10px; font-weight: 400; color: var(--slate-400); }
.layer-card.is-active .layer-select { color: var(--blue-600); font-weight: 700; }
.layer-card.is-hidden .layer-select { opacity: 0.45; }
.layer-actions { display: flex; align-items: center; gap: 8px; }
.layer-actions .icon-btn.is-off { opacity: 0.35; }

.cta-row { display: flex; flex-direction: column; gap: 10px; padding-top: 12px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 11px; color: var(--slate-600); }

.spinner, .color-bar {
  display: flex;
  align-items: center;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--slate-300);
  border-radius: 8px;
  background: var(--slate-50);
  font-size: 13px;
  font-weight: 700;
}
.spinner { justify-content: space-between; padding: 0 8px; }
.color-bar { gap: 8px; }
.color-bar input[type="color"] {
  width: 18px; height: 18px;
  padding: 0;
  border: 1px solid var(--slate-300);
  border-radius: 3px;
  background: none;
  cursor: pointer;
}
.color-bar input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-bar input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 2px; }
.color-bar input[type="color"]::-moz-color-swatch { border: 0; border-radius: 2px; }

.align-buttons {
  display: flex;
  height: 36px;
  overflow: hidden;
  border: 1px solid var(--slate-300);
  border-radius: 8px;
  background: var(--slate-50);
}
.align-buttons button {
  flex: 1 1 0;
  display: grid;
  place-items: center;
  border: 0;
  background: none;
  color: var(--slate-600);
}
.align-buttons button[aria-pressed="true"] { background: var(--blue-100); color: var(--blue-600); }

/* 状態で色が変わるアイコンは SVG をマスクにして currentColor で塗る */
.mask-icon {
  width: 14px; height: 14px;
  background: currentColor;
  mask: var(--icon) center / 14px 14px no-repeat;
}
.icon-align-left { --icon: url("../../images/icons/align-left.svg"); }
.icon-align-center { --icon: url("../../images/icons/align-center.svg"); }
.icon-align-right { --icon: url("../../images/icons/align-right.svg"); }
.icon-chevron-up { --icon: url("../../images/icons/chevron-up.svg"); }
.icon-chevron-down { --icon: url("../../images/icons/chevron-down.svg"); }
.layer-actions .icon-btn { color: var(--slate-400); }
.layer-card.is-active .layer-actions .icon-btn { color: var(--blue-600); }

#text-controls.is-disabled { opacity: 0.5; pointer-events: none; }

.text-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--slate-300);
  border-radius: 8px;
  background: var(--slate-50);
  font-size: 13px;
  font-weight: 700;
  resize: vertical;
}
.text-input:focus { outline: 0; border-color: var(--blue-600); }

.switch-row { display: flex; align-items: center; justify-content: space-between; cursor: pointer; }

/* STEP 5 */
.done-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--green-100);
  color: var(--green-500);
  font-size: 12px;
  font-weight: 700;
}

.download-card, .print-order-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  background: var(--slate-50);
}
.print-order-card { border-color: var(--blue-600); background: var(--blue-100); align-items: flex-start; }
.card-title { font-size: 14px; font-weight: 700; }
.card-title.is-strong { font-weight: 800; }
.card-text { font-size: 12px; color: var(--slate-600); }
.card-note { font-size: 11px; color: var(--slate-400); text-align: center; }
.badge-tag { padding: 2px 8px; border-radius: 4px; background: var(--blue-600); color: var(--white); font-size: 10px; font-weight: 700; }
.price-display { display: flex; align-items: baseline; gap: 4px; }
.price-label { font-size: 11px; color: var(--slate-600); }
.price { font-size: 22px; font-weight: 800; color: var(--blue-600); }
.price-note { font-size: 11px; color: var(--slate-400); }
.print-order-card .btn, .download-card .btn { padding: 12px; font-size: 14px; }

/* STEP 6 */
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend { padding: 0; }
.plan-options { display: flex; flex-direction: column; gap: 10px; }
.plan-options legend { margin-bottom: 10px; }
.plan-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--slate-300);
  border-radius: 12px;
  background: var(--white);
  cursor: pointer;
}
.plan-card:hover { border-color: var(--blue-600); }
.plan-card:has(:checked) { border-color: var(--blue-600); background: var(--blue-100); box-shadow: 0 0 0 1px var(--blue-600); }
.plan-card:has(:focus-visible) { outline: 2px solid var(--blue-600); outline-offset: 2px; }
.plan-radio { width: 18px; height: 18px; margin: 0; accent-color: var(--blue-600); flex-shrink: 0; }
.plan-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.plan-name { font-size: 14px; font-weight: 700; }
.plan-desc { font-size: 12px; color: var(--slate-600); }
.plan-price { font-size: 14px; font-weight: 800; color: var(--blue-600); white-space: nowrap; }

.print-options {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  border-radius: 12px;
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  animation: reveal 0.2s ease-out;
}
@keyframes reveal { from { opacity: 0; translate: 0 -6px; } }
.option-group legend { margin-bottom: 6px; }
.option-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.option-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 8px 12px;
  border: 1px solid var(--slate-300);
  border-radius: 8px;
  background: var(--white);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.option-chip input { position: absolute; opacity: 0; pointer-events: none; }
.option-chip small { font-size: 10px; font-weight: 400; color: var(--slate-400); }
.option-chip:has(:checked) { border-color: var(--blue-600); background: var(--blue-100); color: var(--blue-600); }
.option-chip:has(:focus-visible) { outline: 2px solid var(--blue-600); outline-offset: 2px; }
.quantity-spinner { width: 160px; }

.order-summary dl { margin: 0; display: flex; flex-direction: column; gap: 8px; }
.order-summary dl > div { display: flex; justify-content: space-between; font-size: 13px; }
.order-summary dt { color: var(--slate-600); }
.order-summary dd { margin: 0; font-weight: 700; }
.order-summary .summary-total { padding-top: 10px; border-top: 1px solid var(--slate-200); font-size: 15px; }
.order-summary .summary-total dd { font-size: 20px; font-weight: 800; color: var(--blue-600); }
.order-error { margin-top: 8px; font-size: 12px; font-weight: 700; color: #b91c1c; }
.order-error:empty { display: none; }
.order-note { font-size: 11px; color: var(--slate-600); line-height: 1.6; }

.bottom-actions { padding-top: 12px; }
.bottom-actions .btn { padding: 12px; }

/* 通知 */
.toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: 24px;
  translate: -50% 0;
  max-width: calc(100vw - 32px);
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--navy-900);
  color: var(--white);
  font-size: 13px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.toast.is-visible { opacity: 1; }
.toast.is-error { background: #b91c1c; }

/* ---------- 画面幅に応じた調整 ---------- */
@media (max-width: 1200px) {
  .save-status { display: none; }
  .step-label { display: none; }
  .step.is-current .step-label { display: inline; }
}

@media (max-width: 1024px) {
  .navbar { padding: 0 16px; }
  .brand-name { display: none; }
  .navbar { gap: 8px; }
  .nav-btn { padding: 6px 8px; font-size: 11px; }
  .screen-templates { padding: 24px 16px 32px; }
  .controls-group, .search-bar { width: 100%; }
  .search-bar { flex: 1; width: auto; }

  .workspace { flex-direction: column; height: auto; }
  .center-stage { flex: none; padding: 16px; }
  .poster-frame { --poster-h: min(560px, 70dvh); }
  .poster-finished { height: min(560px, 70dvh); }
  .sidebar,
  .props-panel,
  .layers-panel { width: 100%; padding: 16px; border-left: 0; border-right: 0; border-top: 1px solid var(--slate-300); overflow: visible; }
  /* 縦に並べるときは キャンバス → 操作パネル → レイヤー一覧 の順 */
  .props-panel { order: 1; }
  .layers-panel { order: 2; }
  body[data-step="2"] .poster-frame { --poster-h: min(560px, 70dvh); }
}

@media (max-width: 480px) {
  /* テンプレートは2列にして、完成イメージを見比べやすくする */
  .template-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .template-card .card-info { padding: 8px; gap: 8px; }
  .template-card .card-name { font-size: 12px; }
  .template-card .tag-row { flex-wrap: wrap; }
  .brand { display: none; }
  .label-long { display: none; }
  .label-short { display: inline; }
  .step-label, .step.is-current .step-label, .step-chevron { display: none; }
  .steps-list { gap: 8px; }
  .poster-frame,
  body[data-step="2"] .poster-frame { --poster-h: min(480px, calc((100vw - 32px) * 1.414)); }
  .poster-finished { height: min(480px, calc((100vw - 32px) * 1.414)); }
}

/* ---------- 決済完了ページ（success.php） ---------- */
.result-page { background: var(--slate-50); }
a.brand { color: inherit; text-decoration: none; }
.result-main { display: flex; justify-content: center; padding: 48px 16px; }
.result-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  width: 100%;
  max-width: 560px;
  padding: 32px;
  border: 1px solid var(--slate-200);
  border-radius: 16px;
  background: var(--white);
}
.result-card .btn { width: auto; padding: 12px 20px; }
.test-note { padding: 6px 10px; border-radius: 6px; background: #fef3c7; color: #92400e; font-size: 12px; font-weight: 700; }
.result-summary { width: 100%; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.result-summary > div { display: flex; justify-content: space-between; gap: 16px; font-size: 13px; }
.result-summary dt { color: var(--slate-600); }
.result-summary dd { margin: 0; font-weight: 700; white-space: nowrap; }
.result-summary .summary-total { padding-top: 10px; border-top: 1px solid var(--slate-200); font-size: 15px; }
.result-summary .summary-total dd { font-size: 20px; font-weight: 800; color: var(--blue-600); }
.result-text { font-size: 14px; line-height: 1.7; }
.result-text.is-muted { font-size: 12px; color: var(--slate-600); }
