/* === Reset & Base === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0a0a1a;
  --bg-card: rgba(255,255,255,0.04);
  --bg-card-hover: rgba(255,255,255,0.08);
  --border: rgba(167,139,250,0.15);
  --border-active: rgba(167,139,250,0.4);
  --text: #e0e0f0;
  --text-muted: #8888aa;
  --text-dim: #555570;
  --accent: #a78bfa;
  --accent2: #60a5fa;
  --accent3: #f9a8d4;
  --danger: #ef4444;
  --success: #22c55e;
  --radius: 12px;
  --radius-sm: 8px;
  --max-width: 600px;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

#starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

#app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* === Typography === */
h1 {
  font-size: 2.2rem;
  background: linear-gradient(135deg, var(--accent), var(--accent2), var(--accent3));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

h2 {
  font-size: 1.4rem;
  color: var(--accent);
  margin-bottom: 1rem;
}

h3 {
  font-size: 1.1rem;
  color: var(--accent2);
  margin-bottom: 0.5rem;
}

a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === Layout === */
.page {
  width: 100%;
  max-width: var(--max-width);
  padding: 2rem 1rem;
  padding-top: 4rem;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  text-align: center;
}

/* === Cards === */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  margin-bottom: 0.75rem;
  transition: all 0.2s;
}
.card:hover { background: var(--bg-card-hover); }
.card-clickable { cursor: pointer; }
.card-clickable:hover { border-color: var(--border-active); }

/* === Forms === */
.form-group {
  margin-bottom: 1rem;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

input, select, textarea {
  width: 100%;
  padding: 0.7rem 1rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.5rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #0a0a1a;
  font-weight: 600;
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }

.btn-secondary {
  background: rgba(255,255,255,0.08);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: rgba(255,255,255,0.12); }

.btn-google {
  background: rgba(255,255,255,0.08);
  color: var(--text);
  font-weight: 600;
  border: 1px solid var(--border);
}
.btn-google:hover { background: rgba(255,255,255,0.12); }
.btn-google svg { flex-shrink: 0; }

.google-btn-wrapper {
  position: relative;
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
}
.google-btn-overlay {
  position: absolute;
  inset: 0;
  opacity: 0;
  z-index: 2;
  overflow: hidden;
}
.google-btn-overlay iframe {
  width: 100% !important;
  height: 100% !important;
}

.btn-danger {
  background: rgba(239,68,68,0.15);
  color: var(--danger);
  border: 1px solid rgba(239,68,68,0.3);
}
.btn-danger:hover { background: rgba(239,68,68,0.25); }

.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.85rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* === Navigation === */
.nav-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1.1rem 1rem;
  background: rgba(10,10,26,0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.nav-bar .logo {
  font-size: 1.1rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  cursor: pointer;
}

.nav-links {
  position: fixed;
  top: 0.85rem;
  right: 1rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  z-index: 100;
}

.nav-link {
  position: relative;
  padding: 0.5rem;
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
  background: none;
  font-family: inherit;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-link:hover { color: var(--text); border-color: var(--border); background: rgba(255,255,255,0.05); }
.nav-link.active { color: var(--accent); border-color: var(--border-active); }

.badge-count {
  position: absolute;
  top: -4px;
  right: -4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--bg);
  font-size: 0.7rem;
  font-weight: 700;
}

/* === Landing Page === */
.hero {
  text-align: center;
  padding: 3rem 0 2rem;
}
.hero-emoji { font-size: 4rem; margin-bottom: 1rem; }
.hero p { color: var(--text-muted); margin: 1rem 0; max-width: 400px; }

.preview-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin: 2rem 0;
  text-align: center;
}
.preview-box input[type="date"] {
  max-width: 250px;
  margin: 0 auto;
  display: block;
}
.preview-result {
  margin-top: 1rem;
  font-size: 1.3rem;
  color: var(--accent);
  font-weight: 600;
}

/* === Twin List === */
.twin-card {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.twin-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--bg);
  font-size: 1.1rem;
  flex-shrink: 0;
}
.twin-info { flex: 1; }
.twin-name { font-weight: 600; }
.twin-meta { font-size: 0.8rem; color: var(--text-muted); }
.twin-blocked { opacity: 0.5; }

/* === Chat === */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 120px);
  max-height: 700px;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
}
.chat-back {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0.2rem;
}
.chat-back:hover { color: var(--text); }

.chat-disclaimer {
  background: rgba(96,165,250,0.1);
  border: 1px solid rgba(96,165,250,0.2);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  line-height: 1.5;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.msg {
  max-width: 80%;
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  line-height: 1.5;
  word-wrap: break-word;
}
.msg-mine {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(167,139,250,0.2), rgba(96,165,250,0.2));
  border: 1px solid rgba(167,139,250,0.2);
}
.msg-theirs {
  align-self: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border);
}
.msg-system {
  align-self: center;
  background: rgba(249,168,212,0.1);
  border: 1px solid rgba(249,168,212,0.2);
  color: var(--accent3);
  font-size: 0.85rem;
  text-align: center;
}
.msg-time {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 0.2rem;
}

.shared-contact-card {
  background: rgba(34,197,94,0.1);
  border: 1px solid rgba(34,197,94,0.2);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  margin: 0.3rem 0;
}
.shared-contact-card .type {
  font-size: 0.75rem;
  color: var(--success);
  text-transform: uppercase;
  font-weight: 600;
}
.shared-contact-card .value {
  font-size: 0.95rem;
  color: var(--text);
  margin-top: 0.2rem;
}

.chat-input-area {
  display: flex;
  gap: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
.chat-input-area input {
  flex: 1;
}
.chat-actions {
  display: flex;
  gap: 0.3rem;
  margin-top: 0.5rem;
}

/* === Contact Share Modal === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal {
  background: #12122a;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 400px;
  width: 100%;
  animation: fadeIn 0.2s ease;
}
.modal h3 { margin-bottom: 1rem; }

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.5rem 0;
}
.checkbox-item input[type="checkbox"] {
  width: auto;
  accent-color: var(--accent);
}
.checkbox-label { font-size: 0.95rem; }
.checkbox-type { font-size: 0.75rem; color: var(--text-muted); }

/* === Profile === */
.contact-list {
  margin-top: 1rem;
}
.contact-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}
.contact-item:last-child { border-bottom: none; }
.contact-type {
  font-size: 0.75rem;
  color: var(--accent);
  text-transform: uppercase;
  font-weight: 600;
}

/* === Notifications === */
.notif-item {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}
.notif-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  margin-top: 0.5rem;
}
.notif-dot.read { background: var(--text-dim); }
.notif-body { flex: 1; }
.notif-title { font-weight: 600; font-size: 0.95rem; }
.notif-text { font-size: 0.85rem; color: var(--text-muted); }
.notif-time { font-size: 0.75rem; color: var(--text-dim); }

/* === Status Messages === */
.alert {
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.alert-error {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.2);
  color: var(--danger);
}
.alert-success {
  background: rgba(34,197,94,0.1);
  border: 1px solid rgba(34,197,94,0.2);
  color: var(--success);
}
.alert-info {
  background: rgba(96,165,250,0.1);
  border: 1px solid rgba(96,165,250,0.2);
  color: var(--accent2);
}

/* === Empty States === */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state .emoji { font-size: 3rem; margin-bottom: 1rem; }

/* === Divider === */
.divider {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 360px;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border);
}
.divider span {
  padding: 0 0.75rem;
  white-space: nowrap;
}

/* === Utility === */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.85rem; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 0.5rem; }

/* === Scrollbar === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-active); }

/* === Fixed Top Buttons === */
.top-left-buttons {
  position: fixed;
  top: 0.85rem;
  left: 1rem;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.icon-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-muted);
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.by-ahorn-badge {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.45rem 0.6rem;
  border-radius: 50vh;
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
}
.by-ahorn-badge:hover {
  color: var(--text);
  border-color: var(--accent);
  text-decoration: none;
}

/* === Share Modal === */
.share-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 400;
}
.share-overlay.hidden,
.share-modal.hidden {
  display: none;
}

.share-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 500;
  background: #12122a;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  text-align: center;
  width: 300px;
  max-width: 90vw;
}
.share-modal h3 {
  color: var(--text);
  margin-bottom: 1rem;
  font-size: 1.2rem;
}
.share-modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  transition: color 0.2s;
}
.share-modal-close:hover { color: var(--text); }

.share-qr { margin-bottom: 1rem; }
.share-qr img {
  border-radius: 8px;
  background: white;
  padding: 8px;
}

.share-url-row {
  display: flex;
  gap: 0.5rem;
}
.share-url-row input {
  flex: 1;
  padding: 0.5rem 0.6rem;
  font-size: 0.8rem;
  min-width: 0;
}
.share-url-row button {
  padding: 0.5rem 0.8rem;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none;
  border-radius: var(--radius-sm);
  color: #0a0a1a;
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.2s;
}
.share-url-row button:hover { opacity: 0.9; }

/* === Responsive === */
@media (max-width: 480px) {
  h1 { font-size: 1.8rem; }
  .page { padding: 1rem 0.75rem; }
  .msg { max-width: 90%; }
}
