:root {
  --bg: #e9f1f5;
  --card: #ffffff;
  --ink: #2f4a57;
  --muted: #6b8390;
  --line-color: #e1eaef;
  --accent: #4f6f7e;
  --accent-ink: #ffffff;
  --line-green: #06c755;
  --danger: #c4513f;
  --ok: #2f8a5b;
  --shadow: 0 10px 30px rgba(47, 74, 87, .14);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14202a;
    --card: #1d2c37;
    --ink: #e6eff4;
    --muted: #9db2bd;
    --line-color: #2c3f4c;
    --accent: #7fa8ba;
    --accent-ink: #10202a;
    --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}
a { color: inherit; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 0 18px; border-radius: 12px; border: 0;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: transform .1s ease, opacity .2s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.line { background: var(--line-green); color: #fff; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line-color); }
.btn.big { width: 100%; min-height: 52px; font-size: 17px; }

/* Centered pages: home, setup, share, 404 */
.center-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.panel {
  width: 100%; max-width: 400px; background: var(--card); border-radius: 22px;
  padding: 32px 24px; box-shadow: var(--shadow); text-align: center;
}
.panel h1 { margin: 0 0 8px; font-size: 24px; }
.panel p { margin: 0 0 22px; color: var(--muted); }
.hero .logo { border-radius: 16px; margin-bottom: 12px; }
#action { display: grid; gap: 12px; }
.small-link { color: var(--muted); font-size: 14px; }

.slug-input {
  display: flex; align-items: center; border-radius: 12px; overflow: hidden;
  box-shadow: inset 0 0 0 1.5px var(--line-color); background: var(--bg);
}
.slug-input span { padding: 0 4px 0 12px; color: var(--muted); font-size: 14px; white-space: nowrap; }
.slug-input input {
  flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink);
  font: inherit; font-weight: 600; padding: 13px 12px 13px 0; outline: none;
}
.hint { font-size: 13px; margin: 8px 0 18px !important; text-align: left; }
.hint.ok { color: var(--ok); }
.hint.bad { color: var(--danger); }

/* Card page */
.card-page {
  padding: 0 0 96px;
  background:
    radial-gradient(circle at 1px 1px, rgba(127,168,186,.16) 1px, transparent 0) 0 0 / 22px 22px,
    radial-gradient(60vw 60vw at 0% 0%, rgba(52,211,153,.10), transparent 60%),
    radial-gradient(70vw 70vw at 100% 40%, rgba(139,92,246,.12), transparent 60%),
    radial-gradient(60vw 60vw at 20% 100%, rgba(59,130,246,.10), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
.card {
  max-width: 440px; margin: 0 auto; background: var(--card);
  min-height: 100vh; box-shadow: var(--shadow); position: relative;
  background:
    radial-gradient(90% 40% at 50% 190px, rgba(127,168,186,.12), transparent 70%),
    var(--card);
}
@media (min-width: 480px) {
  .card-page { padding: 32px 16px 110px; }
  .card { min-height: 0; border-radius: 24px; overflow: hidden; }
}
.cover {
  height: 190px; background: #cfe1ea center/cover no-repeat; position: relative; overflow: hidden;
}
.scene { position: absolute; inset: 0; width: 100%; height: 100%; }
.avatar {
  width: 120px; height: 120px; border-radius: 50%; margin: -60px auto 0; position: relative;
  padding: 3px; border: 4px solid var(--card);
  background: conic-gradient(from 210deg, #34d399, #60a5fa, #a78bfa, #fb923c, #34d399);
  display: grid; place-items: center; box-shadow: 0 10px 28px rgba(0,0,0,.28);
}
.avatar span { width: 100%; height: 100%; display: grid; place-items: center; background: var(--accent); }
.avatar img, .avatar span { border-radius: 50%; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar span { font-size: 44px; font-weight: 700; color: var(--accent-ink); }
.identity { text-align: center; padding: 16px 24px 4px; }
.identity h1 { margin: 0; font-size: 26px; letter-spacing: .02em; }
.subtitle { margin: 10px 0 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; padding: 4px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 700; color: var(--accent);
  background: rgba(127,168,186,.12); box-shadow: inset 0 0 0 1px rgba(127,168,186,.28);
}
.chip:first-child { color: #fff; background: linear-gradient(135deg, #6f97a9, #3f6576); box-shadow: 0 4px 12px rgba(63,101,118,.35); }

/* About / bio */
.about { margin: 26px 16px 0; }
.bio-card {
  position: relative; overflow: hidden; padding: 18px 20px 20px 22px; border-radius: 18px;
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(167,139,250,.16), transparent 55%),
    radial-gradient(100% 80% at 0% 100%, rgba(52,211,153,.12), transparent 60%),
    var(--bg);
  box-shadow: inset 0 0 0 1px var(--line-color);
}
.bio-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, #34d399, #60a5fa, #a78bfa);
}
.quote { position: relative; display: block; width: 26px; height: 26px; margin: 0 0 8px; fill: #a78bfa; opacity: .75; }
.bio { position: relative; margin: 0; white-space: pre-line; font-size: 15px; line-height: 1.85; text-align: left; }

/* Contact rows: per-type colors */
.c-phone { --g: linear-gradient(135deg, #34d399, #059669); --glow: rgba(5,150,105,.35); --tint: rgba(16,185,129,.14); --tone: #10b981; }
.c-email { --g: linear-gradient(135deg, #60a5fa, #2563eb); --glow: rgba(37,99,235,.35); --tint: rgba(59,130,246,.14); --tone: #3b82f6; }
.c-line { --g: linear-gradient(135deg, #22e07a, #06c755); --glow: rgba(6,199,85,.35);  --tint: rgba(6,199,85,.14);  --tone: #06c755; }
.c-web { --g: linear-gradient(135deg, #a78bfa, #7c3aed); --glow: rgba(124,58,237,.35); --tint: rgba(139,92,246,.14); --tone: #8b5cf6; }
.c-map { --g: linear-gradient(135deg, #fb923c, #ea580c); --glow: rgba(234,88,12,.35); --tint: rgba(249,115,22,.14); --tone: #f97316; }

/* Contact: detail rows */
.contact-block { margin: 24px 16px 0; }
.section-title {
  margin: 0 0 10px 4px; font-size: 13px; font-weight: 700; letter-spacing: .12em; color: var(--muted);
  display: flex; align-items: center; gap: 10px;
}
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--line-color); }
.contacts { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.c {
  display: grid; grid-template-columns: 44px 1fr 18px; align-items: center; gap: 14px;
  padding: 12px 14px; border-radius: 16px; text-decoration: none; position: relative; overflow: hidden;
  background: var(--bg); box-shadow: inset 0 0 0 1px var(--line-color);
  transition: transform .12s ease, box-shadow .2s;
}
.c::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0; background: var(--tone); }
.c:active { transform: scale(.985); box-shadow: inset 0 0 0 1.5px var(--tone); }
.c-ic {
  width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center;
  background: var(--g); color: #fff; box-shadow: 0 6px 14px var(--glow);
}
.c-ic svg { width: 22px; height: 22px; }
.c-txt { display: grid; min-width: 0; }
.c-lbl { font-size: 12px; color: var(--muted); }
.c-val { font-weight: 650; font-size: 16px; overflow-wrap: anywhere; line-height: 1.35; }
.c-go { width: 18px; height: 18px; color: var(--muted); opacity: .7; }

.actions { display: grid; gap: 10px; padding: 20px 16px 8px; }
.foot { text-align: center; padding: 14px 16px 24px; font-size: 14px; }
.foot a { color: var(--muted); }

.edit-fab {
  position: fixed; right: 16px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 20;
  border: 0; border-radius: 999px; padding: 14px 20px; font: inherit; font-weight: 700;
  background: var(--ink); color: var(--card); box-shadow: var(--shadow); cursor: pointer;
}

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 50;
  background: rgba(20, 32, 42, .92); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px;
}

/* Editor */
.editor-backdrop { position: fixed; inset: 0; background: rgba(10, 20, 28, .45); z-index: 30; }
.editor {
  position: fixed; inset: auto 0 0 0; z-index: 31; max-height: 92vh; overflow-y: auto;
  background: var(--card); border-radius: 22px 22px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  max-width: 520px; margin: 0 auto; box-shadow: var(--shadow);
}
.editor h2 { margin: 0 0 14px; font-size: 20px; display: flex; justify-content: space-between; align-items: center; }
.editor .close { border: 0; background: none; font-size: 26px; color: var(--muted); cursor: pointer; line-height: 1; }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field input, .field textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--bg);
  border: 0; box-shadow: inset 0 0 0 1.5px var(--line-color); border-radius: 10px; padding: 11px 12px;
}
.field input:focus, .field textarea:focus { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
.field textarea { min-height: 90px; resize: vertical; }
.photos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.photo-pick {
  display: grid; place-items: center; gap: 6px; padding: 12px; border-radius: 12px; cursor: pointer;
  box-shadow: inset 0 0 0 1.5px var(--line-color); text-align: center; font-size: 13px; color: var(--muted);
}
.photo-pick img { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; background: var(--bg); }
.photo-pick input { display: none; }
.editor-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; position: sticky; bottom: 0; padding-top: 8px; background: var(--card); }
.slug-row { font-size: 13px; color: var(--muted); margin: 4px 0 16px; }
