:root {
  --bg: #0f172a;
  --bg2: #1e293b;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --radius: 18px;
  --shadow: 0 10px 40px rgba(2, 6, 23, 0.18);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: linear-gradient(160deg, #0f172a 0%, #1e293b 55%, #334155 100%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  min-height: 100dvh;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 16px calc(env(safe-area-inset-bottom) + 24px);
  min-height: 100dvh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 4px 14px;
  color: #e2e8f0;
}
.topbar h1 { font-size: 16px; margin: 0; font-weight: 700; letter-spacing: .02em; }
.topbar .sub { font-size: 11px; color: #94a3b8; margin-top: 2px; }

.icon-btn {
  appearance: none;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.08);
  color: #e2e8f0;
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.icon-btn:active { transform: scale(.97); }

/* ===== Business card ===== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-hero {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 60%, #1e3a8a 100%);
  color: #fff;
  padding: 26px 92px 22px 22px;
  position: relative;
}
.card-hero .company { font-size: 12px; opacity: .9; font-weight: 600; letter-spacing: .04em; }
.card-hero .name { font-size: 26px; font-weight: 800; margin: 8px 0 2px; line-height: 1.2; }
.card-hero .name .kana { display:block; font-size: 12px; font-weight: 600; opacity:.85; margin-bottom: 4px; }
.card-hero .title { font-size: 13px; opacity: .92; }
.avatar {
  position: absolute; top: 22px; right: 20px;
  width: 56px; height: 56px; border-radius: 50%;
  background: rgba(255,255,255,.2);
  display:flex; align-items:center; justify-content:center;
  font-size: 22px; font-weight: 800; color:#fff;
  border: 2px solid rgba(255,255,255,.45);
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-hero .company-kana { font-weight: 600; opacity: .85; font-size: 11px; margin-top: 1px; }
.cval-sub { font-size: 12px; color: var(--muted); font-weight: 500; margin-top: 2px; }

.card-body { padding: 8px 18px 18px; }

.contact-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 6px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
}
.contact-row:last-child { border-bottom: none; }
.contact-row .ci {
  width: 38px; height: 38px; border-radius: 10px;
  background: #eff6ff; color: var(--accent);
  display:flex; align-items:center; justify-content:center; flex: 0 0 auto;
}
.contact-row .ci svg { width: 20px; height: 20px; }
.contact-row .ctext { min-width: 0; }
.contact-row .clabel { font-size: 11px; color: var(--muted); }
.contact-row .cval { font-size: 15px; font-weight: 600; word-break: break-all; }
.contact-row.linkish .cval { color: var(--accent); }

.note {
  padding: 14px 8px 4px;
  font-size: 13px;
  color: #475569;
  line-height: 1.7;
  white-space: pre-wrap;
}

/* ===== SNS buttons ===== */
.sns {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 8px 18px 18px;
}
.sns a {
  display:flex; flex-direction:column; align-items:center; gap:6px;
  padding: 12px 6px;
  border-radius: 14px;
  text-decoration: none;
  color:#fff;
  font-size: 11px; font-weight: 700;
}
.sns a svg { width: 24px; height: 24px; }
.sns .line { background:#06c755; }
.sns .fb { background:#1877f2; }
.sns .ig { background: linear-gradient(45deg,#f09433,#e6683c,#dc2743,#cc2366,#bc1888); }

/* ===== Actions ===== */
.actions { padding: 4px 18px 22px; display: grid; gap: 10px; }
.btn {
  appearance:none; border:none; cursor:pointer;
  border-radius: 14px; padding: 15px;
  font-size: 15px; font-weight: 700;
  display:flex; align-items:center; justify-content:center; gap:8px;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-ghost { background:#f1f5f9; color:#334155; }
.btn:active { transform: scale(.985); }

/* ===== QR ===== */
.qr-wrap { display:flex; flex-direction:column; align-items:center; gap:10px; padding: 6px 0 18px; }
#qrcode { padding: 12px; background:#fff; border-radius:14px; box-shadow: var(--shadow); }
#qrcode img, #qrcode canvas { display:block; }
.qr-hint { font-size: 12px; color:#94a3b8; }

/* ===== Member switcher ===== */
.members {
  display:flex; gap:8px; overflow-x:auto; padding: 4px 2px 14px;
  scrollbar-width: none;
}
.members::-webkit-scrollbar { display:none; }
.chip {
  flex: 0 0 auto;
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.08);
  color:#e2e8f0;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px; font-weight:600;
  cursor:pointer; white-space:nowrap;
}
.chip.active { background:#fff; color:var(--ink); border-color:#fff; }
.chip.add { color:#bfdbfe; }

/* ===== Editor / modal ===== */
.modal-bg {
  position: fixed; inset: 0; background: rgba(2,6,23,.6);
  display:flex; align-items:flex-end; justify-content:center; z-index: 50;
}
.sheet {
  background:#fff; width:100%; max-width:480px;
  border-radius: 20px 20px 0 0;
  max-height: 92dvh; overflow-y:auto;
  padding: 18px 18px calc(env(safe-area-inset-bottom) + 18px);
}
.sheet h2 { font-size: 17px; margin: 4px 0 16px; }
.field { margin-bottom: 14px; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }

.photo-picker { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.photo-prev {
  width: 76px; height: 76px; border-radius: 50%; flex: 0 0 auto;
  background: #eef2ff; border: 1px solid var(--line); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.photo-prev img { width: 100%; height: 100%; object-fit: cover; }
.photo-prev.empty img { display: none; }
.photo-prev.empty::after { content: "写真"; color: #94a3b8; font-size: 12px; }
.photo-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-sm { padding: 9px 14px; font-size: 13px; }
.qr-hint.warn { color: #d97706; }
.expire-note { display:inline-block; margin-top:6px; font-size:11px; color:#d97706; }
.field label { display:block; font-size: 12px; color: var(--muted); margin-bottom:6px; font-weight:600; }
.field input, .field textarea {
  width:100%; border:1px solid var(--line); border-radius:12px;
  padding: 12px; font-size: 16px; font-family: inherit; color: var(--ink);
  background:#f8fafc;
}
.field textarea { min-height: 84px; resize: vertical; }
.sheet-actions { display:flex; gap:10px; margin-top: 8px; }
.sheet-actions .btn { flex:1; }
.btn-danger { background:#fee2e2; color:#b91c1c; }

.toast {
  position: fixed; left:50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background:#0f172a; color:#fff; padding:12px 18px; border-radius:999px;
  font-size:13px; font-weight:600; opacity:0; transition: all .25s; z-index:80;
  box-shadow: var(--shadow); pointer-events:none;
}
.toast.show { opacity:1; transform: translateX(-50%) translateY(0); }

.footer-note { text-align:center; color:#64748b; font-size:11px; padding: 8px 0 4px; }

/* ===== Loading / spinner ===== */
.loading-view { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:14px; min-height:60dvh; color:#cbd5e1; text-align:center; padding:0 24px; }
.loading-view .sub { font-size:14px; line-height:1.7; white-space:pre-line; max-width:340px; }
.spinner { width:22px; height:22px; border:3px solid rgba(148,163,184,.3); border-top-color:#2563eb; border-radius:50%; animation:spin .8s linear infinite; }
.spinner.big { width:38px; height:38px; border-width:4px; }
#qrcode .spinner { margin:90px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Cropper ===== */
.cropper .crop-hint { font-size:12px; color:var(--muted); margin-bottom:14px; }
.crop-stage { position:relative; width:260px; height:260px; margin:0 auto 16px; border-radius:16px; overflow:hidden; background:#0f172a; }
.crop-canvas { display:block; width:260px; height:260px; touch-action:none; cursor:grab; }
.crop-canvas:active { cursor:grabbing; }
.crop-ring { position:absolute; inset:0; pointer-events:none; box-shadow: 0 0 0 9999px rgba(15,23,42,.55) inset; }
.crop-ring::after { content:""; position:absolute; left:50%; top:50%; width:230px; height:230px; transform:translate(-50%,-50%); border-radius:50%; box-shadow: 0 0 0 2px rgba(255,255,255,.9); }
.zoom-row { display:flex; align-items:center; gap:12px; margin-bottom:8px; color:var(--muted); font-size:18px; }
.zoom-slider { flex:1; }

/* ===== 保存方法ガイド ===== */
.guide { margin: 2px 18px 10px; }
.guide-toggle { width:100%; text-align:left; background:#f1f5f9; color:#334155; border:none; border-radius:12px; padding:13px 14px; font-size:14px; font-weight:700; cursor:pointer; }
.guide-body { display:flex; gap:12px; flex-wrap:wrap; padding:12px 2px 2px; }
.guide-col { flex:1; min-width:150px; background:#f8fafc; border:1px solid var(--line); border-radius:12px; padding:12px; }
.guide-head { font-weight:800; font-size:14px; margin-bottom:10px; color:var(--ink); }
.guide-step { display:flex; gap:8px; align-items:flex-start; font-size:12.5px; color:#475569; line-height:1.5; margin-bottom:8px; }
.guide-step:last-child { margin-bottom:0; }
.gnum { flex:0 0 auto; width:18px; height:18px; border-radius:50%; background:var(--accent); color:#fff; font-size:11px; font-weight:800; display:flex; align-items:center; justify-content:center; margin-top:1px; }
.received-banner {
  background: rgba(37,99,235,.15); border:1px solid rgba(96,165,250,.4);
  color:#dbeafe; border-radius:12px; padding:10px 14px; font-size:12px;
  margin-bottom: 12px; text-align:center;
}
