:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --text: #1a1d23;
  --muted: #646b78;
  --line: #dfe2e8;
  --hover: #f6f7f9;
  --accent: #2748c9;
  --focus: #2748c9;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="dark"] {
  --bg: #101216;
  --surface: #171a20;
  --text: #e8eaee;
  --muted: #9aa1ae;
  --line: #292d36;
  --hover: #1d2129;
  --accent: #8fa6ff;
  --focus: #8fa6ff;
}

* { box-sizing: border-box; }

html { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.page {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 72px 20px 64px;
}

/* Profile */
.profile { text-align: center; margin-bottom: 36px; }

.avatar-btn {
  display: block;
  margin: 0 auto 18px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: zoom-in;
}
.avatar-btn[hidden] { display: none; }
.avatar-btn:focus-visible { outline-offset: 3px; }

.avatar {
  display: block;
  width: 104px;
  height: 104px;
  margin: 0;
  border-radius: 50%;
  object-fit: cover;
  background: var(--line);
  border: 1px solid var(--line);
}

h1 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 650;
  letter-spacing: -0.015em;
  line-height: 1.25;
}

.bio {
  margin: 8px auto 0;
  max-width: 40ch;
  color: var(--muted);
  font-size: 0.975rem;
}

/* Links */
.links {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

.links li + li { border-top: 1px solid var(--line); }

.row { display: flex; align-items: stretch; }

.link {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 8px 14px 18px;
  color: inherit;
  text-decoration: none;
  transition: background-color 0.15s;
}
.link:hover { background: var(--hover); }

.link svg {
  flex: none;
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.link-text { min-width: 0; }
.link-label { display: block; font-weight: 600; line-height: 1.3; }
.link-sub {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.qr-btn {
  flex: none;
  width: 56px;
  display: grid;
  place-items: center;
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}
.qr-btn:hover { background: var(--hover); color: var(--text); }
.qr-btn svg { width: 22px; height: 22px; fill: currentColor; }

a:focus-visible, button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

/* Theme toggle */
.theme-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.theme-toggle:hover { background: var(--hover); }
.theme-toggle svg { width: 20px; height: 20px; fill: currentColor; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
.theme-toggle:focus-visible { outline-offset: 2px; }

/* QR dialog */
.qr-dialog {
  width: min(340px, calc(100vw - 32px));
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
}
.qr-dialog::backdrop { background: rgba(8, 10, 14, 0.55); }

.qr-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.qr-head h2 { margin: 0; font-size: 1.05rem; font-weight: 650; }

.qr-close {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  margin-right: -6px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.qr-close:hover { background: var(--hover); color: var(--text); }
.qr-close svg { width: 18px; height: 18px; }
.qr-close:focus-visible { outline-offset: 0; }

/* The code itself stays black on white in both themes so phones can read it. */
.qr-code {
  background: #fff;
  padding: 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.qr-code svg { display: block; width: 100%; height: auto; }

.qr-url {
  margin: 12px 0 14px;
  color: var(--muted);
  font-size: 0.82rem;
  word-break: break-all;
}

.qr-copy {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}
.qr-copy:hover { background: var(--hover); }
.qr-copy:focus-visible { outline-offset: 2px; }

.error {
  margin: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.9rem;
}

/* Image viewer */
.img-dialog {
  max-width: 100vw;
  max-height: 100vh;
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: hidden;
}
.img-dialog[open] { display: grid; place-items: center; }
.img-dialog::backdrop { background: rgba(8, 10, 14, 0.85); }

.img-full {
  display: block;
  max-width: min(92vw, 900px);
  max-height: 88vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  background: var(--surface);
}

.img-close {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  cursor: pointer;
}
.img-close:hover { background: rgba(255, 255, 255, 0.28); }
.img-close svg { width: 20px; height: 20px; }
.img-close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* Footer */
.footer {
  margin-top: 28px;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}
.footer a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.footer a:hover { text-decoration: underline; }

@media (max-width: 420px) {
  .page { padding-top: 64px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}