/* ── Google Fonts ─────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Fraunces:ital,wght@0,400;0,600;0,700;1,400&display=swap');

/* ── Design Tokens ────────────────────────────────────────────────────────── */
:root {
  --green:        #16a34a;
  --green-light:  #dcfce7;
  --green-dark:   #15803d;
  --blue:         #0369a1;
  --blue-light:   #e0f2fe;
  --red:          #dc2626;
  --red-light:    #fee2e2;
  --amber:        #d97706;
  --amber-light:  #fef3c7;

  --bg:           #f8fafc;
  --bg-alt:       #f1f5f9;
  --card:         #ffffff;
  --border:       #e2e8f0;
  --border-dark:  #cbd5e1;

  --text:         #0f172a;
  --text-muted:   #64748b;
  --text-faint:   #94a3b8;

  --radius:       8px;
  --radius-lg:    12px;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow:       0 4px 12px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.05);
  --shadow-lg:    0 10px 30px rgba(0,0,0,.10), 0 4px 8px rgba(0,0,0,.06);

  --font-body:    'Outfit', sans-serif;
  --font-display: 'Fraunces', serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  --nav-h:        60px;
  --sidebar-w:    240px;
  --content-max:  860px;
}

/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--green-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }
code, pre { font-family: var(--font-mono); }

/* ── Navigation ───────────────────────────────────────────────────────────── */
.nav {
  position: sticky; top: 0; z-index: 100;
  height: var(--nav-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}
.nav-brand {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-display);
  font-size: 1.35rem; font-weight: 700;
  color: var(--text); text-decoration: none;
}
.nav-brand-dot { color: var(--green); }
.nav-links { display: flex; gap: 2px; margin-left: 8px; }
.nav-link {
  padding: 6px 12px; border-radius: var(--radius);
  font-size: .875rem; font-weight: 500;
  color: var(--text-muted);
  transition: color .15s, background .15s;
}
.nav-link:hover, .nav-link.active {
  color: var(--text); background: var(--bg-alt);
  text-decoration: none;
}
.nav-spacer { flex: 1; }
.nav-search {
  display: flex; align-items: center;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px; gap: 8px;
  width: 220px;
  transition: border-color .15s, box-shadow .15s;
}
.nav-search:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(22,163,74,.12);
}
.nav-search input {
  border: none; background: none; outline: none;
  font-size: .875rem; color: var(--text); width: 100%;
}
.nav-actions { display: flex; align-items: center; gap: 8px; }
.nav-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700;
  cursor: pointer; overflow: hidden;
  border: 2px solid var(--border);
  color: #fff;
  flex-shrink: 0;
}
.nav-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 7px; padding: 9px 18px;
  border-radius: var(--radius); border: none;
  font-size: .875rem; font-weight: 600;
  transition: all .15s; white-space: nowrap; line-height: 1;
}
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); text-decoration: none; color: #fff; }
.btn-secondary {
  background: var(--bg-alt); color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); text-decoration: none; }
.btn-outline {
  background: transparent; color: var(--green-dark);
  border: 1.5px solid var(--green-dark);
}
.btn-outline:hover { background: var(--green-light); text-decoration: none; color: var(--green-dark); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #b91c1c; text-decoration: none; color: #fff; }
.btn-ghost { background: none; border: none; color: var(--text-muted); padding: 6px 10px; }
.btn-ghost:hover { color: var(--text); background: var(--bg-alt); }
.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn-lg { padding: 12px 28px; font-size: 1rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-google {
  background: #fff; color: #3c4043;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.btn-google:hover { background: #f8f9fa; box-shadow: var(--shadow); text-decoration: none; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-body { padding: 24px; }
.card-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: .9375rem;
  display: flex; align-items: center; justify-content: space-between;
}
.card-footer {
  padding: 12px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-alt);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-label { font-size: .875rem; font-weight: 500; color: var(--text); }
.form-input {
  padding: 9px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .9375rem; color: var(--text);
  background: var(--card); outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.form-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(22,163,74,.12);
}
.form-input.is-error { border-color: var(--red); }
textarea.form-input { resize: vertical; min-height: 100px; }
.form-hint { font-size: .8rem; color: var(--text-muted); }
.form-error { font-size: .8rem; color: var(--red); font-weight: 500; }

/* ── Tags / Badges ────────────────────────────────────────────────────────── */
.tag {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .75rem; font-weight: 600; letter-spacing: .01em;
}
.tag-green  { background: var(--green-light);  color: var(--green-dark); }
.tag-blue   { background: var(--blue-light);   color: var(--blue); }
.tag-amber  { background: var(--amber-light);  color: var(--amber); }
.tag-gray   { background: var(--bg-alt); color: var(--text-muted); border: 1px solid var(--border); }
.tag-red    { background: var(--red-light);    color: var(--red); }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: var(--radius);
  font-size: .875rem; display: flex; align-items: flex-start; gap: 10px;
}
.alert-success { background: var(--green-light); color: var(--green-dark); border: 1px solid #86efac; }
.alert-error   { background: var(--red-light);   color: var(--red);        border: 1px solid #fca5a5; }
.alert-info    { background: var(--blue-light);  color: var(--blue);       border: 1px solid #7dd3fc; }
.alert-warning { background: var(--amber-light); color: var(--amber);      border: 1px solid #fcd34d; }

/* ── Avatar ───────────────────────────────────────────────────────────────── */
.avatar {
  border-radius: 50%; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; flex-shrink: 0; color: #fff;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm  { width: 28px; height: 28px; font-size: .7rem; }
.avatar-md  { width: 36px; height: 36px; font-size: .85rem; }
.avatar-lg  { width: 48px; height: 48px; font-size: 1.1rem; }
.avatar-xl  { width: 80px; height: 80px; font-size: 1.8rem; }

/* ── Vote Widget ──────────────────────────────────────────────────────────── */
.vote-widget {
  display: flex; flex-direction: column; align-items: center;
  gap: 3px; min-width: 44px;
}
.vote-btn {
  width: 36px; height: 36px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: all .15s; font-size: .85rem;
}
.vote-btn:hover { border-color: var(--green); color: var(--green); background: var(--green-light); }
.vote-btn.up.active { border-color: var(--green); background: var(--green-light); color: var(--green-dark); }
.vote-btn.down.active { border-color: var(--red); background: var(--red-light); color: var(--red); }
.vote-count { font-weight: 700; font-size: 1rem; color: var(--text); line-height: 1; }

/* ── Page layout ──────────────────────────────────────────────────────────── */
.page-wrap { max-width: 1200px; margin: 0 auto; padding: 32px 24px; }
.page-header { margin-bottom: 28px; }
.page-header h1 {
  font-family: var(--font-display);
  font-size: 1.75rem; font-weight: 700; line-height: 1.2;
}
.page-header p { color: var(--text-muted); margin-top: 6px; }
.page-header-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }

.two-col { display: grid; grid-template-columns: 1fr var(--sidebar-w); gap: 28px; align-items: start; }
.two-col-wide { grid-template-columns: 1fr 280px; }

/* ── Sidebar widget ───────────────────────────────────────────────────────── */
.widget { margin-bottom: 20px; }
.widget-title {
  font-size: .8rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-muted);
  padding: 0 4px 10px;
}
.widget-list { display: flex; flex-direction: column; gap: 2px; }
.widget-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 12px; border-radius: var(--radius);
  font-size: .875rem; color: var(--text-muted);
  transition: background .12s;
}
.widget-item:hover { background: var(--bg-alt); color: var(--text); text-decoration: none; }
.widget-item.active { background: var(--green-light); color: var(--green-dark); font-weight: 500; }
.widget-count {
  font-size: .75rem; background: var(--bg-alt);
  border: 1px solid var(--border); border-radius: 20px;
  padding: 1px 8px; color: var(--text-muted);
}

/* ── Code block ───────────────────────────────────────────────────────────── */
.code-block {
  background: #0f172a; color: #e2e8f0;
  border-radius: var(--radius); padding: 16px;
  font-family: var(--font-mono); font-size: .85rem;
  overflow-x: auto; line-height: 1.6;
}
code {
  background: var(--bg-alt); padding: 2px 6px;
  border-radius: 4px; font-size: .875em;
  border: 1px solid var(--border);
}

/* ── Divider ──────────────────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ── Spinner ──────────────────────────────────────────────────────────────── */
.spinner {
  display: inline-block; width: 20px; height: 20px;
  border: 2.5px solid var(--border); border-top-color: var(--green);
  border-radius: 50%; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 24px; color: var(--text-muted); }
.empty-state svg { margin: 0 auto 16px; color: var(--text-faint); }
.empty-state h3 { font-size: 1.1rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }

/* ── Tabs ─────────────────────────────────────────────────────────────────── */
.tabs {
  display: flex; gap: 2px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}
.tab {
  padding: 10px 18px; font-size: .875rem; font-weight: 500;
  color: var(--text-muted); border: none; background: none;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: all .15s; cursor: pointer;
  border-radius: var(--radius) var(--radius) 0 0;
}
.tab:hover { color: var(--text); background: var(--bg-alt); }
.tab.active { color: var(--green-dark); border-bottom-color: var(--green); }

/* ── Post list item ───────────────────────────────────────────────────────── */
.topic-item {
  display: flex; gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.topic-item:last-child { border-bottom: none; }
.topic-item:hover { background: #fafcff; }
.topic-main { flex: 1; min-width: 0; }
.topic-title {
  font-size: .9375rem; font-weight: 600; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.topic-title:hover { color: var(--green-dark); }
.topic-meta { display: flex; align-items: center; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.topic-meta-text { font-size: .8rem; color: var(--text-muted); }
.topic-stats { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 48px; }
.topic-stat { font-size: .75rem; color: var(--text-muted); text-align: center; }
.topic-stat-num { font-weight: 700; font-size: .9rem; color: var(--text); }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .two-col, .two-col-wide { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .page-wrap { padding: 16px 12px; }
  .nav-search { display: none; }
  .nav-links .nav-link { padding: 6px 8px; font-size: .8rem; }
  .nav { padding: 0 12px; }
}
