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

:root {
  --bg:           #0a0a0c;
  --surface:      #111114;
  --surface2:     #18181c;
  --surface3:     #202024;
  --border:       #2c2c32;
  --border-light: #404048;
  --accent:       #8e8ea8;
  --accent-dim:   #6a6a80;
  --accent-glow:  rgba(180,180,210,0.08);
  --accent-text:  #d0d0e8;
  --text:         #ececf4;
  --text-muted:   #8888a0;
  --text-faint:   #46465a;
  --success:      #6ee7a0;
  --error:        #f87171;
  --warning:      #fbbf24;
  --radius:       10px;
  --radius-sm:    6px;
  --radius-lg:    16px;
  --shadow:       0 4px 32px rgba(0,0,0,0.7);
  --shadow-sm:    0 2px 10px rgba(0,0,0,0.4);
}

html { scroll-behavior: smooth; }

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

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

img { max-width: 100%; display: block; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ── Navbar ── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 28px;
  height: 60px;
  background: rgba(12,12,16,0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
}
.logo-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1;
  gap: 1px;
}
.logo-main {
  font-size: 1.2rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  background: linear-gradient(135deg, #ffffff 0%, #d8d8e8 40%, #a0a0b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-transform: uppercase;
}
.logo-sub {
  font-size: 0.52rem;
  font-weight: 400;
  color: var(--text-faint);
  letter-spacing: 0.22em;
  text-transform: lowercase;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 20px;
  flex: 1;
}

.nav-link {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  transition: color 0.15s, background 0.15s;
  text-decoration: none;
}
.nav-link:hover { color: var(--text); background: var(--surface2); }
.nav-link.active { color: var(--text); background: var(--surface2); border: 1px solid var(--border); }

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

.nav-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s;
  text-decoration: none;
}
.nav-user:hover { color: var(--text); background: var(--surface2); }

.nav-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  flex-shrink: 0;
}
.nav-avatar-placeholder {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface3);
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, #c8c8d8 0%, #9898b0 100%); color: #0a0a0c; font-weight: 700; border: 1px solid rgba(255,255,255,0.15); }
.btn-primary:hover:not(:disabled) { background: linear-gradient(135deg, #e0e0f0 0%, #b0b0c8 100%); color: #0a0a0c; transform: translateY(-1px); box-shadow: 0 4px 20px rgba(180,180,220,0.2); }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { color: var(--text); border-color: var(--border-light); background: var(--surface2); }
.btn-danger { background: transparent; color: var(--error); border: 1px solid rgba(248,113,113,0.3); }
.btn-danger:hover:not(:disabled) { background: rgba(248,113,113,0.1); }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }
.btn-lg { padding: 12px 28px; font-size: 1rem; border-radius: var(--radius); }

/* ── Layout ── */
.page { max-width: 1100px; margin: 0 auto; padding: 40px 24px; }
.page-wide { max-width: 1300px; margin: 0 auto; padding: 40px 24px; }
.page-narrow { max-width: 720px; margin: 0 auto; padding: 40px 24px; }

.page-header { margin-bottom: 32px; }
.page-header h1 { font-size: 1.75rem; font-weight: 700; }
.page-header p { color: var(--text-muted); margin-top: 4px; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-body { padding: 20px; }
.card-hover { transition: border-color 0.15s, transform 0.15s; }
.card-hover:hover { border-color: var(--border-light); transform: translateY(-1px); }

/* ── Forms ── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-label { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); letter-spacing: 0.05em; text-transform: uppercase; }
.form-input, .form-textarea, .form-select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 14px;
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  outline: none;
  border-color: var(--border-light);
  box-shadow: 0 0 0 3px rgba(180,180,210,0.07);
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-faint); }
.form-textarea { resize: vertical; min-height: 120px; line-height: 1.6; }
.form-select { appearance: none; cursor: pointer; }
.form-select option { background: var(--surface2); }
.form-hint { font-size: 0.8rem; color: var(--text-muted); }
.form-error { font-size: 0.8rem; color: var(--error); }

/* ── Alert ── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 16px;
  border: 1px solid;
}
.alert-error { background: rgba(248,113,113,0.08); border-color: rgba(248,113,113,0.25); color: var(--error); }
.alert-success { background: rgba(74,222,128,0.08); border-color: rgba(74,222,128,0.25); color: var(--success); }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.2s;
  pointer-events: none;
  max-width: 320px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: var(--surface3); border: 1px solid rgba(74,222,128,0.3); color: var(--success); }
.toast-error { background: var(--surface3); border: 1px solid rgba(248,113,113,0.3); color: var(--error); }

/* ── Badge ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.badge-admin { background: rgba(251,191,36,0.15); color: var(--warning); border: 1px solid rgba(251,191,36,0.3); }
.badge-member { background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border); }
.badge-cat {
  background: rgba(180,180,210,0.08);
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-size: 0.72rem;
}

/* ── Home Page ── */
.hero {
  text-align: center;
  padding: 80px 24px 60px;
  position: relative;
}
.hero-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0px;
  margin-bottom: 20px;
}
.hero-logo .logo-main { font-size: 3.8rem; letter-spacing: 0.18em; }
.hero-logo .logo-sub { font-size: 0.9rem; letter-spacing: 0.4em; margin-top: 2px; }
.hero p { color: var(--text-muted); font-size: 1.1rem; max-width: 480px; margin: 0 auto 32px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 48px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
}
.stat-number { font-size: 2rem; font-weight: 800; color: var(--text); }
.stat-label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 4px; }

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ── Forum ── */
.forum-layout { display: grid; grid-template-columns: 240px 1fr; gap: 24px; }

.sidebar { display: flex; flex-direction: column; gap: 8px; }
.sidebar-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-faint);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 8px;
  margin-top: 8px;
}
.sidebar-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  border: 1px solid transparent;
}
.sidebar-link:hover { color: var(--text); background: var(--surface2); border-color: var(--border); }
.sidebar-link.active { color: var(--text); background: var(--surface2); border-color: var(--border-light); }
.sidebar-link .count {
  font-size: 0.72rem;
  background: var(--surface3);
  padding: 1px 6px;
  border-radius: 999px;
  color: var(--text-faint);
}

.post-list { display: flex; flex-direction: column; gap: 8px; }
.post-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}
.post-item:hover { border-color: var(--border-light); background: var(--surface2); color: inherit; }
.post-item-main { flex: 1; min-width: 0; }
.post-item-title { font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.post-item-meta { font-size: 0.8rem; color: var(--text-muted); margin-top: 3px; }
.post-item-stats { display: flex; gap: 16px; flex-shrink: 0; }
.post-stat { display: flex; flex-direction: column; align-items: center; }
.post-stat-val { font-size: 0.95rem; font-weight: 700; color: var(--text-muted); }
.post-stat-label { font-size: 0.68rem; color: var(--text-faint); text-transform: uppercase; }

.forum-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

/* ── Post page ── */
.post-header { margin-bottom: 24px; }
.post-title { font-size: 1.5rem; font-weight: 700; line-height: 1.3; margin-bottom: 12px; }
.post-author-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.author-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  flex-shrink: 0;
}
.author-placeholder {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.author-name { font-weight: 600; color: var(--text); font-size: 0.9rem; }

.post-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.8;
  font-size: 0.95rem;
}

.replies-section { margin-top: 32px; }
.reply-list { display: flex; flex-direction: column; gap: 12px; }
.reply-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.reply-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.reply-body { padding: 14px 16px; white-space: pre-wrap; word-break: break-word; font-size: 0.9rem; line-height: 1.7; }

.reply-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 16px;
}

/* ── Profile Page ── */
.profile-banner {
  width: 100%;
  height: 220px;
  object-fit: cover;
  background: linear-gradient(135deg, var(--accent-dim) 0%, #3a3a8a 100%);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  display: block;
}
.profile-banner-placeholder {
  width: 100%;
  height: 220px;
  background: linear-gradient(135deg, #111114 0%, #1a1a20 50%, #111116 100%);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  position: relative;
  overflow: hidden;
}
.profile-banner-placeholder::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 28px,
    rgba(180,180,210,0.025) 28px,
    rgba(180,180,210,0.025) 29px
  );
}

.profile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 24px;
}

.profile-info { padding: 0 28px 24px; }
.profile-avatar-wrap {
  margin-top: -44px;
  margin-bottom: 12px;
  position: relative;
  display: inline-block;
}
.profile-avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--surface);
  box-shadow: var(--shadow);
}
.profile-avatar-placeholder {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--surface3), var(--surface2));
  border: 4px solid var(--surface);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-muted);
}

.profile-name-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.profile-username { font-size: 1.4rem; font-weight: 800; }
.profile-join { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }
.profile-bio { color: var(--text-muted); font-size: 0.9rem; margin-top: 10px; max-width: 560px; line-height: 1.6; }

/* ── Settings ── */
.settings-layout { display: grid; grid-template-columns: 200px 1fr; gap: 28px; }
.settings-nav { display: flex; flex-direction: column; gap: 4px; }
.settings-nav-link {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}
.settings-nav-link:hover { color: var(--text); background: var(--surface2); }
.settings-nav-link.active { color: var(--text); background: var(--surface2); }

.settings-section { display: none; }
.settings-section.active { display: block; }
.settings-section h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 4px; }
.settings-section .sub { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 24px; }
.settings-divider { height: 1px; background: var(--border); margin: 24px 0; }

/* ── Auth pages ── */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
}
.auth-logo { display: flex; margin-bottom: 28px; }
.auth-logo .logo-main { font-size: 1.5rem; }
.auth-logo .logo-sub { font-size: 0.58rem; letter-spacing: 0.22em; }
.auth-title { font-size: 1.4rem; font-weight: 700; margin-bottom: 4px; }
.auth-sub { color: var(--text-muted); font-size: 0.875rem; margin-bottom: 28px; }
.auth-footer { text-align: center; font-size: 0.85rem; color: var(--text-muted); margin-top: 20px; }

/* ── Members ── */
.members-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.member-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  transition: border-color 0.15s, transform 0.15s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
}
.member-card:hover { border-color: var(--border-light); transform: translateY(-2px); color: inherit; }
.member-card-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--border);
  margin: 0 auto 10px;
  display: block;
}
.member-card-placeholder {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--surface3);
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-muted);
  margin: 0 auto 10px;
}
.member-card-name { font-weight: 700; font-size: 0.95rem; }
.member-card-join { font-size: 0.75rem; color: var(--text-muted); margin-top: 3px; }

/* ── Misc ── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 2.5rem; margin-bottom: 12px; opacity: 0.4; }
.empty-state p { font-size: 0.9rem; }

.divider { height: 1px; background: var(--border); margin: 24px 0; }

.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.85rem; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.flex-1 { flex: 1; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }

/* ── Upload preview ── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}
.upload-zone:hover { border-color: var(--accent); color: var(--text); }
.upload-zone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }

.avatar-preview {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--border);
  display: none;
  margin: 0 auto 12px;
}
.banner-preview {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  display: none;
  margin-bottom: 12px;
}

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

.skeleton {
  background: linear-gradient(90deg, var(--surface2) 25%, var(--surface3) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Responsive ── */
@media (max-width: 768px) {
  .navbar { padding: 0 16px; }
  .nav-links { display: none; }
  .forum-layout { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; }
  .stats-grid { grid-template-columns: 1fr; }
  .settings-layout { grid-template-columns: 1fr; }
  .hero-logo .logo-main { font-size: 2.5rem; }
  .hero-logo .logo-sub { font-size: 0.8rem; }
  .page { padding: 24px 16px; }
}
