/* Wallet 名刺メーカー — ahwenu.com の喫茶店トーン（styles.css の配色トークンを踏襲） */
:root {
  --paper: #f6efe3; --paper-2: #efe4d2; --card: #fffaf2;
  --espresso: #3a1d10; --roast: #5b3421; --ink: #2b1a12; --ink-soft: #6e5647;
  --latte: #c89b6d; --latte-ink: #8d5f33; --crema: #e3c9a4; --line: #dccab2; --coffee: #7a4524;
  --bad: #b3261e;
  --radius: 18px;
  --serif: "Shippori Mincho", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --display: "Playfair Display", "Shippori Mincho", serif;
  --sans: "Zen Kaku Gothic New", "Hiragino Sans", system-ui, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --paper: #1b120d; --paper-2: #2a1c15; --card: #241812;
  --espresso: #f1dfc7; --roast: #e0c3a0; --ink: #eadccb; --ink-soft: #bda794;
  --latte-ink: #d9a86f; --crema: #6b4a33; --line: #4a3527; --coffee: #c98a50; --bad: #ff8a7e;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body, button, label, input, select { touch-action: manipulation; } /* 「次へ」の連打で iOS がダブルタップ拡大しないように（ピンチは生きる） */
body {
  margin: 0; color: var(--ink); font-family: var(--sans); line-height: 1.8; background-color: var(--paper);
  background-image: radial-gradient(#3a1d1008 1px, transparent 1px), radial-gradient(#3a1d1006 1px, transparent 1px);
  background-size: 22px 22px, 31px 31px; background-position: 0 0, 11px 17px;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; }
.wrap { width: min(1040px, 100% - 32px); margin-inline: auto; }

.top { display: flex; align-items: center; justify-content: space-between; padding: max(14px, env(safe-area-inset-top)) 0 0; }
.top .back { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; font-size: 14px; color: var(--ink-soft); }
.top .back:hover { color: var(--espresso); }
.cup-toggle {
  width: 40px; height: 40px; display: grid; place-items: center; cursor: pointer; padding: 0;
  border: 1px solid var(--line); border-radius: 50%; background: var(--card); color: var(--espresso);
}
.cup-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.section-title { text-align: center; margin: 36px 0 28px; }
.section-title .en { font-family: var(--display); font-style: italic; color: var(--latte-ink); font-size: 17px; letter-spacing: 0.1em; display: block; }
.section-title h1 { font-family: var(--serif); font-size: clamp(26px, 3.6vw, 36px); margin: 4px 0 8px; color: var(--espresso); }
.section-title p { margin: 0 auto; max-width: 620px; color: var(--ink-soft); }

.maker { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 28px; align-items: start; }
.maker > * { min-width: 0; } /* 横スクロールの .steps の中身で列が広がらないように */
.steps, .steps .step, .field input, .field select { min-width: 0; }
@media (max-width: 860px) { .maker { grid-template-columns: 1fr; } .preview-col { order: -1; } }

.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px 26px;
  box-shadow: 0 1px 0 #fff inset, 0 18px 40px -28px #3a1d1040;
}
.panel h2 { font-family: var(--serif); font-size: 18px; color: var(--espresso); margin: 0 0 14px; }
.field { display: grid; gap: 4px; margin-bottom: 14px; }
.field > span { font-size: 13px; font-weight: 700; color: var(--ink-soft); letter-spacing: 0.04em; }
.field > span b { display: inline-block; font-size: 11px; line-height: 1.5; padding: 0 7px; border-radius: 999px; background: var(--bad); color: #fff; font-weight: 700; margin-left: 6px; vertical-align: 1px; letter-spacing: .04em; }
.field.req input, .field.req select { border-left: 3px solid var(--bad); }
.field.req.filled input, .field.req.filled select { border-left-color: var(--line); } /* 入ったら通常に戻す */
.field input[type="text"], .field input[type="url"], .field input[type="email"], .field select {
  font: inherit; font-size: 16px; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; width: 100%;
}
.field input:focus-visible, .field select:focus-visible, .swatch input:focus-visible + i { outline: 2px solid var(--latte-ink); outline-offset: 2px; }
.field small { color: var(--ink-soft); font-size: 12px; line-height: 1.5; }
.field.invalid input { border-color: var(--bad); }
.field .err { color: var(--bad); font-size: 12px; display: none; }
.field.invalid .err { display: block; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 480px) { .row2 { grid-template-columns: 1fr; } }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { position: relative; cursor: pointer; display: grid; gap: 4px; justify-items: center; font-size: 12px; color: var(--ink-soft); }
.swatch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.swatch i { display: block; width: 44px; height: 30px; border-radius: 8px; border: 2px solid transparent; box-shadow: 0 0 0 1px var(--line); position: relative; overflow: hidden; }
.swatch i::after { content: ""; position: absolute; left: 8px; right: 18px; top: 10px; height: 3px; border-radius: 2px; background: var(--sw-fg); opacity: .9; }
.swatch input:checked + i { border-color: var(--espresso); box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--espresso); }

.check { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; margin: 6px 0 18px; }
.check input { margin-top: 6px; }
.check small { display: block; font-size: 12px; color: var(--ink-soft); }

.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 700; font-size: 15px; font-family: inherit;
  padding: 10px 20px; border-radius: 999px; transition: transform .15s ease, background .15s ease; border: 0; cursor: pointer;
}
.btn:hover { transform: translateY(-1px); }
.btn.primary { background: var(--espresso); color: var(--paper); }
.btn.primary:hover { background: var(--roast); }
:root[data-theme="dark"] .btn.primary { background: var(--crema); color: #fff6ea; }
.btn.ghost { border: 1px solid var(--line); background: transparent; color: var(--espresso); }
.btn.wallet { background: #000; color: #fff; padding: 11px 22px; }
.btn.wallet:hover { background: #222; }
.btn.wallet svg { width: 22px; height: 22px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }
.note { font-size: 13px; color: var(--ink-soft); margin: 14px 0 0; }
.note.device { display: none; padding: 12px 14px; border-radius: 12px; background: var(--paper-2); }
.note.device.show { display: flow-root; } /* flow-root で右に浮かせた QR も箱の中に収める（下の余白も付く） */
.note.device .pageqr { float: right; width: 84px; height: 84px; margin: 0 0 6px 12px; background: #fff; padding: 4px; border-radius: 8px; }
.note.device .pageqr svg { width: 100%; height: 100%; display: block; }

/* Wallet 風プレビュー */
.preview-col { position: sticky; top: 16px; }
.pv-tabs { display: flex; gap: 6px; justify-content: center; margin-bottom: 12px; }
.pv-tabs button { font: inherit; font-size: 13px; font-weight: 700; padding: 5px 14px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--ink-soft); cursor: pointer; }
.pv-tabs button[aria-selected="true"] { background: var(--espresso); color: var(--paper); border-color: var(--espresso); }
.pass {
  --pbg: #3a1d10; --pfg: #f6efe3; --plabel: #e3c9a4;
  width: 100%; max-width: 340px; margin: 0 auto; border-radius: 14px; background: var(--pbg); color: var(--pfg);
  padding: 0 0 20px; box-shadow: 0 24px 50px -24px #0009, 0 0 0 1px #0002; font-family: -apple-system, "Hiragino Sans", var(--sans); line-height: 1.3;
  min-height: 430px; position: relative; overflow: hidden;
}
.pass .lbl { font-size: 10px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--plabel); }
.pass .hdr { display: flex; align-items: center; gap: 8px; min-height: 30px; padding: 12px 16px 8px; }
.pass .hdr svg { width: 26px; height: 26px; stroke: var(--pfg); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.pass .hdr .org { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pass .strip { display: block; width: 100%; height: auto; aspect-ratio: 375 / 144; }
.pass .sec { display: flex; gap: 22px; margin-top: 14px; padding: 0 16px; }
.pass .sec .v { font-size: 15px; }
.pass .qr { margin: 22px auto 0; width: 150px; background: #fff; border-radius: 10px; padding: 8px; }
.pass .qr svg { display: block; width: 100%; height: auto; }
.pass .alt { text-align: center; font-size: 11px; margin-top: 6px; color: var(--pfg); opacity: .85; word-break: break-all; padding: 0 16px; }
.pass.back { display: block; background: #f2f2f7; color: #1c1c1e; padding: 4px 16px 16px; min-height: 430px; }
.pass.back[hidden] { display: none; }
.pass.back .bf { padding: 12px 0; border-bottom: 1px solid #d1d1d6; }
.pass.back .bf:last-child { border-bottom: 0; }
.pass.back .bf .lbl { color: #6c6c70; }
.pass.back .bf .v { font-size: 15px; word-break: break-all; white-space: pre-line; }
.pass.back .bf .v.link { color: #0a60ff; }
.pass.back .bf.made .v { font-size: 13px; color: #3a3a3c; }
.pass[hidden] { display: none; }
.pv-hint { text-align: center; font-size: 12px; color: var(--ink-soft); margin: 10px 0 0; }

/* 使い方 */
.howto { margin: 40px 0 0; }
.howto ol { counter-reset: n; list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; grid-template-columns: repeat(3, 1fr); }
@media (max-width: 760px) { .howto ol { grid-template-columns: 1fr; } }
.howto li { counter-increment: n; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px 16px; }
.howto li::before { content: counter(n, decimal-leading-zero); font-family: var(--display); font-style: italic; color: var(--latte-ink); font-size: 20px; display: block; }
.howto li b { display: block; font-family: var(--serif); color: var(--espresso); font-size: 16px; margin: 2px 0 6px; }
.howto li p { margin: 0; font-size: 14px; color: var(--ink-soft); }
.fine { font-size: 13px; color: var(--ink-soft); margin: 18px 0 0; }

.site-footer { background: var(--espresso); color: var(--crema); padding: 32px 0 40px; margin-top: 56px; font-size: 14px; }
:root[data-theme="dark"] .site-footer { background: #0f0907; color: #cdb79e; }
.site-footer .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; }
.site-footer a { text-decoration: none; }
.site-footer a:hover { color: #fff; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 18px; }

/* 狭い画面: プレビューは画面上部に固定し、ふだんは「帯だけ」の小さな表示（.mini）。タップで全体に切り替える */
.pv-toggle { display: none; }
@media (max-width: 860px) {
  .maker .preview-col { position: sticky; top: 0; z-index: 5; margin: 0 calc(50% - 50vw); padding: 8px max(16px, calc(50vw - 50%)) 8px; background: var(--paper); box-shadow: 0 8px 16px -12px #0007; }
  .maker .preview-col:not(.mini) { position: static; margin: 0; padding: 0; background: none; box-shadow: none; }
  .pv-toggle { display: inline-block; font: inherit; font-size: 12px; font-weight: 700; color: var(--espresso); background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 5px 14px; cursor: pointer; }
  .preview-col:not(.mini) .pv-toggle { display: block; margin: 8px auto 0; }
  .preview-col.mini .pv-tabs, .preview-col.mini .pv-hint, .preview-col.mini .pass.back,
  .preview-col.mini .pass .sec, .preview-col.mini .pass .qr, .preview-col.mini .pass .alt { display: none; }
  .preview-col.mini .pass.front { display: block; min-height: 0; padding-bottom: 0; max-width: 100%; }
  .preview-col.mini .pass .hdr { padding: 7px 14px 5px; min-height: 0; }
  .preview-col.mini .pass .hdr svg { width: 20px; height: 20px; }
  .preview-col.mini .pass .hdr .org { font-size: 12px; }
  .preview-col.mini .pass .strip { cursor: pointer; max-height: 21vh; object-fit: cover; object-position: top; } /* 縦に大きな帯は固定中は上だけ見せる */
}

/* ?demo=1 のスクリーンショット用: 見出しを隠す */
body.shot .top, body.shot main > .section-title { display: none; }
body.shot main { padding-top: 28px; }

/* アイコン（X のアイコン / 写真 / カップ） */
.avatar-row { display: flex; align-items: center; gap: 14px; }
.avatar-pv { width: 56px; height: 56px; border-radius: 50%; background: var(--crema); flex: none; display: grid; place-items: center; overflow: hidden; box-shadow: 0 0 0 1px var(--line); position: relative; }
.avatar-pv .glyph { display: grid; place-items: center; color: var(--espresso); }
.avatar-pv svg { width: 32px; height: 32px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.avatar-pv img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none; }
.avatar-pv.has img { display: block; }
.avatar-pv.has .glyph { display: none; }
.marks { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 8px; margin-top: 10px; }
.mark { position: relative; cursor: pointer; display: grid; gap: 3px; justify-items: center; padding: 8px 4px 6px; border-radius: 12px; border: 1px solid var(--line); background: var(--paper); color: var(--espresso); font-size: 11px; }
.mark input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.mark svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mark span { color: var(--ink-soft); line-height: 1.2; }
.mark:has(input:checked) { border-color: var(--espresso); box-shadow: 0 0 0 1px var(--espresso); background: var(--card); }
.mark:has(input:focus-visible) { outline: 2px solid var(--latte-ink); outline-offset: 2px; }
.chip.tip span { cursor: help; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span { display: inline-block; font-size: 13px; font-weight: 700; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-soft); background: var(--paper); }
.chip input:checked + span { background: var(--espresso); color: var(--paper); border-color: var(--espresso); }
.chip input:focus-visible + span { outline: 2px solid var(--latte-ink); outline-offset: 2px; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.field small.warn { color: var(--bad); }
form.busy .btn.wallet { opacity: .6; pointer-events: none; }
form.busy .btn.wallet span::after { content: "…"; }

/* 先頭の「デザイン・配色」と、4 ブロックのステップ */
.look { display: grid; gap: 10px; padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px dashed var(--line); }
.field.compact { margin-bottom: 0; }
.stepnav { display: none; }
.steps .step > h2 { margin-top: 2px; }
@media (max-width: 860px) {
  .panel { padding: 16px 16px 20px; }
  /* 配色・デザインは JS で固定プレビュー側に移す */
  .preview-col .look { display: block; margin: 8px 0 0; padding: 0; border: 0; }
  .preview-col .look .field.compact { display: flex; align-items: center; gap: 10px; width: 100%; }
  .preview-col .look .field.compact + .field.compact { margin-top: 6px; }
  .preview-col .look .field > span { font-size: 11px; flex: none; white-space: nowrap; }
  .preview-col .look .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .preview-col .look .chips::-webkit-scrollbar { display: none; }
  .preview-col .look .chip span { font-size: 11.5px; padding: 4px 9px; white-space: nowrap; }
  .preview-col .look .swatch i { width: 30px; height: 22px; border-radius: 6px; }
  .preview-col .look .swatch i::after { left: 6px; right: 12px; top: 8px; height: 2px; }
  .preview-col .look .swatch span { display: none; }
  .preview-col .look .swatches { gap: 6px; flex: 1; min-width: 0; }
  .preview-col .pv-toggle { margin: 0 0 0 auto; padding: 4px 9px; font-size: 11px; flex: none; white-space: nowrap; }
  .preview-col.mini .pass .hdr { display: none; }
  .preview-col.mini .pass.front { border-radius: 12px; }
  /* ステップ: 横スクロール＋スナップ。スワイプで隣へ */
  .steps { display: flex; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; scroll-behavior: smooth; -webkit-overflow-scrolling: touch; margin: 0 -16px; padding: 0; scrollbar-width: none; align-items: flex-start; transition: height .25s ease; }
  .steps::-webkit-scrollbar { display: none; }
  .steps .step { flex: 0 0 100%; width: 100%; scroll-snap-align: start; scroll-snap-stop: always; padding: 0 16px; box-sizing: border-box; }
  .stepnav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 12px; }
  .stepinfo { display: grid; justify-items: center; gap: 2px; font-size: 12px; color: var(--ink-soft); }
  .stepinfo b { color: var(--espresso); font-size: 13px; }
  .dots { display: flex; gap: 5px; }
  .dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); display: block; }
  .dots i.on { background: var(--espresso); }
  .stepnav .btn[disabled] { visibility: hidden; }
}

/* PC 向け: スマホで読み取る QR のダイアログ */
#qrDlg { border: 0; border-radius: 18px; padding: 26px 26px 22px; width: min(92vw, 380px); background: var(--card); color: var(--espresso); box-shadow: 0 30px 80px -20px #000a; text-align: center; }
#qrDlg::backdrop { background: #1a0e0888; backdrop-filter: blur(3px); }
.qr-lead { margin: 0 0 14px; text-wrap: balance; font-size: 15px; font-weight: 700; }
.qr-wait { margin: 18px 0; font-size: 13px; color: var(--ink-soft); }
.qr-box { width: 232px; height: 232px; margin: 0 auto; padding: 12px; background: #fff; border-radius: 14px; box-shadow: 0 0 0 1px var(--line); transition: opacity .3s; }
.qr-box svg { width: 100%; height: 100%; display: block; }
.qr-box.dead { opacity: .12; }
.qr-steps { text-align: left; font-size: 13px; line-height: 1.7; color: var(--ink-soft); margin: 16px 0 0; padding-left: 1.5em; }
.qr-left { font-size: 12px; color: var(--ink-soft); margin: 10px 0 14px; }
.qr-left b { color: var(--espresso); font-variant-numeric: tabular-nums; }
.qr-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.qr-actions a.btn { text-decoration: none; }

/* 2 枚に分けるときのアイコン枠 */
.avlabel { margin: 0 0 8px; font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.avlabel[hidden] { display: none; }
