:root {
  --bg: #0d0d1a;
  --surface: #15152a;
  --surface-2: #1c1c34;
  --line: #2a2a46;
  --accent: #7c3aed;
  --accent-soft: rgba(124, 58, 237, 0.16);
  --text: #e9e9f5;
  --muted: #9a9ab8;
  --danger: #f87171;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans JP", system-ui, sans-serif;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

.wrap { width: min(1080px, calc(100% - 2.5rem)); margin-inline: auto; }

.site-head {
  border-bottom: 1px solid var(--line);
  background: rgba(13, 13, 26, 0.9);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10;
}
.head-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 0.9rem 0;
}
.brand { display: flex; align-items: center; gap: 0.6rem; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 7px;
  background: linear-gradient(140deg, var(--accent), #4f46e5);
  box-shadow: 0 0 18px var(--accent-soft);
}
.brand-name { font-weight: 700; letter-spacing: 0.02em; }
.badge {
  font-size: 0.75rem; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 0.15rem 0.7rem; white-space: nowrap;
}

.hero { padding: 3.5rem 0 2.25rem; }
.hero h1 {
  font-size: clamp(1.75rem, 5vw, 2.9rem);
  line-height: 1.3; margin: 0 0 1rem; letter-spacing: -0.01em;
}
.lead { color: var(--muted); max-width: 46rem; margin: 0; }
.lead strong { color: var(--text); }
.sp-br { display: none; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(1.25rem, 3vw, 2rem);
  margin-bottom: 2rem;
}

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(1.25rem, 3vw, 2.25rem); }
.col { min-width: 0; display: flex; flex-direction: column; }

.field-label {
  font-size: 0.85rem; font-weight: 500; color: var(--muted);
  margin-bottom: 0.5rem;
}

.drop {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  aspect-ratio: 3 / 4;
  display: grid; place-items: center;
  cursor: pointer; overflow: hidden;
  transition: border-color 0.15s, background 0.15s;
}
.drop:hover, .drop:focus-visible, .drop.over {
  border-color: var(--accent); background: var(--accent-soft); outline: none;
}
.drop img { width: 100%; height: 100%; object-fit: contain; }
.drop-empty {
  display: grid; justify-items: center; gap: 0.35rem;
  color: var(--muted); text-align: center; padding: 1rem;
}
.drop-icon {
  width: 34px; height: 34px; border-radius: 9px;
  border: 2px solid var(--muted); opacity: 0.55;
}
.drop-text { font-size: 0.9rem; }
.drop-hint { font-size: 0.78rem; opacity: 0.7; }

.tips {
  font-size: 0.8rem; color: var(--muted);
  background: var(--surface-2); border-radius: 10px;
  padding: 0.7rem 0.85rem; margin: 0.9rem 0 0;
}
.tips strong { color: var(--text); }

input[type="text"] {
  width: 100%; padding: 0.7rem 0.85rem;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  font: inherit; font-size: 0.95rem;
}
input[type="text"]:focus { outline: 2px solid var(--accent); border-color: transparent; }

.btn-primary {
  display: block; width: 100%; margin-top: 1.1rem;
  padding: 0.85rem 1.2rem;
  background: var(--accent); color: #fff;
  border: none; border-radius: 11px;
  font: inherit; font-weight: 700; font-size: 1rem;
  cursor: pointer; text-align: center; text-decoration: none;
  transition: filter 0.15s, opacity 0.15s;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.12); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-ghost {
  display: block; width: 100%; margin-top: 0.6rem;
  padding: 0.7rem 1rem; background: transparent;
  color: var(--muted); border: 1px solid var(--line);
  border-radius: 11px; font: inherit; cursor: pointer;
}
.btn-ghost:hover { color: var(--text); border-color: var(--accent); }

.status { margin-top: 1.1rem; }
.bar {
  height: 7px; background: var(--surface-2);
  border-radius: 999px; overflow: hidden;
}
.bar-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent), #a78bfa);
  border-radius: 999px; transition: width 0.5s ease;
}
.stage { margin: 0.6rem 0 0; font-size: 0.9rem; font-weight: 500; }
.stage-note, .limit, .note {
  margin: 0.3rem 0 0; font-size: 0.78rem; color: var(--muted);
}
.limit { margin-top: auto; padding-top: 1rem; }

.error {
  margin: 0.9rem 0 0; padding: 0.7rem 0.85rem;
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.35);
  border-radius: 10px; color: var(--danger); font-size: 0.88rem;
}

.result h2, .how h2 { font-size: 1.25rem; margin: 0 0 1.2rem; }
.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.75rem; }
.viewer {
  aspect-ratio: 3 / 4; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; touch-action: none;
}
.viewer canvas { display: block; width: 100%; height: 100%; }
.result-info { display: flex; flex-direction: column; }
.result-info dl {
  margin: 0 0 1rem; display: grid;
  grid-template-columns: auto 1fr; gap: 0.4rem 1rem;
  font-size: 0.88rem;
}
.result-info dt { color: var(--muted); }
.result-info dd { margin: 0; }

.how { padding-bottom: 3rem; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.9rem; }
.steps li {
  display: flex; gap: 0.9rem; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 0.9rem 1.1rem;
}
.step-n {
  flex: none; width: 26px; height: 26px; border-radius: 8px;
  background: var(--accent-soft); color: #c4b5fd;
  display: grid; place-items: center;
  font-size: 0.8rem; font-weight: 700;
}
.steps b { font-size: 0.95rem; }
.steps p { margin: 0.15rem 0 0; font-size: 0.85rem; color: var(--muted); }

.site-foot {
  border-top: 1px solid var(--line); padding: 1.5rem 0;
  color: var(--muted); font-size: 0.82rem;
}
.site-foot p { margin: 0; }

@media (max-width: 760px) {
  .grid, .result-grid { grid-template-columns: 1fr; }
  .sp-br { display: inline; }
  .hero { padding: 2.5rem 0 1.75rem; }
  .drop { aspect-ratio: 1 / 1; }
  .limit { padding-top: 0.75rem; }
}

/* --- 入力スロット（正面＋任意3面） --- */
.slots {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  grid-template-rows: repeat(3, 1fr);
  gap: 0.6rem;
}
/* The main slot's aspect ratio sets the block height; the three optional
   slots divide that same height so the two columns stay level. */
.slot-main { grid-row: 1 / 4; }
.slot { min-height: 0; }
.slot-main .drop { aspect-ratio: 3 / 4; }
.slot .drop { aspect-ratio: auto; height: 100%; min-height: 0; }
.slot .drop-text { font-size: 0.85rem; font-weight: 500; }
.slot .drop-hint { font-size: 0.7rem; }
.slot-main .drop-text { font-size: 1rem; }

/* --- つくったアバター一覧 --- */
.gallery { padding-bottom: 1rem; }
.gallery h2 { font-size: 1.25rem; margin: 0 0 1.2rem; }
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.9rem;
}
.card {
  display: block; width: 100%; padding: 0; text-align: left;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden; cursor: pointer;
  font: inherit; color: inherit;
  transition: border-color 0.15s, transform 0.15s;
}
.card:hover, .card:focus-visible {
  border-color: var(--accent); transform: translateY(-2px); outline: none;
}
.card-thumb {
  width: 100%; aspect-ratio: 3 / 4; background: var(--surface-2);
  display: grid; place-items: center; overflow: hidden;
}
.card-thumb img { width: 100%; height: 100%; object-fit: contain; }
.card-thumb .no-thumb { color: var(--muted); font-size: 0.75rem; }
.card-body { padding: 0.6rem 0.75rem 0.75rem; }
.card-name {
  font-size: 0.9rem; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-meta {
  margin-top: 0.2rem; font-size: 0.72rem; color: var(--muted);
  display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap;
}
.tag {
  border: 1px solid var(--line); border-radius: 999px;
  padding: 0 0.45rem; font-size: 0.68rem;
}
.tag-multi { border-color: var(--accent); color: #c4b5fd; }

@media (max-width: 760px) {
  .slots { grid-template-columns: 1.4fr 1fr; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}

/* --- モーション切替 --- */
.motions {
  display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1rem;
}
.motion {
  padding: 0.35rem 0.8rem;
  background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px;
  font: inherit; font-size: 0.82rem; cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.motion:hover { color: var(--text); border-color: var(--accent); }
.motion.is-on {
  background: var(--accent-soft); border-color: var(--accent); color: #c4b5fd;
}

/* --- 作り方の切替 --- */
.modes {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem;
  margin-bottom: clamp(1.25rem, 3vw, 1.75rem);
}
.mode {
  display: grid; gap: 0.15rem; text-align: left;
  padding: 0.8rem 1rem;
  background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--line); border-radius: 12px;
  font: inherit; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.mode:hover { border-color: var(--accent); }
.mode.is-on { background: var(--accent-soft); border-color: var(--accent); }
.mode-name { font-size: 0.95rem; font-weight: 700; color: var(--text); }
.mode.is-on .mode-name { color: #c4b5fd; }
.mode-desc { font-size: 0.76rem; line-height: 1.5; }

@media (max-width: 560px) { .modes { grid-template-columns: 1fr; } }
