:root {
  --bg: #101013;
  --card: #1a1a1f;
  --card-2: #222228;
  --text: #f2f1ed;
  --text-2: #a5a39c;
  --text-3: #76746d;
  --border: #2a2a31;
  --danger: #f09595;
  --danger-bg: #3a1d1d;
  --success: #9fe1cb;
  --success-bg: #123329;
  --radius: 14px;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f6f5f1;
  --card: #ffffff;
  --card-2: #f0efe9;
  --text: #1c1c1a;
  --text-2: #5f5e5a;
  --text-3: #8a8880;
  --border: #e4e2da;
  --danger: #a32d2d;
  --danger-bg: #fcebeb;
  --success: #0f6e56;
  --success-bg: #e1f5ee;
  color-scheme: light;
}

.theme-purple { --accent: #7f77dd; --accent-deep: #534ab7; --accent-light: #eeedfe; --accent-dark: #26215c; --accent-chip: #cecbf6; }
.theme-teal   { --accent: #1d9e75; --accent-deep: #0f6e56; --accent-light: #e1f5ee; --accent-dark: #04342c; --accent-chip: #9fe1cb; }
.theme-coral  { --accent: #d85a30; --accent-deep: #993c1d; --accent-light: #faece7; --accent-dark: #4a1b0c; --accent-chip: #f5c4b3; }
.theme-pink   { --accent: #d4537e; --accent-deep: #993556; --accent-light: #fbeaf0; --accent-dark: #4b1528; --accent-chip: #f4c0d1; }
.theme-blue   { --accent: #378add; --accent-deep: #185fa5; --accent-light: #e6f1fb; --accent-dark: #042c53; --accent-chip: #b5d4f4; }
.theme-green  { --accent: #639922; --accent-deep: #3b6d11; --accent-light: #eaf3de; --accent-dark: #173404; --accent-chip: #c0dd97; }

* { box-sizing: border-box; margin: 0; }

html { background: var(--bg); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 480px; margin: 0 auto; padding: 16px; }

a { color: var(--accent, #7f77dd); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; }
h2 { font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }
.muted { color: var(--text-2); font-size: 16px; }
.small { font-size: 14px; color: var(--text-3); }

.icon { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; flex-shrink: 0; }
.icon-sm { width: 14px; height: 14px; vertical-align: -2px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
}

label { display: block; font-size: 15px; color: var(--text-2); margin: 14px 0 5px; }
input[type="text"], input[type="password"], input[type="email"], input[type="url"],
textarea, select {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card-2);
  color: var(--text);
  font-family: inherit;
  appearance: none;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent, #7f77dd); outline-offset: -1px; }
input[type="file"] { font-size: 15px; margin-top: 4px; color: var(--text-2); }
input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--accent, #7f77dd); }
.helptext { display: block; font-size: 14px; color: var(--text-3); margin-top: 4px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 50px;
  padding: 13px 18px;
  font-size: 16px;
  font-weight: 550;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  margin-top: 12px;
  font-family: inherit;
  transition: background 0.12s, border-color 0.12s;
}
.btn:active { transform: scale(0.98); }
.btn:hover { background: var(--card-2); text-decoration: none; }
.btn-primary { background: var(--accent, #7f77dd); border-color: transparent; color: #fff; }
.btn-primary:hover { background: var(--accent-deep, #534ab7); }
.btn-danger { color: var(--danger); border-color: var(--border); background: transparent; }
.btn-danger:hover { background: var(--danger-bg); border-color: transparent; }
.btn-sm { width: auto; min-height: 44px; padding: 9px 16px; font-size: 15px; margin-top: 0; }
.btn-icon { width: 44px; height: 44px; min-height: 44px; padding: 0; margin-top: 0; }

.errorlist { list-style: none; padding: 10px 14px; margin: 8px 0; background: var(--danger-bg); color: var(--danger); border-radius: 10px; font-size: 15px; }
.messages { list-style: none; padding: 0; margin: 0 0 12px; }
.messages li { padding: 13px 16px; border-radius: 12px; font-size: 15px; margin-bottom: 6px; }
.messages .success { background: var(--success-bg); color: var(--success); }
.messages .error { background: var(--danger-bg); color: var(--danger); }

/* nav */
.topnav { display: flex; align-items: center; justify-content: space-between; padding: 12px 0 18px; gap: 8px; }
.topnav .brand { font-weight: 700; font-size: 18px; color: var(--text); display: flex; align-items: center; gap: 9px; }
.topnav .brand:hover { text-decoration: none; }
.brand-dot {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--accent, #7f77dd); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
}
.brand-dot .icon { width: 17px; height: 17px; }
.topnav .nav-links { display: flex; gap: 2px; font-size: 15px; align-items: center; }
.nav-item {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 44px; min-height: 44px;
  color: var(--text-2); padding: 10px 11px; border-radius: 11px;
  background: none; border: 0; cursor: pointer; font: inherit; font-size: 15px;
}
.nav-item:hover { background: var(--card); color: var(--text); text-decoration: none; }
.nav-item .icon { width: 20px; height: 20px; }

/* dashboard tabs */
.tabs { display: flex; gap: 4px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 4px; margin-bottom: 16px; }
.tabs a {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px;
  padding: 11px 4px; font-size: 15px; font-weight: 550; color: var(--text-3); border-radius: 9px;
}
.tabs a .icon { width: 18px; height: 18px; }
.tabs a.active { color: var(--text); background: var(--card-2); }
.tabs a:hover { text-decoration: none; color: var(--text); }

.profile-switcher { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.profile-switcher select { flex: 1; }

/* badge (public profile) */
.badge-card {
  background: linear-gradient(160deg, var(--accent, #7f77dd), var(--accent-deep, #534ab7));
  border-radius: 20px;
  padding: 28px 20px 22px;
  text-align: center;
  color: #fff;
  margin-bottom: 14px;
}
.badge-card.has-banner { padding-top: 0; overflow: hidden; }
.badge-banner { margin: 0 -20px 16px; height: 120px; object-fit: cover; width: calc(100% + 40px); display: block; }
.badge-avatar {
  width: 92px; height: 92px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.55);
  background: var(--accent-light);
  object-fit: cover;
  display: inline-block;
}
.badge-avatar-fallback {
  width: 92px; height: 92px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.55);
  background: var(--accent-light);
  color: var(--accent-deep);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 36px; font-weight: 700;
}
.badge-name { font-size: 28px; font-weight: 700; margin-top: 10px; letter-spacing: -0.02em; }
.badge-sub { font-size: 16px; color: rgba(255, 255, 255, 0.85); margin-top: 2px; }
.badge-chips { margin-top: 12px; display: flex; gap: 7px; justify-content: center; flex-wrap: wrap; }
.chip { background: rgba(0, 0, 0, 0.28); color: #fff; font-size: 14px; padding: 6px 14px; border-radius: 999px; }

.bio { text-align: center; color: var(--text-2); font-size: 17px; margin: 16px 8px; }

.linklist { display: flex; flex-direction: column; gap: 9px; }
.linkrow {
  display: flex; align-items: center; gap: 13px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 60px;
  padding: 14px 16px;
  color: var(--text);
  font-weight: 550;
  font-size: 17px;
  width: 100%;
  font-family: inherit;
  text-align: left;
}
.linkrow:active { transform: scale(0.99); }
.linkrow:hover { border-color: var(--accent, #7f77dd); text-decoration: none; }
button.linkrow { cursor: pointer; }
.platform-dot {
  width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 14px; font-weight: 700;
}
.linkrow .grow { flex: 1; min-width: 0; }
.linkrow .sub { display: block; font-size: 14px; color: var(--text-3); font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linkrow .arrow { color: var(--text-3); display: inline-flex; }

/* dashboard link manager */
.managerow { cursor: grab; }
.managerow.dragging { opacity: 0.45; border-style: dashed; }
.drag-handle { color: var(--text-3); cursor: grab; display: inline-flex; align-items: center; justify-content: center; min-width: 40px; min-height: 44px; user-select: none; touch-action: none; }

/* theme picker */
.theme-picker { display: flex; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.theme-picker input { display: none; }
.theme-swatch { width: 42px; height: 42px; border-radius: 50%; cursor: pointer; display: inline-block; border: 3px solid transparent; transition: transform 0.1s; }
.theme-swatch:hover { transform: scale(1.1); }
.theme-picker input:checked + .theme-swatch { border-color: var(--text); }
.theme-swatch-rainbow { background: conic-gradient(#e24b4a, #ef9f27, #97c459, #1d9e75, #378add, #7f77dd, #d4537e, #e24b4a); }
input[type="color"] { width: 80px; height: 48px; padding: 4px; border: 1px solid var(--border); border-radius: 12px; background: var(--card-2); cursor: pointer; }

/* stats */
.statgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; margin-bottom: 12px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.stat .n { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.stat .l { font-size: 14px; color: var(--text-3); }

.qr-box { text-align: center; }
.qr-box img { width: 220px; height: 220px; border-radius: 14px; border: 1px solid var(--border); background: #fff; padding: 6px; }

.row-actions { display: flex; gap: 6px; align-items: center; }
.inline-form { display: inline; }
.divider { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }

/* landing hero */
.hero { text-align: center; padding: 28px 0 10px; }

/* paw loading screen */
#paw-loader {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: var(--bg);
  color: var(--accent, #7f77dd);
}
#paw-loader[hidden] { display: none; }
#paw-loader p { color: var(--text-2); font-size: 16px; }
#paw-loader .toe, #paw-loader .pad {
  fill: currentColor;
  transform-box: fill-box;
  transform-origin: center;
  animation: 0.65s ease-in-out infinite alternate;
}
#paw-loader .toe-1 { animation-name: paw-toe-1; }
#paw-loader .toe-2 { animation-name: paw-toe-2; }
#paw-loader .toe-3 { animation-name: paw-toe-3; }
#paw-loader .toe-4 { animation-name: paw-toe-4; }
#paw-loader .pad { animation-name: paw-pad; }

@keyframes paw-toe-1 { from { transform: translate(14px, 14px) rotate(18deg) scale(0.62); } to { transform: none; } }
@keyframes paw-toe-2 { from { transform: translate(5px, 16px) rotate(7deg) scale(0.62); } to { transform: none; } }
@keyframes paw-toe-3 { from { transform: translate(-5px, 16px) rotate(-7deg) scale(0.62); } to { transform: none; } }
@keyframes paw-toe-4 { from { transform: translate(-14px, 14px) rotate(-18deg) scale(0.62); } to { transform: none; } }
@keyframes paw-pad { from { transform: scale(0.92); } to { transform: scale(1); } }

@media (prefers-reduced-motion: reduce) {
  #paw-loader .toe, #paw-loader .pad { animation: none; }
}

footer { text-align: center; padding: 24px 0 40px; font-size: 15px; color: var(--text-3); }
footer a { color: var(--text-3); margin: 0 8px; display: inline-block; padding: 8px 4px; }

@media (min-width: 600px) {
  .statgrid { grid-template-columns: repeat(4, 1fr); }
}
