:root {
  --bg: #f5f3fb;
  --surface: #ffffff;
  --surface-2: #ece9f6;
  --ink: #23212b;
  --ink-2: #5d5a69;
  --line: #ddd9ea;
  --accent: #5a63c8;
  --accent-text: #444db0;
  --accent-ink: #ffffff;
  --accent-soft: #e4e6fa;
  --warm: #b8862f;
  --shadow: 0 1px 2px rgb(40 35 70 / 6%), 0 6px 20px rgb(40 35 70 / 8%);
  --radius: 18px;
  --font-round: 'Zen Maru Gothic', system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16151c;
    --surface: #211f2a;
    --surface-2: #2b2936;
    --ink: #eeecf5;
    --ink-2: #aaa6b8;
    --line: #37344a;
    --accent: #8d95ef;
    --accent-text: #a9b0f5;
    --accent-ink: #14152b;
    --accent-soft: #2d3057;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 6px 20px rgb(0 0 0 / 30%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, 'Hiragino Sans', 'Noto Sans JP', sans-serif; line-height: 1.6;
  min-height: 100dvh; padding-bottom: env(safe-area-inset-bottom);
}
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
a { color: var(--accent-text); }
main { max-width: 560px; margin: 0 auto; padding: 0 16px 32px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ヘッダー */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px; padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top)); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); }
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font: 700 18px/1 var(--font-round); }
.icon-btn { display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); cursor: pointer; }

/* 共通 */
.card { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 12px 20px;
  border-radius: 99px; border: 1.5px solid transparent; font: inherit; font-weight: 700; font-size: 16px; text-decoration: none; cursor: pointer;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-xl { min-height: 60px; font-size: 18px; width: 100%; }
.btn-sm { min-height: 44px; padding: 8px 16px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn:focus-visible, .style-card:focus-within, .seg label:focus-within { outline: 3px solid color-mix(in srgb, var(--accent) 50%, transparent); outline-offset: 2px; }

/* 最初の画面 */
.home-title { margin: 14px 0 8px; text-align: center; font: 700 clamp(24px, 7vw, 30px)/1.35 var(--font-round); }
.lead { margin: 0 0 16px; color: var(--ink-2); text-align: center; font-size: 15px; }
.step-title { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font: 700 16px/1.4 var(--font-round); }
.step-title b { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 14px; }
.photo-pick { border-radius: 14px; overflow: hidden; background: var(--surface-2); margin-bottom: 10px; }
.photo-pick img { width: 100%; max-height: 360px; object-fit: contain; background: var(--surface-2); }
.photo-empty { display: grid; justify-items: center; gap: 6px; padding: 28px 12px; color: var(--ink-2); font-size: 14px; }
.pick-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.photo-note { margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: var(--accent-soft); font-size: 13px; }
.photo-note p { margin: 0; }
.photo-note p + p { margin-top: 6px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.seg input, .styles input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 12px; border-radius: 12px; border: 1.5px solid var(--line); text-align: center; font-weight: 700; cursor: pointer; }
.seg input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.styles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.style-card { display: grid; gap: 2px; padding: 12px; min-height: 64px; border-radius: 12px; border: 1.5px solid var(--line); cursor: pointer; }
.style-card b { font-size: 15px; }
.style-card small { color: var(--ink-2); font-size: 12px; }
.style-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.style-card:has(input:checked) b { color: var(--accent-text); }
.field { display: grid; gap: 6px; margin-top: 10px; font-weight: 700; font-size: 14px; }
.field small { color: var(--ink-2); font-weight: 400; }
.field textarea, .field select { width: 100%; font: inherit; font-weight: 400; padding: 10px 12px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); }
.run { margin-top: 6px; }
.quota-note { margin: 8px 0 0; text-align: center; font-size: 13px; color: var(--ink-2); }
.send-note { margin: 10px 0 0; font-size: 12px; color: var(--ink-2); }

/* 作っている間 */
.loading-photo { margin: 12px 0; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); }
.loading-photo img { width: 100%; max-height: 360px; object-fit: contain; opacity: .85; }
.progress-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.progress-head span { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.steps { margin: 0 0 8px; padding-left: 1.3em; display: grid; gap: 6px; color: var(--ink-2); }
.steps li.active { color: var(--ink); font-weight: 700; }
.steps li.done { color: var(--accent-text); }
.steps li.done::after { content: ' ✓'; }
.progress-note { margin: 0; font-size: 13px; color: var(--ink-2); }

/* 結果 */
/* 前と後の比較スライダー（おかたづけと同じ） */
.compare {
  margin: 0; position: relative; border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); background: var(--surface-2); touch-action: pan-y;
  --pos: 50%;
}
.compare > img { width: 100%; max-height: 72vh; object-fit: contain; }
.compare-before { position: absolute; inset: 0; clip-path: inset(0 calc(100% - var(--pos)) 0 0); background: var(--surface-2); }
.compare-before img { width: 100%; height: 100%; object-fit: contain; }
.compare-label {
  position: absolute; top: 10px; font-size: 12px; font-weight: 700;
  background: rgb(0 0 0 / 55%); color: #fff; padding: 2px 10px; border-radius: 99px; pointer-events: none;
  transition: opacity .15s ease;
}
.compare-label.gone, .compare-before.gone { opacity: 0; visibility: hidden; }
.compare-label.left { left: 10px; }
.compare-label.right { right: 10px; background: var(--accent); color: var(--accent-ink); }
.compare-handle {
  position: absolute; top: 0; bottom: 0; left: var(--pos); width: 3px; margin-left: -1.5px;
  background: #fff; pointer-events: none; box-shadow: 0 0 8px rgb(0 0 0 / 30%);
}
.compare-handle span {
  position: absolute; top: 50%; left: 50%; width: 40px; height: 40px; margin: -20px 0 0 -20px;
  border-radius: 50%; background: #fff; box-shadow: var(--shadow);
}
.compare-handle span::before {
  content: '‹ ›'; position: absolute; inset: 0; display: grid; place-items: center;
  color: #2a2723; font-weight: 700; letter-spacing: 2px;
}
.compare input[type='range'] {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: ew-resize;
}
.compare.pending > img { filter: blur(6px) saturate(.6) brightness(.85); transform: scale(1.04); }
.compare.pending .compare-before, .compare.pending .compare-handle, .compare.pending .compare-label,
.compare.pending input[type='range'] { display: none; }

/* 着せ替え後の画像の番号ピン：アイテムに重ねず外に置き、点と線でアイテムを指す */
.pins { position: absolute; inset: 0; pointer-events: none; }
.pins.off { display: none; }
.pin {
  position: absolute; transform: translate(-50%, -50%);
  width: 32px; height: 32px; border-radius: 50%; padding: 0;
  display: grid; place-items: center; cursor: pointer; pointer-events: auto;
  background: var(--accent); color: var(--accent-ink); border: 2px solid #fff;
  font: 700 15px/1 var(--font-round);
  box-shadow: 0 2px 8px rgb(0 0 0 / 35%);
  transition: opacity .15s ease, transform .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.pin::after {
  content: ''; position: absolute; inset: -6px; border-radius: 50%;
  border: 2px solid #fff; opacity: .7; animation: ping 2s ease-out infinite;
}
.pin:active { transform: translate(-50%, -50%) scale(.92); }
.pin:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
@keyframes ping { 0% { transform: scale(.8); opacity: .7; } 100% { transform: scale(1.4); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .pin::after { animation: none; } }
.pin-lines { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.pin-lines .pin-line-shadow { stroke: rgb(0 0 0 / 35%); stroke-width: 4; stroke-linecap: round; }
.pin-lines .pin-line { stroke: #fff; stroke-width: 2; stroke-linecap: round; }
.pins .pin-dot {
  position: absolute; width: 10px; height: 10px; transform: translate(-50%, -50%); border-radius: 50%; box-sizing: border-box;
  background: var(--accent); border: 2px solid #fff; box-shadow: 0 0 0 1px rgb(0 0 0 / 25%); pointer-events: none;
}
.pins [data-x].covered { opacity: 0; }
.pins .pin.covered { pointer-events: none; }
.pins-toggle {
  position: absolute; right: 10px; bottom: 10px; z-index: 2;
  display: inline-flex; align-items: center; gap: 5px; padding: 6px 12px 6px 10px;
  border: 0; border-radius: 99px; background: rgb(0 0 0 / 30%); color: rgb(255 255 255 / 85%);
  font: 700 12px/1 var(--font-round, inherit); cursor: pointer; -webkit-tap-highlight-color: transparent;
  backdrop-filter: blur(2px); opacity: .75; transition: opacity .15s ease;
}
.pins-toggle:hover, .pins-toggle:active, .pins-toggle:focus-visible { opacity: 1; }
.pins-toggle .eye-off { display: none; }
.pins-toggle[aria-pressed='true'] .eye-off { display: inline; }
.pins-toggle:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

/* 着せ替えたイメージを作っている間・作れなかったときの表示 */
.img-status {
  position: absolute; inset: 0; z-index: 3;
  display: grid; place-content: center; justify-items: center; gap: 8px; padding: 20px;
  text-align: center; color: #fff;
  background: linear-gradient(180deg, rgb(0 0 0 / 15%), rgb(0 0 0 / 45%));
}
.img-status b { font-size: 16px; font-family: var(--font-round); text-shadow: 0 1px 4px rgb(0 0 0 / 40%); }
.img-status span:not(.img-spinner) { font-size: 12px; line-height: 1.6; max-width: 26em; text-shadow: 0 1px 3px rgb(0 0 0 / 50%); font-variant-numeric: tabular-nums; }
.img-spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid rgb(255 255 255 / 35%); border-top-color: #fff;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.img-status[data-state='failed'] .img-spinner { display: none; }
.img-status .btn { margin-top: 4px; width: auto; }
@media (prefers-reduced-motion: reduce) { .img-spinner { animation-duration: 2.5s; } }

/* 着せ替え後／比べる／元の写真 */
.view-toggle {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px;
  margin: 10px 0 0; border-radius: 99px; background: var(--surface-2);
}
.view-toggle button {
  min-height: 38px; border: 0; border-radius: 99px; background: transparent; color: var(--ink-2);
  font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
}
.view-toggle button[aria-pressed='true'] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.view-toggle button:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); }
#pinHint { display: block; color: var(--accent-text); font-weight: 700; }
#pinHint[hidden] { display: none; }

/* 番号から移動した先の商品を光らせる */
.item-block { scroll-margin-top: 72px; }
.item-block.flash { animation: flash 1.4s ease; }
@keyframes flash {
  0%, 40% { box-shadow: 0 0 0 3px var(--accent), var(--shadow); }
  100% { box-shadow: var(--shadow); }
}
.outfit-list a.outfit-row { color: inherit; text-decoration: none; }
.image-note { margin: 8px 0; font-size: 12px; color: var(--ink-2); }
.result-actions { display: flex; gap: 8px; margin-bottom: 12px; }
.eyebrow { margin: 0 0 6px; font-size: 12px; font-weight: 700; color: var(--accent-text); }
.summary { margin: 0 0 12px; font-size: 15px; }
.section-title { margin: 18px 0 10px; font: 700 18px/1.4 var(--font-round); }
.card .section-title { margin-top: 0; }
.outfit-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.outfit-list .outfit-row { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 12px; background: var(--surface-2); }
.no { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font: 700 13px/1 var(--font-round); flex: none; }
.outfit-body { display: grid; min-width: 0; }
.outfit-body small { color: var(--ink-2); font-size: 12px; }
.outfit-price { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.total { display: flex; justify-content: space-between; align-items: baseline; margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line); }
.total strong { font-size: 22px; }
.pr-note, .size-note { margin: 0 0 10px; font-size: 12px; color: var(--ink-2); }
.pr-note span { display: inline-block; margin-right: 6px; padding: 0 6px; border-radius: 4px; border: 1px solid var(--ink-2); font-weight: 700; }
.item-block h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 16px; }
.offers { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.offer { display: grid; grid-template-columns: 76px 1fr; gap: 10px; align-items: center; padding: 8px; border-radius: 12px; background: var(--surface-2); color: var(--ink); text-decoration: none; }
.offer img { width: 76px; height: 76px; object-fit: cover; border-radius: 8px; background: var(--surface); }
.offer-body { display: grid; gap: 2px; min-width: 0; }
.offer-title { font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; }
.offer-meta { font-size: 13px; color: var(--ink-2); }
.offer-go { font-size: 13px; font-weight: 700; color: var(--accent-text); }
.search-links { margin: 10px 0 0; font-size: 13px; color: var(--ink-2); }
.search-links a { display: inline-block; margin-right: 6px; padding: 4px 0; font-weight: 700; }
.empty { margin: 0; font-size: 14px; color: var(--ink-2); }
.fineprint { font-size: 11px; color: var(--ink-2); }
#againBtn { width: 100%; margin-top: 8px; }

/* フッター・トースト */
.site-footer { padding: 24px 16px 32px; text-align: center; font-size: 13px; color: var(--ink-2); }
.site-footer p { margin: 6px 0; }
.sister { padding: 12px; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); max-width: 360px; margin: 0 auto 14px !important; }
.sister a { font-weight: 700; }
.copy { font-size: 12px; }
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 20; max-width: 520px; margin: 0 auto; padding: 12px 16px; border-radius: 14px; background: var(--ink); color: var(--bg); font-size: 14px; box-shadow: var(--shadow); }

/* 利用規約・プライバシーポリシー */
.doc { line-height: 1.85; font-size: 15px; }
.doc h1 { font: 700 24px/1.4 var(--font-round); margin: 8px 0 4px; }
.doc h2 { font-size: 17px; margin: 28px 0 8px; padding-left: 10px; border-left: 4px solid var(--accent); }
.doc ul { padding-left: 1.4em; margin: 8px 0; }
.doc-meta { color: var(--ink-2); font-size: 13px; }
.table-wrap { overflow-x: auto; }
.doc-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.doc-table th, .doc-table td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.doc-contact { padding: 12px; border-radius: 12px; background: var(--surface); }
.doc-links { margin-top: 24px; }

/* トップの見本（ビフォー／アフター） */
.hero-compare { max-width: 320px; margin: 14px auto 0; }
.hero-compare > img { max-height: none; height: auto; }
.hero-note { margin: 8px 0 16px; text-align: center; font-size: 12px; color: var(--ink-2); line-height: 1.6; }

/* 写っている範囲・部位の選択 */
.sub-title { margin: 14px 0 8px; font-size: 14px; font-weight: 700; }
.shot-pick[hidden], .part-pick[hidden] { display: none; }
.parts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.parts input { position: absolute; opacity: 0; pointer-events: none; }
.parts span { display: grid; gap: 2px; height: 100%; box-sizing: border-box; padding: 10px 12px; border-radius: 12px; border: 1.5px solid var(--line); cursor: pointer; }
.parts small { color: var(--ink-2); font-size: 11px; line-height: 1.4; }
.parts input:checked + span { border-color: var(--accent); background: var(--accent-soft); }
.parts input:checked + span b { color: var(--accent-text); }
.parts label:focus-within span { outline: 3px solid color-mix(in srgb, var(--accent) 50%, transparent); outline-offset: 2px; }

/* コーデの内訳の「選んだ理由」 */
.outfit-reason { color: var(--ink-2); font-size: 12px; line-height: 1.5; }

/* 姉妹アプリ「おかたづけ」へのボタン */
.sister-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 56px;
  margin: 0 auto 14px; max-width: 420px; padding: 12px 18px; box-sizing: border-box;
  border-radius: 16px; background: #23805f; color: #fff; text-decoration: none;
  font: 700 15px/1.4 var(--font-round); box-shadow: var(--shadow);
}
.sister-btn > span:first-child { font-size: 24px; }
.sister-btn small { display: block; font-size: 12px; font-weight: 500; opacity: .92; }
.sister-btn:hover { filter: brightness(1.05); }
.sister-btn:focus-visible { outline: 3px solid color-mix(in srgb, #23805f 45%, transparent); outline-offset: 3px; }

/* 着せ替え前・後を共有／この結果はどうでしたか？（おかたづけと同じ） */
.block { display: grid; gap: 10px; margin-top: 16px; }
.block h2 { margin: 0; font: 700 18px/1.4 var(--font-round); }
.block-help { margin: 0; font-size: 13px; color: var(--ink-2); line-height: 1.6; }
.seg-2 { grid-template-columns: 1fr 1fr; }
.seg-2 span { font-size: 13px; padding: 10px 4px; }
.share-preview { margin: 0; text-align: center; }
.share-preview img { max-height: 60dvh; width: auto; max-width: 100%; margin: 0 auto; border-radius: 12px; border: 1px solid var(--line); }
.share-preview.story img { max-height: 70dvh; }
.share-help { color: var(--accent-text); font-weight: 600; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions .btn { width: 100%; padding-inline: 8px; font-size: 14px; white-space: nowrap; }
.is-disabled { opacity: .45; pointer-events: none; }
#againBtn { margin-top: 16px; }
.fb-body { display: grid; gap: 10px; }
.fb-body[hidden], .fb-thanks[hidden] { display: none; }
.rating { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rating button {
  display: grid; justify-items: center; gap: 4px; padding: 10px 4px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
}
.rating button span { font-size: 24px; line-height: 1; }
.rating button[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.rating button:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); }
.feedback-card textarea {
  width: 100%; box-sizing: border-box; padding: 10px 12px; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 15px; resize: vertical;
}
.feedback-card textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.fb-thanks { margin: 0; padding: 12px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-text); font-weight: 700; text-align: center; }
.share-preview-note { padding: 14px; border-radius: 12px; background: var(--surface-2); text-align: center; }
.share-preview-note[hidden] { display: none; }
