:root {
  --bg: #07070b;
  --text: #f5f5f7;
  --muted: #a6a6b3;
  --glass-bg: rgba(255, 255, 255, 0.06);
  --glass-stroke: rgba(255, 255, 255, 0.14);
  --glass-highlight: rgba(255, 255, 255, 0.45);
  --accent: #7aa2ff;
  --accent-2: #c08cff;
  --radius: 28px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.55), 0 4px 16px rgba(0, 0, 0, 0.4);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* ---------- Ambient liquid-glass background ---------- */
.aurora {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(120% 120% at 50% -10%, #11131f 0%, #07070b 55%, #050507 100%);
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.6;
  mix-blend-mode: screen;
  will-change: transform;
}

.blob-1 {
  width: 46vmax; height: 46vmax;
  background: radial-gradient(circle at 30% 30%, #5b7cff, transparent 65%);
  top: -12vmax; left: -8vmax;
  animation: drift1 22s var(--ease) infinite alternate;
}

.blob-2 {
  width: 40vmax; height: 40vmax;
  background: radial-gradient(circle at 50% 50%, #b06bff, transparent 65%);
  bottom: -14vmax; right: -10vmax;
  animation: drift2 26s var(--ease) infinite alternate;
}

.blob-3 {
  width: 34vmax; height: 34vmax;
  background: radial-gradient(circle at 50% 50%, #2ad6c5, transparent 65%);
  top: 35%; left: 55%;
  opacity: 0.4;
  animation: drift3 30s var(--ease) infinite alternate;
}

.grain {
  position: absolute;
  inset: -50%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  opacity: 0.035;
  mix-blend-mode: overlay;
}

@keyframes drift1 { to { transform: translate(8vmax, 6vmax) scale(1.1); } }
@keyframes drift2 { to { transform: translate(-7vmax, -5vmax) scale(1.15); } }
@keyframes drift3 { to { transform: translate(-6vmax, 4vmax) scale(0.9); } }

@media (prefers-reduced-motion: reduce) {
  .blob { animation: none; }
}

/* ---------- Layout ---------- */
.stage {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: max(2rem, env(safe-area-inset-top)) 1.25rem 2rem;
}

/* ---------- Glass primitives ---------- */
.glass {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid var(--glass-stroke);
  box-shadow: var(--shadow), inset 0 1px 0 var(--glass-highlight);
}

.glass-inset {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-stroke);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 -10px 30px rgba(0, 0, 0, 0.25);
}

/* ---------- Bio card ---------- */
.card {
  position: relative;
  width: min(540px, 100%);
  border-radius: var(--radius);
  padding: clamp(2rem, 5vw, 3rem);
  text-align: center;
  overflow: hidden;
  animation: rise 0.9s var(--ease) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(24px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

/* moving specular highlight */
.card-glow {
  position: absolute;
  top: -40%;
  left: -30%;
  width: 80%;
  height: 80%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.12), transparent 60%);
  pointer-events: none;
  transition: transform 0.3s var(--ease);
}

.avatar {
  position: relative;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  margin: 0 auto 1.25rem;
  display: grid;
  place-items: center;
  font-size: 2.4rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  background-image: linear-gradient(135deg, rgba(122, 162, 255, 0.35), rgba(192, 140, 255, 0.35));
  color: #fff;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.avatar-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-edit {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-shadow: none;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  z-index: 2;
}
body.editing .avatar { cursor: pointer; }
body.editing .avatar:hover .avatar-edit { display: flex; }

.name {
  font-size: clamp(1.9rem, 5vw, 2.6rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  margin: 0 0 0.4rem;
  background: linear-gradient(180deg, #ffffff, #c8c8d4);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.role {
  color: var(--accent);
  font-size: 1rem;
  font-weight: 500;
  margin: 0 0 1.5rem;
  letter-spacing: 0.01em;
}

.bio {
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.7;
  margin: 0 auto 1.75rem;
  max-width: 42ch;
}

/* ---------- Link pills ---------- */
.links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 1.15rem;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--glass-stroke);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: transform 0.18s var(--ease), background 0.2s var(--ease);
}

.pill:hover { transform: translateY(-2px); background: rgba(255, 255, 255, 0.14); }

.pill-icon {
  display: inline-flex;
  width: 16px;
  height: 16px;
  opacity: 0.85;
}
.pill-icon svg { width: 100%; height: 100%; fill: currentColor; }

body.editing .pill { cursor: pointer; border-style: dashed; }
body.editing .pill::after {
  content: "✎";
  font-size: 0.8rem;
  opacity: 0.6;
  margin-left: 0.1rem;
}

/* ---------- Footer ---------- */
.footer {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.85rem;
  animation: rise 1.1s var(--ease) both;
}

.text-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  opacity: 0.7;
  transition: opacity 0.2s;
}
.text-btn:hover { opacity: 1; color: var(--text); }

/* ---------- Editing state ---------- */
[contenteditable="true"] {
  outline: none;
  border-radius: 10px;
  transition: box-shadow 0.2s, background 0.2s;
}
body.editing [contenteditable="true"] {
  box-shadow: 0 0 0 1px var(--glass-stroke);
  background: rgba(255, 255, 255, 0.04);
  padding: 0.15em 0.4em;
  cursor: text;
}
body.editing [contenteditable="true"]:focus {
  box-shadow: 0 0 0 2px var(--accent);
  background: rgba(255, 255, 255, 0.07);
}

/* ---------- Modal ---------- */
.modal {
  border: 1px solid var(--glass-stroke);
  border-radius: 22px;
  padding: 0;
  color: var(--text);
  width: min(380px, 92vw);
  background: rgba(20, 20, 28, 0.72);
}
.modal::backdrop {
  background: rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.modal form { padding: 1.75rem; display: flex; flex-direction: column; gap: 0.75rem; }
.modal h2 { margin: 0; font-size: 1.3rem; font-weight: 600; letter-spacing: -0.02em; }
.modal-sub { margin: 0 0 0.5rem; color: var(--muted); font-size: 0.9rem; }

.modal input {
  width: 100%;
  padding: 0.8rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--glass-stroke);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
}
.modal input:focus { outline: none; box-shadow: 0 0 0 2px var(--accent); }

.error { color: #ff8585; font-size: 0.85rem; margin: 0; }

.field-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-top: 0.35rem;
}

.modal-actions { display: flex; gap: 0.6rem; justify-content: flex-end; margin-top: 0.5rem; }
.modal-actions.spread { justify-content: flex-start; align-items: center; }
.modal-actions .spacer { flex: 1; }

/* ---------- Buttons ---------- */
.btn {
  padding: 0.6rem 1.2rem;
  border-radius: 999px;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.15s var(--ease), filter 0.2s, background 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0a0a12;
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border-color: var(--glass-stroke);
}
.btn.ghost:hover { background: rgba(255, 255, 255, 0.15); }
.btn.ghost:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.danger {
  background: rgba(255, 80, 80, 0.18);
  color: #ff9b9b;
  border-color: rgba(255, 80, 80, 0.35);
}
.btn.danger:hover { background: rgba(255, 80, 80, 0.28); }

/* ---------- Toolbar ---------- */
/* Floating, centered glass pill (iOS-26 / Instagram-style nav) */
.toolbar {
  position: fixed;
  bottom: max(1.5rem, env(safe-area-inset-bottom));
  left: 50%;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.4rem;
  border-radius: 999px;
  z-index: 50;
  max-width: 94vw;
  overflow-x: auto;
  scrollbar-width: none;
  background: rgba(26, 27, 33, 0.55);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  backdrop-filter: blur(40px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.28);
  /* Default CSS centering (fallback); JS recomputes exact center on show/resize.
     Animation only fades opacity so it never disturbs horizontal centering. */
  transform: translateX(-50%);
  animation: pillIn 0.4s var(--ease) both;
}
@keyframes pillIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.toolbar::-webkit-scrollbar { display: none; }
.toolbar .btn, .toolbar-status { flex: 0 0 auto; white-space: nowrap; }

/* Minimal, borderless icon segments inside the pill */
.toolbar .btn {
  border: none;
  background: transparent;
  color: var(--text);
  opacity: 0.85;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.toolbar .btn:hover { background: rgba(255, 255, 255, 0.12); opacity: 1; }
.toolbar .btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0a0a12;
  opacity: 1;
}
.toolbar .btn.primary:hover { filter: brightness(1.08); }

.toolbar .ic {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.toolbar-status {
  padding: 0 0.4rem 0 0.7rem;
  font-size: 0.82rem;
  color: var(--muted);
}

/* Collapse to a clean icon-only pill on small screens */
@media (max-width: 560px) {
  .toolbar-status { display: none; }
  .toolbar .btn-label { display: none; }
  .toolbar .btn { padding: 0.55rem; }
}
.toolbar-status {
  font-size: 0.85rem;
  color: var(--muted);
  margin-right: 0.25rem;
}
.toolbar-status.saving { color: var(--accent); }
.toolbar-status.saved { color: #5fd08a; }

/* ---------- Passkeys ---------- */
.btn.full { width: 100%; justify-content: center; display: inline-flex; align-items: center; gap: 0.4rem; }
.btn.small { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.key-glyph { font-size: 1rem; }

.divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  margin: 0.25rem 0;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--glass-stroke);
}
.divider span { padding: 0 0.75rem; }

.modal-body { padding: 1.75rem; display: flex; flex-direction: column; gap: 0.75rem; }

.passkey-list { list-style: none; margin: 0.25rem 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.passkey-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-stroke);
  font-size: 0.9rem;
}
.passkey-empty { color: var(--muted); font-size: 0.9rem; padding: 0.5rem 0; }

/* ---------- Contact card ---------- */
.contact-card {
  width: min(540px, 100%);
  text-align: left;
  animation: rise 1s var(--ease) both;
}
.contact-title {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 1rem;
}
.contact-form { display: flex; flex-direction: column; gap: 0.7rem; }
.contact-form input,
.contact-form textarea {
  width: 100%;
  padding: 0.8rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--glass-stroke);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  resize: vertical;
}
.contact-form input:focus,
.contact-form textarea:focus { outline: none; box-shadow: 0 0 0 2px var(--accent); }
.contact-form input::placeholder,
.contact-form textarea::placeholder { color: var(--muted); }

/* honeypot — visually and from a11y tree, but present for bots */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.form-status { font-size: 0.88rem; margin: 0.1rem 0 0; color: var(--muted); }
.form-status.ok { color: #5fd08a; }
.form-status.err { color: #ff8585; }

/* footer text buttons */
.footer { flex-wrap: wrap; justify-content: center; }
#foot-copy { cursor: default; }
