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

:root {
  --brand:       #6366f1;
  --brand-hover: #4f46e5;
  --brand-faint: rgba(99,102,241,.08);
  --bg:          #f1f5f9;
  --card:        #ffffff;
  --border:      #e2e8f0;
  --text:        #0f172a;
  --text-muted:  #64748b;
  --text-faint:  #94a3b8;
  --header-bg:   #1e1b4b;
  --header-text: rgba(255,255,255,.9);
  --header-muted:rgba(255,255,255,.45);
  --input-bg:    #f8fafc;
  --radius:      10px;
  --shadow:      0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:   0 4px 12px rgba(0,0,0,.10);
  --font:        system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

[data-theme="dark"] {
  --bg:          #0f172a;
  --card:        #1e293b;
  --border:      #334155;
  --text:        #f1f5f9;
  --text-muted:  #94a3b8;
  --text-faint:  #475569;
  --header-bg:   #0d0c24;
  --input-bg:    #1e293b;
}

html { scroll-behavior: smooth; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.5; min-height: 100vh; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }

/* ── Header ────────────────────────────────────────────────────────────── */
#header {
  position: sticky; top: 0; z-index: 200;
  background: var(--header-bg);
  box-shadow: 0 1px 0 rgba(255,255,255,.06);
  height: 52px;
}
.header-inner {
  max-width: 1100px; margin: 0 auto; height: 100%;
  display: flex; align-items: center; gap: 12px; padding: 0 20px;
}
.logo {
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0; text-decoration: none !important;
}
.logo-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--brand); display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.logo-name { font-size: 16px; font-weight: 800; color: var(--header-text); letter-spacing: -.3px; }
.logo-tagline { font-size: 11px; color: var(--header-muted); margin-left: 2px; display: none; }
@media (min-width: 640px) { .logo-tagline { display: inline; } }

.search-wrap { flex: 1; max-width: 440px; margin: 0 8px; }
.search-wrap form { position: relative; }
.search-wrap input {
  width: 100%; padding: 7px 14px 7px 34px;
  border: 1px solid rgba(255,255,255,.12); border-radius: 20px;
  background: rgba(255,255,255,.08); color: var(--header-text);
  font-size: 13px; outline: none;
  transition: background .15s, border-color .15s;
}
.search-wrap input::placeholder { color: var(--header-muted); }
.search-wrap input:focus { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.25); }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--header-muted); pointer-events: none; }

.header-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-shrink: 0; }
.btn-ghost {
  padding: 6px 14px; border-radius: 20px; border: 1px solid rgba(255,255,255,.2);
  background: transparent; color: var(--header-text); font-size: 13px; font-weight: 600;
  transition: background .15s;
}
.btn-ghost:hover { background: rgba(255,255,255,.1); text-decoration: none; }
.btn-accent {
  padding: 6px 14px; border-radius: 20px; border: none;
  background: var(--brand); color: #fff; font-size: 13px; font-weight: 600;
  transition: background .15s; display: inline-block;
}
.btn-accent:hover { background: var(--brand-hover); text-decoration: none; }
.btn-icon-hdr {
  width: 34px; height: 34px; border: none; background: rgba(255,255,255,.07);
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  color: var(--header-muted); transition: background .15s, color .15s;
}
.btn-icon-hdr:hover { background: rgba(255,255,255,.14); color: var(--header-text); }

/* ── Page wrap ──────────────────────────────────────────────────────────── */
.page-wrap {
  max-width: 1100px; margin: 0 auto; padding: 24px 20px 48px;
  display: grid; grid-template-columns: 1fr 288px; gap: 28px; align-items: start;
}
@media (max-width: 900px) { .page-wrap { grid-template-columns: 1fr; } .sidebar { display: none; } }
@media (max-width: 640px) { .page-wrap { padding: 12px 0 48px; gap: 0; } }

/* ── Sort bar ───────────────────────────────────────────────────────────── */
.sort-bar {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 14px; margin-bottom: 12px;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
}
.sort-btn {
  display: flex; align-items: center; gap: 5px; padding: 5px 12px;
  border-radius: 20px; font-size: 13px; font-weight: 600;
  color: var(--text-muted); border: 1px solid transparent;
  transition: all .15s;
}
.sort-btn:hover { color: var(--brand); background: var(--brand-faint); text-decoration: none; }
.sort-btn.active { color: var(--brand); background: var(--brand-faint); border-color: rgba(99,102,241,.2); }
.sort-btn svg { width: 15px; height: 15px; }

/* ── Post card ──────────────────────────────────────────────────────────── */
.post-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 12px; overflow: hidden;
  border-left: 3px solid var(--sub-color, var(--border));
  transition: box-shadow .15s, transform .1s;
}
.post-card:hover { box-shadow: var(--shadow-md); }

.post-card-top {
  padding: 12px 14px 8px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.sub-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 700; color: var(--text);
  padding: 2px 8px 2px 4px; border-radius: 20px;
  background: var(--bg); border: 1px solid var(--border);
  text-decoration: none !important; white-space: nowrap;
}
.sub-chip-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.sub-chip:hover { border-color: var(--brand); color: var(--brand); }
.post-meta-sep { color: var(--text-faint); font-size: 11px; }
.post-age { font-size: 12px; color: var(--text-muted); }
.post-author { font-size: 12px; color: var(--text-muted); }
.post-author:hover { color: var(--brand); }

.post-card-body { padding: 0 14px 10px; display: flex; gap: 12px; align-items: flex-start; }
.post-title-wrap { flex: 1; min-width: 0; }
.post-title { font-size: 16px; font-weight: 600; color: var(--text); line-height: 1.4; }
.post-title:hover { color: var(--brand); text-decoration: none; }
.post-flair {
  display: inline-block; margin-right: 6px; padding: 1px 7px;
  border-radius: 10px; font-size: 11px; font-weight: 700; vertical-align: middle;
}
.flair-blue   { background: rgba(99,102,241,.12);  color: #6366f1; }
.flair-green  { background: rgba(34,197,94,.12);   color: #16a34a; }
.flair-red    { background: rgba(239,68,68,.12);   color: #dc2626; }
.flair-purple { background: rgba(168,85,247,.12);  color: #9333ea; }
.flair-gold   { background: rgba(234,179,8,.12);   color: #b45309; }
.flair-teal   { background: rgba(20,184,166,.12);  color: #0d9488; }

.post-thumb {
  width: 80px; height: 60px; border-radius: 8px; overflow: hidden;
  flex-shrink: 0; background: var(--bg);
}
.post-thumb-inner {
  width: 100%; height: 100%; display: flex; align-items: center;
  justify-content: center; font-size: 24px; background: var(--border);
}

.post-awards {
  padding: 0 14px 8px; display: flex; gap: 10px; font-size: 12px; font-weight: 600;
  color: var(--text-muted);
}

.post-card-footer {
  padding: 8px 10px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  background: var(--input-bg);
}
.vote-group {
  display: inline-flex; align-items: center; gap: 1px;
  border: 1px solid var(--border); border-radius: 20px; overflow: hidden; margin-right: 4px;
}
.vote-group a {
  display: flex; align-items: center; justify-content: center;
  padding: 4px 8px; font-size: 12px; font-weight: 700; color: var(--text-muted);
  transition: background .1s, color .1s; text-decoration: none !important;
}
.vote-group a:hover { background: var(--brand-faint); color: var(--brand); }
.vote-score {
  padding: 4px 8px; font-size: 12px; font-weight: 800; color: var(--text-muted);
  border-left: 1px solid var(--border); border-right: 1px solid var(--border);
  background: var(--card);
}
.action-pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px;
  border-radius: 20px; border: 1px solid transparent; font-size: 12px; font-weight: 600;
  color: var(--text-muted); background: transparent;
  transition: background .1s, color .1s, border-color .1s;
}
.action-pill:hover { background: var(--brand-faint); color: var(--brand); border-color: rgba(99,102,241,.2); text-decoration: none; }
.action-pill svg { width: 14px; height: 14px; }

/* ── Feed gate ──────────────────────────────────────────────────────────── */
.feed-gate {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 28px 24px; text-align: center; margin-bottom: 12px;
}
.feed-gate h3 { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.feed-gate p { color: var(--text-muted); font-size: 14px; margin-bottom: 18px; line-height: 1.6; }
.feed-gate-btns { display: flex; justify-content: center; gap: 10px; }
.feed-gate-btns .btn-ghost { border-color: var(--border); color: var(--text); }
.feed-gate-btns .btn-ghost:hover { background: var(--bg); }

/* ── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar { display: flex; flex-direction: column; gap: 14px; }
.sidebar-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.sidebar-card-head {
  padding: 14px 16px 0; display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px;
}
.sidebar-card-head svg { width: 14px; height: 14px; }
.sidebar-card-body { padding: 10px 16px 16px; }
.sidebar-card-body p { font-size: 13px; color: var(--text-muted); line-height: 1.6; margin-bottom: 12px; }
.sidebar-action {
  display: block; width: 100%; padding: 8px; margin-bottom: 8px; border-radius: 20px;
  font-size: 13px; font-weight: 700; text-align: center; border: none; cursor: pointer;
}
.sidebar-action.filled { background: var(--brand); color: #fff; }
.sidebar-action.filled:hover { background: var(--brand-hover); text-decoration: none; }
.sidebar-action.outline { background: transparent; color: var(--brand); border: 1px solid var(--brand); }
.sidebar-action.outline:hover { background: var(--brand-faint); text-decoration: none; }
.sidebar-action:last-child { margin-bottom: 0; }

.community-list { list-style: none; padding: 0 0 8px; }
.community-list li { display: flex; align-items: center; gap: 10px; padding: 7px 16px; cursor: pointer; }
.community-list li:hover { background: var(--bg); }
.community-list .c-icon { width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; color: #fff; }
.community-list .c-info { flex: 1; min-width: 0; }
.community-list .c-name { font-size: 13px; font-weight: 700; display: block; }
.community-list .c-name a { color: var(--text); }
.community-list .c-name a:hover { color: var(--brand); text-decoration: none; }
.community-list .c-members { font-size: 11px; color: var(--text-muted); }
.community-list .c-join { padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; border: 1px solid var(--brand); color: var(--brand); white-space: nowrap; display: inline-block; }
.community-list .c-join:hover { background: var(--brand-faint); text-decoration: none; }

.footer-links { padding: 10px 16px 14px; display: flex; flex-wrap: wrap; gap: 6px 10px; }
.footer-links a { font-size: 11px; color: var(--text-faint); }
.footer-links a:hover { color: var(--text-muted); text-decoration: none; }
.footer-copy { font-size: 11px; color: var(--text-faint); width: 100%; }

/* ── Auth pages ─────────────────────────────────────────────────────────── */
.auth-page {
  min-height: calc(100vh - 52px);
  display: flex; align-items: center; justify-content: center; padding: 24px 16px;
}
.auth-card {
  background: var(--card); border-radius: 16px; box-shadow: var(--shadow-md);
  display: flex; overflow: hidden; width: 100%; max-width: 780px;
}
.auth-art {
  width: 240px; flex-shrink: 0;
  background: linear-gradient(145deg, #312e81 0%, #4338ca 50%, #6366f1 100%);
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 18px; padding: 40px 20px; text-align: center;
}
.auth-art-logo { width: 56px; height: 56px; border-radius: 16px; background: rgba(255,255,255,.15); display: flex; align-items: center; justify-content: center; }
.auth-art h2 { color: #fff; font-size: 20px; font-weight: 800; }
.auth-art p { color: rgba(255,255,255,.65); font-size: 13px; line-height: 1.6; }
@media (max-width: 560px) { .auth-art { display: none; } }

.auth-form-wrap { flex: 1; padding: 36px 32px; }
@media (max-width: 480px) { .auth-form-wrap { padding: 28px 20px; } }
.auth-form-wrap h1 { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.auth-subtitle { font-size: 12px; color: var(--text-muted); margin-bottom: 22px; line-height: 1.6; }
.auth-subtitle a { color: var(--brand); }

.auth-error {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  background: rgba(239,68,68,.07); border: 1px solid rgba(239,68,68,.25);
  border-radius: 8px; color: #dc2626; font-size: 13px; margin-bottom: 16px;
}
[data-theme="dark"] .auth-error { color: #f87171; }

.btn-full { width: 100%; padding: 10px; border-radius: 10px; font-size: 14px; font-weight: 700; border: none; display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; transition: background .15s; }
.btn-full.primary { background: var(--brand); color: #fff; }
.btn-full.primary:hover { background: var(--brand-hover); }
.btn-full.google { background: var(--input-bg); color: var(--text); border: 1px solid var(--border); margin-bottom: 10px; }
.btn-full.google:hover { background: var(--border); }

.auth-divider { display: flex; align-items: center; gap: 10px; margin: 16px 0; color: var(--text-faint); font-size: 12px; font-weight: 600; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.form-group { margin-bottom: 14px; }
.form-group label { display: flex; justify-content: space-between; align-items: center; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-bottom: 5px; }
.form-group input { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--input-bg); color: var(--text); font-size: 14px; outline: none; transition: border-color .15s, box-shadow .15s; }
.form-group input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
.input-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.forgot-link { font-size: 11px; color: var(--brand); font-weight: 400; text-transform: none; letter-spacing: 0; }
.forgot-link:hover { text-decoration: underline; }

.remember-me { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); margin-bottom: 16px; cursor: pointer; }
.remember-me input { width: 14px; height: 14px; accent-color: var(--brand); cursor: pointer; }
.remember-me a { color: var(--brand); }

.auth-switch { font-size: 13px; color: var(--text-muted); margin-top: 16px; text-align: center; }
.auth-switch a { color: var(--brand); font-weight: 700; }

/* ── Toast ──────────────────────────────────────────────────────────────── */
.toast-wrap { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--text); color: var(--card); padding: 10px 20px; border-radius: 8px; font-size: 13px; font-weight: 500; white-space: nowrap; animation: toastIn .2s ease, toastOut .3s ease 2.7s forwards; }
@keyframes toastIn  { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }
@keyframes toastOut { to   { opacity:0; transform:translateY(8px); } }
