@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
  --teal:       #0d9488;
  --teal-d:     #0f766e;
  --teal-l:     #ccfbf1;
  --teal-xl:    #f0fdfb;
  --white:      #ffffff;
  --bg:         #f7fffe;
  --gray-50:    #f9fafb;
  --gray-100:   #f1f5f4;
  --gray-200:   #e2e8e7;
  --gray-400:   #94a3a2;
  --gray-500:   #64748b;
  --gray-700:   #334155;
  --gray-900:   #0f172a;
  --red:        #ef4444;
  --green:      #10b981;
  --r:          12px;
  --r-lg:       18px;
  --r-xl:       24px;
  --r-pill:     100px;
  --sh:         0 2px 12px rgba(13,148,136,0.1);
  --sh-lg:      0 8px 32px rgba(13,148,136,0.14);
}

*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
html { scroll-behavior:smooth; }

body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg);
  color: var(--gray-900);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; }

/* ── NAVBAR (desktop) ── */
.navbar {
  position: sticky; top: 0; z-index: 100;
  height: 62px;
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(13,148,136,0.1);
  display: flex; align-items: center;
  padding: 0 32px;
  gap: 16px;
}
.nav-brand {
  font-size: 1.35rem; font-weight: 800;
  color: var(--teal); letter-spacing: -0.03em;
  display: flex; align-items: center; gap: 8px;
  margin-right: auto;
}
.nav-brand span {
  width: 9px; height: 9px;
  background: var(--teal); border-radius: 50%;
  display: inline-block;
}
.nav-actions { display: flex; align-items: center; gap: 10px; }

/* ── BOTTOM NAV (mobile) ── */
.mobile-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  background: white;
  border-top: 1px solid var(--gray-200);
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
  height: calc(60px + max(0px, env(safe-area-inset-bottom)));
}
.mobile-nav-inner {
  display: flex; justify-content: space-around; align-items: center;
}
.mob-nav-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; cursor: pointer;
  color: var(--gray-400); font-size: 0.62rem; font-weight: 600;
  font-family: 'Outfit', sans-serif;
  padding: 6px 16px; border-radius: var(--r);
  transition: color 0.2s;
  text-decoration: none;
}
.mob-nav-btn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.mob-nav-btn.active, .mob-nav-btn:hover { color: var(--teal); }
.mob-nav-btn.active svg { stroke: var(--teal); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 20px; border-radius: var(--r-pill);
  font-family: 'Outfit', sans-serif; font-size: 0.875rem; font-weight: 600;
  cursor: pointer; border: none; transition: all 0.2s; white-space: nowrap;
  text-decoration: none;
}
.btn-primary { background: var(--teal); color: white; box-shadow: 0 2px 10px rgba(13,148,136,0.3); }
.btn-primary:hover { background: var(--teal-d); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(13,148,136,0.38); }
.btn-outline { background: transparent; color: var(--teal); border: 1.5px solid var(--teal); }
.btn-outline:hover { background: var(--teal-xl); }
.btn-ghost { background: transparent; color: var(--gray-500); }
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-700); }
.btn-danger { background: #fef2f2; color: var(--red); border: 1.5px solid #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-lg { padding: 13px 30px; font-size: 1rem; }

/* ── FORMS ── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--gray-500); margin-bottom: 5px; letter-spacing: 0.05em; text-transform: uppercase; }
.form-input {
  width: 100%; padding: 11px 14px;
  border: 1.5px solid var(--gray-200); border-radius: var(--r);
  font-family: 'Outfit', sans-serif; font-size: 0.95rem; color: var(--gray-900);
  background: white; outline: none; transition: border-color 0.2s, box-shadow 0.2s;
}
.form-input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(13,148,136,0.1); }
.form-input.err { border-color: var(--red); box-shadow: 0 0 0 3px rgba(239,68,68,0.08); }
textarea.form-input { resize: vertical; min-height: 100px; line-height: 1.6; }
.form-err { font-size: 0.78rem; color: var(--red); margin-top: 4px; display: flex; align-items: center; gap: 4px; }
.form-err::before { content: '⚠'; }

/* ── CARD ── */
.card { background: white; border-radius: var(--r-xl); border: 1px solid rgba(13,148,136,0.08); box-shadow: var(--sh); }
.card-body { padding: 28px; }

/* ── Q-CARD ── */
.q-card {
  background: white; border-radius: var(--r-xl);
  border: 1px solid rgba(13,148,136,0.1);
  padding: 22px 24px 18px 28px;
  margin-bottom: 12px;
  position: relative; overflow: hidden;
  transition: box-shadow 0.2s, transform 0.2s;
}
.q-card::before {
  content: ''; position: absolute;
  left: 0; top: 0; bottom: 0; width: 4px;
  background: linear-gradient(180deg, var(--teal) 0%, #2dd4bf 100%);
}
.q-card:hover { box-shadow: var(--sh-lg); transform: translateY(-1px); }
.q-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.q-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--teal-l); color: var(--teal-d);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.8rem; flex-shrink: 0;
  overflow: hidden;
}
.q-avatar img { width: 100%; height: 100%; object-fit: cover; }
.q-author { font-weight: 700; font-size: 0.9rem; }
.q-date { font-size: 0.75rem; color: var(--gray-400); }
.q-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 6px; line-height: 1.4; }
.q-preview { font-size: 0.875rem; color: var(--gray-500); line-height: 1.6; margin-bottom: 14px; }
.q-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.vote-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 13px; border-radius: var(--r-pill);
  font-size: 0.78rem; font-weight: 600; cursor: pointer;
  border: 1.5px solid var(--gray-200); background: white; color: var(--gray-500);
  font-family: 'Outfit', sans-serif; transition: all 0.18s;
}
.vote-btn:hover { border-color: var(--teal); color: var(--teal); background: var(--teal-xl); }
.vote-btn.up-active { border-color: var(--teal); color: var(--teal); background: var(--teal-xl); }
.vote-btn.down-active { border-color: var(--red); color: var(--red); background: #fef2f2; }

/* ── DROPDOWN ── */
.dropdown { position: relative; }
.dd-menu {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: white; border: 1px solid var(--gray-200);
  border-radius: var(--r-lg); box-shadow: var(--sh-lg);
  min-width: 195px; overflow: hidden; z-index: 300;
  opacity: 0; transform: translateY(-6px) scale(0.97);
  pointer-events: none; transition: all 0.18s;
}
.dd-menu.open { opacity: 1; transform: translateY(0) scale(1); pointer-events: all; }
.dd-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; font-size: 0.875rem; font-weight: 500;
  color: var(--gray-700); cursor: pointer; border: none;
  background: none; width: 100%; font-family: 'Outfit', sans-serif;
  transition: background 0.15s; text-decoration: none;
}
.dd-item:hover { background: var(--teal-xl); color: var(--teal); }
.dd-item.red:hover { background: #fef2f2; color: var(--red); }
.dd-sep { border: none; border-top: 1px solid var(--gray-100); margin: 4px 0; }

/* ── AVATAR CIRCLE ── */
.av-circle {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--teal-l); color: var(--teal-d);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.85rem; cursor: pointer;
  overflow: hidden; border: 2px solid var(--teal-l);
  transition: border-color 0.2s;
}
.av-circle:hover { border-color: var(--teal); }
.av-circle img { width: 100%; height: 100%; object-fit: cover; }

/* ── MODAL ── */
.modal-bg {
  position: fixed; inset: 0; background: rgba(15,23,42,0.4);
  backdrop-filter: blur(4px); z-index: 400;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity 0.22s;
}
.modal-bg.open { opacity: 1; pointer-events: all; }
.modal {
  background: white; border-radius: var(--r-xl);
  width: 100%; max-width: 520px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
  transform: scale(0.96) translateY(12px);
  transition: transform 0.22s;
  max-height: 90vh; overflow-y: auto;
}
.modal-bg.open .modal { transform: scale(1) translateY(0); }
.modal-head {
  padding: 22px 24px 0;
  display: flex; justify-content: space-between; align-items: center;
}
.modal-title { font-size: 1.1rem; font-weight: 700; }
.modal-x {
  width: 30px; height: 30px; border-radius: 50%;
  border: none; background: var(--gray-100); color: var(--gray-500);
  cursor: pointer; font-size: 1rem; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.modal-x:hover { background: var(--gray-200); }
.modal-body { padding: 18px 24px 24px; }

/* ── TOAST ── */
.toast {
  position: fixed; z-index: 9999;
  padding: 12px 20px; border-radius: var(--r);
  font-size: 0.875rem; font-weight: 600; color: white;
  opacity: 0; transform: translateY(8px);
  transition: opacity 0.25s, transform 0.25s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: var(--teal); }
.toast-error   { background: var(--red); }

/* desktop toast position */
@media (min-width: 641px) {
  .toast { bottom: 28px; right: 28px; }
}
/* mobile toast position */
@media (max-width: 640px) {
  .toast { bottom: 80px; left: 50%; transform: translateX(-50%) translateY(8px); }
  .toast.show { transform: translateX(-50%) translateY(0); }
}

/* ── PAGE WRAP ── */
.page-wrap { max-width: 720px; margin: 0 auto; padding: 32px 20px; }
.page-wide  { max-width: 960px; margin: 0 auto; padding: 32px 20px; }

/* ── BADGE ── */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: var(--r-pill); font-size: 0.72rem; font-weight: 600; }
.badge-teal { background: var(--teal-l); color: var(--teal-d); }

/* ── EMPTY STATE ── */
.empty { text-align: center; padding: 60px 20px; color: var(--gray-400); }
.empty-icon { font-size: 2.8rem; margin-bottom: 12px; }
.empty h3 { font-size: 1rem; color: var(--gray-500); font-weight: 600; margin-bottom: 6px; }
.empty p { font-size: 0.85rem; }

/* ── DIVIDER ── */
hr { border: none; border-top: 1px solid var(--gray-200); margin: 20px 0; }

/* ── ANSWER CARD ── */
.ans-card {
  background: var(--gray-50); border-radius: var(--r-lg);
  border: 1px solid var(--gray-200); padding: 16px 18px;
  margin-bottom: 10px;
}
.ans-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.ans-author { font-weight: 600; font-size: 0.85rem; }
.ans-date { font-size: 0.72rem; color: var(--gray-400); }
.ans-body { font-size: 0.9rem; color: var(--gray-700); line-height: 1.65; }

/* ═══════════════════════════════
   MOBILE OVERRIDES
═══════════════════════════════ */
@media (max-width: 640px) {
  .navbar { display: none; }
  .mobile-nav { display: block; }

  body { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }

  .page-wrap, .page-wide { padding: 16px 14px; }

  .card-body { padding: 18px; }

  .q-card { padding: 16px 16px 14px 20px; border-radius: var(--r-lg); }
  .q-title { font-size: 0.98rem; }

  .btn-lg { padding: 12px 24px; }

  /* Auth pages on mobile — full screen card */
  .auth-wrap { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px 16px; }
  .auth-card { border-radius: var(--r-xl); }

  /* Modal on mobile — bottom sheet */
  .modal-bg { align-items: flex-end; padding: 0; }
  .modal {
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    max-width: 100%; max-height: 92vh;
  }
}

/* ═══════════════════════════════
   DESKTOP AUTH
═══════════════════════════════ */
@media (min-width: 641px) {
  .auth-wrap {
    min-height: 100vh; display: flex;
    align-items: center; justify-content: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, var(--teal-xl) 0%, var(--bg) 60%);
  }
  .auth-card { width: 100%; max-width: 440px; }
}
