:root {
  --pink-50: #fff0f5;
  --pink-100: #ffd9e6;
  --pink-400: #ff6fa5;
  --pink-500: #ff3d7f;
  --pink-600: #e8235f;
  --purple-500: #a855f7;
  --ink: #3b1225;
  --ink-soft: #7a4a5c;
  --card-bg: #ffffff;
  --border: #ffd9e6;
  --shadow: 0 10px 30px rgba(232, 35, 95, 0.12);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Poppins", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, var(--pink-50), #fff 45%, #fef3ff 100%);
  position: relative;
  overflow-x: hidden;
}

.bg-hearts {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background-image:
    radial-gradient(circle at 10% 20%, rgba(255, 111, 165, 0.15) 0, transparent 40%),
    radial-gradient(circle at 90% 10%, rgba(168, 85, 247, 0.12) 0, transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(255, 111, 165, 0.12) 0, transparent 40%);
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 20px 20px;
}

.header {
  text-align: center;
  margin-bottom: 28px;
}

.header h1 {
  font-size: 2rem;
  margin: 0 0 6px;
  background: linear-gradient(90deg, var(--pink-600), var(--purple-500));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  color: var(--ink-soft);
  margin: 0;
  font-size: 0.95rem;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 24px;
}

/* ---------- Navbar ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
/* [hidden] dan .navbar sama-sama "menang" di cascade karena berasal dari
   stylesheet penulis (author) -- tanpa baris ini, display:flex di atas
   selalu mengalahkan display:none bawaan atribut hidden. */
.navbar[hidden] {
  display: none;
}

.nav-brand {
  font-weight: 700;
  color: var(--pink-600);
  margin-right: auto;
}

.nav-links {
  display: flex;
  gap: 4px;
}

.nav-link {
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-link.active,
.nav-link:hover {
  background: var(--pink-50);
  color: var(--pink-600);
}

.badge {
  background: var(--pink-500);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 7px;
  min-width: 18px;
  text-align: center;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--pink-100);
  background: var(--pink-50);
}

.nav-name {
  font-size: 0.85rem;
  font-weight: 600;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Forms (shared) ---------- */
label {
  display: block;
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-bottom: 4px;
}

input[type="text"],
input[type="password"],
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.95rem;
  margin-bottom: 12px;
  outline: none;
  transition: border-color 0.15s;
  resize: vertical;
}

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus {
  border-color: var(--pink-500);
}

input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.file-label {
  display: block;
  cursor: pointer;
  width: fit-content;
}
.file-label:hover .preview {
  border-color: var(--pink-400);
  background: var(--pink-100);
}

.preview {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 120px;
  aspect-ratio: 1;
  border: 2px dashed var(--pink-100);
  border-radius: 14px;
  overflow: hidden;
  background: var(--pink-50);
  color: var(--ink-soft);
  font-size: 0.75rem;
  text-align: center;
  margin: 0 0 14px;
}

.preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-placeholder {
  padding: 8px;
}

.hint {
  font-size: 0.75rem;
  color: var(--ink-soft);
  margin: 0 0 16px;
  line-height: 1.4;
}

.btn-primary {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(90deg, var(--pink-500), var(--purple-500));
  color: #fff;
  font-family: inherit;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.1s, opacity 0.15s;
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.btn-secondary {
  width: 100%;
  padding: 9px;
  border: 1.5px solid var(--pink-400);
  border-radius: 10px;
  background: #fff;
  color: var(--pink-600);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-secondary:hover {
  background: var(--pink-50);
}

.btn-ghost {
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
}

.btn-ghost:hover {
  background: var(--pink-50);
  color: var(--pink-600);
}

.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.error {
  color: var(--pink-600);
  background: var(--pink-50);
  border: 1px solid var(--pink-100);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.85rem;
  margin: 14px 0 0;
}

.success {
  color: #1a7a4c;
  background: #eafff3;
  border: 1px solid #b9f0d2;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.85rem;
  margin: 14px 0 0;
}

/* ---------- Auth view ---------- */
.auth-card {
  max-width: 420px;
  margin: 0 auto;
}

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  background: var(--pink-50);
  padding: 4px;
  border-radius: 12px;
}

.tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 9px;
  border-radius: 9px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink-soft);
  cursor: pointer;
}

.tab-btn.active {
  background: #fff;
  color: var(--pink-600);
  box-shadow: 0 2px 8px rgba(232, 35, 95, 0.1);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ---------- Home: grid user ---------- */
.user-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.user-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  text-align: center;
}

.user-photo {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--pink-100);
  margin-bottom: 10px;
}

.user-name {
  font-weight: 600;
  margin: 0 0 2px;
  word-break: break-word;
}

.user-username {
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin: 0 0 8px;
}

.user-bio {
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin: 0 0 12px;
  line-height: 1.4;
}

/* ---------- Inbox ---------- */
.message-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message-item {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}

.message-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.message-from {
  font-weight: 600;
  color: var(--pink-600);
  font-size: 0.85rem;
}

.message-time {
  font-size: 0.72rem;
  color: var(--ink-soft);
}

.message-text {
  margin: 0 0 10px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- Modal kirim pesan ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(59, 18, 37, 0.4);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal-overlay[hidden] {
  display: none;
}

.modal {
  width: 100%;
  max-width: 440px;
  position: relative;
  margin: 0;
}

.modal h2 {
  font-size: 1.05rem;
  margin: 0 0 16px;
  padding-right: 24px;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  border: none;
  background: var(--pink-50);
  color: var(--ink-soft);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.85rem;
}

.char-count {
  text-align: right;
  font-size: 0.72rem;
  color: var(--ink-soft);
  margin: -6px 0 12px;
}

/* ---------- Empty state ---------- */
.empty-state {
  color: var(--ink-soft);
  font-size: 0.9rem;
  text-align: center;
  padding: 30px 10px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: #fff;
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 60;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
}

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

.footer {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.75rem;
  padding: 20px;
}

@media (max-width: 640px) {
  .navbar {
    justify-content: center;
  }

  .nav-brand {
    width: 100%;
    text-align: center;
    margin-right: 0;
  }

  .nav-name {
    display: none;
  }
}
