:root {
  --bg: #f4f3f1;
  --bg-2: #e9e8e5;
  --ink: #1d1e20;
  --muted: #6c6f74;
  --line: #d8d7d3;
  --card: #ffffff;
  --accent: #1d1e20;
  --accent-ink: #ffffff;
  --ok: #2f7d5b;
  --warn: #a1452f;
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", sans-serif;
  color: var(--ink);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121314; --bg-2: #1b1c1e; --ink: #ecebe8; --muted: #9a9ca0;
    --line: #2c2d30; --card: #1b1c1e; --accent: #ecebe8; --accent-ink: #121314;
    --ok: #6fc49c; --warn: #e39a86;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { min-height: 100dvh; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }

/* ---------- タップ時のページ ---------- */
body.tap {
  background: radial-gradient(120% 80% at 50% 0%, var(--bg) 40%, var(--bg-2) 100%);
}
.stage {
  min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 32px 24px calc(32px + env(safe-area-inset-bottom)); text-align: center;
}
.mark { width: 76px; height: 76px; margin-bottom: 20px; }
.mark img { width: 100%; height: 100%; object-fit: contain; }
.mark img + .mark-svg { display: none; }
.mark-svg { width: 100%; height: 100%; animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .55; transform: scale(.96); } }
@media (prefers-reduced-motion: reduce) { .mark-svg { animation: none; } }
.panel { max-width: 340px; width: 100%; }
.brand { margin: 0 0 6px; font-size: 13px; letter-spacing: .32em; text-transform: lowercase; color: var(--muted); }
.panel h1 { font-size: 20px; line-height: 1.5; margin: 6px 0 10px; font-weight: 600; }
.sub { text-wrap: balance; margin: 0 0 22px; color: var(--muted); font-size: 14px; line-height: 1.7; }
.host { margin: 12px 0 0; color: var(--muted); font-size: 13px; word-break: break-all; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; width: 100%; min-height: 52px;
  padding: 0 20px; border-radius: 999px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-ink); font: inherit; font-size: 16px; font-weight: 600;
  text-decoration: none; cursor: pointer;
}
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }

/* ---------- 管理画面 ---------- */
body.admin { font-size: 15px; }
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.top .brand { margin: 0; flex: 1; font-size: 13px; letter-spacing: .18em; white-space: nowrap; }
.top .who { color: var(--muted); font-size: 12px; max-width: 45vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wrap { max-width: 760px; margin: 0 auto; padding: 16px 16px 80px; }
.box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.box h2 { font-size: 15px; margin: 0 0 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1 1 140px; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
textarea { min-height: 56px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
button.s {
  font: inherit; font-size: 14px; font-weight: 600; min-height: 42px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); cursor: pointer; white-space: nowrap;
}
button.s.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
button.s:disabled { opacity: .45; cursor: default; }
.hint { font-size: 12px; color: var(--muted); margin: 8px 0 0; line-height: 1.6; }
.msg { font-size: 13px; margin: 8px 0 0; min-height: 1em; }
.msg.ok { color: var(--ok); } .msg.err { color: var(--warn); }

.tools { display: flex; gap: 8px; margin-bottom: 12px; }
.tools input { flex: 1; }
.count { color: var(--muted); font-size: 12px; margin: 0 0 10px; }

.tag { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.tag.off { opacity: .6; }
.tag-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.tag-id { font: 600 18px/1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .08em; }
.pill { font-size: 11px; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.pill.set { color: var(--ok); border-color: currentColor; }
.taps { margin-left: auto; color: var(--muted); font-size: 12px; }
.tag-url {
  display: flex; gap: 8px; align-items: center; background: var(--bg); border-radius: 10px; padding: 6px 6px 6px 12px; margin-bottom: 10px;
}
.tag-url code { flex: 1; font-size: 13px; word-break: break-all; }
.grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 620px) { .grid { grid-template-columns: 2fr 1fr; } .grid .full { grid-column: 1 / -1; } }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); margin: 0; }
.check input { width: auto; }
.actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.center { text-align: center; padding: 60px 16px; }
.center .btn { max-width: 300px; }

/* ---------- SNSまとめページ ---------- */
#setup-btn { margin-bottom: 10px; }
body.tap { --p-card: var(--card); --p-line: var(--ink); --p-ava: #e9eaec; --p-ava-ink: var(--ink); }
body.tap[data-skin="night"] {
  --bg: #141a3a; --bg-2: #0c1028; --ink: #f2f4ff; --muted: #aeb6e0; --card: #222b5e;
  --p-line: #7de2ff; --p-ava: #7de2ff; --p-ava-ink: #141a3a; color: var(--ink);
}
body.tap[data-skin="strawberry"] {
  --bg: #ffe6ee; --bg-2: #fbd0dd; --ink: #5a1f33; --muted: #9a5a6e; --card: #fff7f9;
  --p-line: #5a1f33; --p-ava: #ff8fb1; --p-ava-ink: #5a1f33; color: var(--ink);
}
body.tap[data-skin="mint"] {
  --bg: #dcf4e8; --bg-2: #c2ead6; --ink: #123d2e; --muted: #4c7a68; --card: #f4fff9;
  --p-line: #123d2e; --p-ava: #5ed3a0; --p-ava-ink: #123d2e; color: var(--ink);
}
body.tap { color: var(--ink); }
.profile { width: 100%; max-width: 360px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.p-ava {
  width: 88px; height: 88px; border-radius: 50%; display: grid; place-items: center;
  background: var(--p-ava); color: var(--p-ava-ink); border: 2px solid var(--p-line);
  font-size: 36px; font-weight: 700;
}
.p-name { font-size: 22px; line-height: 1.35; margin: 4px 0 0; font-weight: 700; overflow-wrap: anywhere; }
.p-bio { margin: -6px 0 6px; color: var(--muted); font-size: 14px; line-height: 1.7; overflow-wrap: anywhere; white-space: pre-line; }
.p-links { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.p-link {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 16px;
  background: var(--p-card); color: var(--ink); text-decoration: none; text-align: left; font-weight: 700;
  border: 1.5px solid var(--p-line); box-shadow: 0 3px 0 var(--p-line); transition: transform .1s, box-shadow .1s;
}
.p-link:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--p-line); }
.p-link .who { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.p-link small { font-weight: 400; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-link .arr { margin-left: auto; font-size: 22px; color: var(--muted); }
.p-empty { color: var(--muted); font-size: 14px; border: 1.5px dashed var(--muted); border-radius: 16px; padding: 18px; margin: 0; }
.p-foot { margin: 18px 0 0; font-size: 11px; letter-spacing: .12em; color: var(--muted); }

.dot {
  position: relative; flex: none; width: 34px; height: 34px; border-radius: 10px; overflow: hidden;
  background: var(--c); color: #fff; display: grid; place-items: center;
}
.dot b { font-size: 10px; font-weight: 700; letter-spacing: .02em; }
.dot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.dot.has-img { background: transparent; }
.dot.has-img b { visibility: hidden; }

/* ---------- 購入者の登録ページ ---------- */
body.setup .wrap { max-width: 560px; }
.setup-step { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; }
.code-in { font: 600 20px/1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .14em; text-transform: uppercase; text-align: center; }
.sns-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.sns-row:first-child { border-top: 0; padding-top: 0; }
.sns-row .name { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; }
.sns-row .name .dot { width: 28px; height: 28px; border-radius: 8px; }
.sns-row .in { grid-column: 1 / -1; display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.sns-row .in span { padding-left: 12px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.sns-row .in input { border: 0; background: transparent; padding-left: 2px; min-width: 0; }
.sns-row .in:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.sns-row .in input:focus { outline: none; }
.sw { position: relative; width: 46px; height: 28px; }
.sw input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; width: 100%; }
.sw i { position: absolute; inset: 0; border-radius: 999px; background: var(--line); pointer-events: none; transition: background .15s; }
.sw i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--card); transition: transform .15s; }
.sw input:checked + i { background: var(--ok); }
.sw input:checked + i::after { transform: translateX(18px); }
.sw input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.themes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.theme {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--bg); color: var(--ink); font: inherit; font-size: 12px; cursor: pointer;
}
.theme[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.theme i { width: 34px; height: 34px; border-radius: 50%; border: 6px solid; }
.stats-big { font-size: 40px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.stats-big small { font-size: 14px; color: var(--muted); margin-left: 4px; }
.meter { height: 8px; border-radius: 999px; background: var(--bg-2); overflow: hidden; margin-top: 6px; }
.meter i { display: block; height: 100%; background: var(--ink); border-radius: 999px; }
.clicks { margin: 12px 0 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.clicks li { display: flex; justify-content: space-between; padding: 8px 0; font-size: 14px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.save-bar {
  position: sticky; bottom: 0; padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 30%); display: flex; flex-direction: column; gap: 4px;
}
.claim { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.claim code { font: 600 15px/1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .1em; color: var(--ink); }
.pill.reg { color: #6a4fc7; border-color: currentColor; }
button.s.danger { background: var(--warn); border-color: var(--warn); color: #fff; }
.tag-url code, .claim code { user-select: all; -webkit-user-select: all; }
.p-ava { overflow: hidden; }
.p-ava img, .ava-prev img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ava-edit { display: flex; align-items: center; gap: 16px; }
.ava-prev {
  flex: none; width: 76px; height: 76px; border-radius: 50%; overflow: hidden; display: grid; place-items: center;
  background: var(--bg-2); border: 1px solid var(--line); font-size: 30px; font-weight: 700; color: var(--ink);
}
.ava-btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-width: 0; }
.ava-btns .msg { flex-basis: 100%; margin: 0; }
label.file-btn {
  display: inline-flex; align-items: center; min-height: 42px; padding: 0 14px; margin: 0; border-radius: 10px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); font-size: 14px; font-weight: 600; cursor: pointer;
}

/* ---------- コピーの反応 ---------- */
button.s.copied { background: var(--ok); border-color: var(--ok); color: #fff; }
#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#copy-sheet {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); display: none; align-items: flex-end; justify-content: center; z-index: 60;
}
#copy-sheet.show { display: flex; }
.sheet-box {
  width: 100%; max-width: 520px; background: var(--card); border-radius: 18px 18px 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
}
.sheet-title { margin: 0 0 10px; font-weight: 600; }
.sheet-text { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 16px; }
.sheet-actions { display: flex; gap: 8px; margin-top: 12px; }
.sheet-actions button { flex: 1; }

/* ---------- まとめページ下のショップ案内 ---------- */
.p-shop {
  width: 100%; margin-top: 18px; display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border-radius: 16px; border: 1px dashed var(--muted); color: var(--ink); text-decoration: none; text-align: left;
  background: color-mix(in srgb, var(--p-card) 55%, transparent);
}
.p-shop:active { opacity: .7; }
.p-shop-mark { flex: none; width: 34px; height: 34px; color: var(--ink); }
.p-shop-txt { display: flex; flex-direction: column; gap: 3px; min-width: 0; line-height: 1.35; }
.p-shop-txt small { font-size: 11px; color: var(--muted); }
.p-shop-txt b { font-size: 14px; font-weight: 700; }
.p-shop .arr { margin-left: auto; font-size: 22px; color: var(--muted); }
@media (prefers-color-scheme: dark) { body.tap { --p-ava-ink: #1d1e20; } }
