*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface2: #242424;
  --border: #2e2e2e;
  --accent: #43e97b;
  --accent2: #38f9d7;
  --text: #f0f0f0;
  --muted: #888;
  --danger: #ff5c5c;
  --radius: 14px;
  --radius-sm: 8px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

/* ── LANDING ── */
.landing {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: radial-gradient(ellipse at 50% 0%, #1a3a2a 0%, #0f0f0f 60%);
}

.logo {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: .25rem;
  letter-spacing: -1px;
}

.tagline {
  color: var(--muted);
  font-size: .95rem;
  margin-bottom: 2.5rem;
  text-align: center;
}

/* ── CARD ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 420px;
}

.card h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}

/* ── FORM ── */
.field {
  display: flex;
  flex-direction: column;
  gap: .45rem;
  margin-bottom: 1.1rem;
}

.field label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.field input,
.field textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: .95rem;
  font-family: inherit;
  padding: .65rem .9rem;
  outline: none;
  transition: border-color .15s;
  width: 100%;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--accent);
}

.field textarea {
  resize: vertical;
  min-height: 70px;
}

.prefix-wrap {
  display: flex;
  align-items: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color .15s;
}

.prefix-wrap:focus-within { border-color: var(--accent); }

.prefix {
  color: var(--muted);
  font-size: .9rem;
  padding: .65rem .5rem .65rem .9rem;
  white-space: nowrap;
  user-select: none;
}

.prefix-wrap input {
  background: transparent;
  border: none;
  flex: 1;
  padding: .65rem .9rem .65rem .2rem;
}

.prefix-wrap input:focus { border: none; }

/* ── BUTTONS ── */
.btn {
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: .9rem;
  font-weight: 600;
  padding: .65rem 1.2rem;
  transition: opacity .15s, transform .1s;
}

.btn:active { transform: scale(.97); }
.btn:hover { opacity: .88; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #0f0f0f;
  width: 100%;
  padding: .8rem;
  font-size: 1rem;
  margin-top: .5rem;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}

.btn-danger {
  background: transparent;
  border: none;
  color: var(--danger);
  padding: .4rem .6rem;
  font-size: .85rem;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.1rem;
  padding: .3rem;
  cursor: pointer;
  line-height: 1;
}

/* ── GOOGLE SIGN-IN ── */
.google-btn-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 1.5rem 0 .5rem;
}

/* ── AVATAR IMAGES ── */
.avatar-img {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
}

.avatar-img-lg {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
}

/* ── DASHBOARD ── */
.dashboard {
  min-height: 100vh;
  background: var(--bg);
  padding-bottom: 4rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(15,15,15,.9);
  backdrop-filter: blur(8px);
  z-index: 10;
}

.topbar-logo {
  font-size: 1.2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.share-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .4rem .8rem;
  font-size: .8rem;
  color: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: .4rem;
  transition: background .15s;
}

.share-box:hover { background: var(--surface); }

.dash-body {
  max-width: 600px;
  margin: 0 auto;
  padding: 2rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ── PROFILE HEADER CARD ── */
.profile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.profile-card-top {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 800;
  color: #0f0f0f;
  flex-shrink: 0;
}

.profile-info h3 { font-size: 1rem; font-weight: 700; }
.profile-info span { font-size: .82rem; color: var(--muted); }

/* ── AVATAR WITH CAMERA OVERLAY ── */
.avatar-wrap {
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  border-radius: 50%;
}
.avatar-wrap .avatar,
.avatar-wrap .avatar-img { flex-shrink: 0; }
.avatar-overlay {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
}
.avatar-wrap:hover .avatar-overlay { opacity: 1; }

/* ── CROP MODAL ── */
.crop-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}
.crop-modal-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 500px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.crop-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.crop-modal-header h3 { font-size: 1rem; font-weight: 700; }
.crop-container {
  width: 100%;
  height: 340px;
  background: #111;
  overflow: hidden;
}
.crop-container img { display: block; max-width: 100%; }
.crop-container .cropper-view-box,
.crop-container .cropper-face { border-radius: 50%; }
.crop-controls {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .9rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.crop-controls label { font-size: .78rem; color: var(--muted); white-space: nowrap; }
.zoom-slider {
  flex: 1;
  min-width: 80px;
  accent-color: var(--accent);
  cursor: pointer;
}
.crop-ctrl-btn {
  padding: .35rem .6rem !important;
  font-size: .95rem !important;
  line-height: 1;
}
.crop-actions {
  display: flex;
  gap: .6rem;
  padding: 1rem 1.25rem;
  justify-content: flex-end;
}

.edit-profile-fields { display: none; flex-direction: column; gap: .8rem; }
.edit-profile-fields.open { display: flex; }

.edit-row {
  display: flex;
  gap: .6rem;
  margin-top: .5rem;
}

/* ── ADD LINK FORM ── */
.add-link-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.add-link-card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1.2rem;
}

.add-link-row {
  display: grid;
  grid-template-columns: 1fr 1.4fr auto;
  gap: .6rem;
  align-items: end;
}

@media (max-width: 500px) {
  .add-link-row { grid-template-columns: 1fr; }
}

/* ── LINKS LIST ── */
.links-section h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: .8rem;
  color: var(--muted);
  text-transform: uppercase;
  font-size: .78rem;
  letter-spacing: .07em;
}

.links-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.link-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .85rem 1rem;
  display: flex;
  align-items: center;
  gap: .8rem;
  transition: border-color .15s;
}

.link-item:hover { border-color: #444; }

.drag-handle {
  color: var(--muted);
  font-size: 1rem;
  cursor: grab;
  flex-shrink: 0;
}

.link-details { flex: 1; min-width: 0; }
.link-title { font-size: .92rem; font-weight: 600; }
.link-url {
  font-size: .78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  font-size: .9rem;
  padding: 2.5rem 1rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: .65rem 1.3rem;
  font-size: .88rem;
  color: var(--text);
  z-index: 100;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1), opacity .3s;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ── PUBLIC PROFILE ── */
.profile-page {
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% -10%, #1a3a2a 0%, #0f0f0f 60%);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3rem 1rem 4rem;
}

.profile-page .avatar {
  width: 80px;
  height: 80px;
  font-size: 2rem;
  margin-bottom: 1rem;
}

.profile-page .display-name {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: .3rem;
}

.profile-page .bio {
  color: var(--muted);
  font-size: .9rem;
  margin-bottom: 2rem;
  text-align: center;
  max-width: 360px;
}

.profile-links {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.profile-link-btn {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  text-align: center;
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  transition: background .15s, transform .1s, border-color .15s;
  cursor: pointer;
}

.profile-link-btn:hover {
  background: var(--surface2);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.profile-page-footer {
  margin-top: 3rem;
  font-size: .78rem;
  color: #444;
}

.profile-page-footer a {
  color: var(--accent);
  opacity: .7;
}

.not-found {
  text-align: center;
  padding: 4rem 1rem;
}

.not-found h1 { font-size: 4rem; color: var(--muted); }
.not-found p { color: var(--muted); margin-top: .5rem; }

/* ── SPINNER ── */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 4rem auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── ERROR BANNER ── */
.error-msg {
  background: rgba(255,92,92,.12);
  border: 1px solid rgba(255,92,92,.3);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: .85rem;
  padding: .6rem .9rem;
  margin-top: .5rem;
  display: none;
}

.error-msg.show { display: block; }
