/* ── CSS Custom Properties ── */
:root {
  --fluid-width: 1500px;
  --bg-base:        #070b1a;
  --bg-card:        #0d1426;
  --border-color:   #1a2440;
  --accent:         #3b82f6;
  --accent-hover:   #2563eb;
  --accent-bg:      rgba(59,130,246,.10);
  --accent-shadow:  rgba(59,130,246,.40);
  --text-primary:   #ffffff;
  --text-muted:     #cbd5e1;
  --text-dim:       #64748b;
  --text-faint:     #475569;
  --hero-from:      #0d1426;
  --hero-to:        #1e3a8a;
  --hero-glow:      rgba(59,130,246,.35);
  --switch-off:     #1a2440;
}

/* ── Dark/Gold Theme ── */
body.theme-dark {
  --bg-base:        #09090b;
  --bg-card:        #111113;
  --border-color:   #27272a;
  --accent:         #c9a962;
  --accent-hover:   #c9a962;
  --accent-bg:      rgb(247 220 85 / 10%);
  --accent-shadow:  rgb(247 235 85 / 40%);
  --text-dim:       #71717a;
  --text-faint:     #52525b;
  --hero-from:      #0b0b09;
  --hero-to:        #644707;
  --hero-glow:      rgb(247 167 85 / 30%);
  --switch-off:     #27272a;
}

/* ── Light Theme ── */
body.theme-light {
  --bg-base:        #f1f5f9;
  --bg-card:        #ffffff;
  --border-color:   #e2e8f0;
  --accent:         #2563eb;
  --accent-hover:   #1d4ed8;
  --accent-bg:      rgba(37,99,235,.08);
  --accent-shadow:  rgba(37,99,235,.25);
  --text-primary:   #0f172a;
  --text-muted:     #334155;
  --text-dim:       #64748b;
  --text-faint:     #94a3b8;
  --hero-from:      #dbeafe;
  --hero-to:        #bfdbfe;
  --hero-glow:      rgba(37,99,235,.15);
  --switch-off:     #cbd5e1;
}

/* ── Red Theme ── */
body.theme-red {
  --bg-base:        #0f0608;
  --bg-card:        #1a080b;
  --border-color:   #3b0f16;
  --accent:         #ef4444;
  --accent-hover:   #dc2626;
  --accent-bg:      rgba(239,68,68,.10);
  --accent-shadow:  rgba(239,68,68,.40);
  --text-dim:       #7f4044;
  --text-faint:     #5a2428;
  --hero-from:      #1a080b;
  --hero-to:        #7f1d1d;
  --hero-glow:      rgba(239,68,68,.30);
  --switch-off:     #3b0f16;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-base);
  color: var(--text-muted);
  min-height: 100vh;
  margin: 0;
}

/* ── Card ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
}
.row-divide > * + * { border-top: 1px solid var(--border-color); }

/* ── Colour helpers ── */
.accent    { color: var(--accent); }
.t-primary { color: var(--text-primary); }
.t-muted   { color: var(--text-muted); }
.t-dim     { color: var(--text-dim); }
.t-faint   { color: var(--text-faint); }

/* ── Icon bubble ── */
.icon-bubble {
  background: var(--accent-bg);
  color: var(--accent);
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* ── Avatar ── */
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--border-color);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim);
  flex-shrink: 0;
}

/* ── Hero banner ── */
.hero {
  background: linear-gradient(135deg, var(--hero-from) 0%, var(--hero-from) 50%, var(--hero-to) 100%);
  position: relative; overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 80% 50%, var(--hero-glow), transparent 60%);
  pointer-events: none;
}

/* ── Navigation ── */
.nav-active {
  border-bottom: 2px solid var(--accent);
  padding-bottom: 14px;
  color: var(--text-primary);
}

/* ── Buttons ── */
.btn-accent {
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: background .2s;
}
.btn-accent:hover { background: var(--accent-hover); }

.btn-border {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  cursor: pointer;
  transition: background .2s;
}
.btn-border:hover { background: var(--border-color); }

/* ── Container ── */
.container-fluid { max-width: var(--fluid-width) !important; }

/* ── Body-class modifier states ── */
body.no-anim *, body.no-anim *::before, body.no-anim *::after {
  transition: none !important; animation: none !important;
}
body.no-radius .card, body.no-radius button,
body.no-radius .icon-bubble, body.no-radius .avatar,
body.no-radius input, body.no-radius [class*="rounded"] {
  border-radius: 0 !important;
}
body.no-icons .icon-bubble { display: none !important; }
body.no-hero  #hero-section { display: none !important; }
body.no-sidebar #main-grid  { grid-template-columns: 1fr !important; }
body.no-sidebar #sidebar    { display: none !important; }

/* ── Collapsible categories ── */
.cat-body    { overflow: hidden; transition: max-height .3s ease; }
.cat-header  { cursor: pointer; user-select: none; }
.cat-chevron { transition: transform .3s ease; }
.cat-collapsed .cat-chevron { transform: rotate(180deg); }
.cat-collapsed .cat-body    { max-height: 0 !important; }

/* ── Toggle switch ── */
.switch {
  position: relative; width: 42px; height: 22px;
  background: var(--switch-off);
  border-radius: 999px; cursor: pointer;
  transition: background .2s; flex-shrink: 0;
  border: none; padding: 0;
}
.switch::after {
  content: ""; position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: left .2s, background .2s;
}
.switch.on { background: var(--accent); }
.switch.on::after { left: 22px; background: #fff; }

/* ── FX canvas layers ── */
#snow-canvas, #particles-canvas {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none; z-index: 40;
}

/* ── Floating theme button ── */
#theme-btn {
  position: fixed; bottom: 24px; right: 24px; z-index: 50;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 24px var(--accent-shadow);
  border: none; cursor: pointer;
  transition: background .2s, box-shadow .2s;
}
#theme-btn:hover { background: var(--accent-hover); }

/* ── Theme modal ── */
#theme-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 60; display: none;
  align-items: center; justify-content: center;
}
#theme-modal.open { display: flex; }

/* ── Colour swatches ── */
.colour-swatch {
  position: relative;
  border-radius: 10px;
  padding: 10px 8px 8px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color .2s, transform .15s;
  text-align: center;
  background: var(--border-color);
  width: 100%;
}
.colour-swatch:hover { border-color: var(--text-dim); transform: translateY(-1px); }
.colour-swatch.active { border-color: var(--accent) !important; }
.colour-swatch.active::after {
  content: "✓";
  position: absolute; top: 4px; right: 7px;
  font-size: 10px; font-weight: 700;
  color: var(--accent);
}
.swatch-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  margin: 0 auto 6px;
  border: 2px solid rgba(255,255,255,.15);
}
.swatch-label {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 500;
}

/* ── Responsive breakpoints ── */
@media (max-width: 1024px) {
  #main-grid { grid-template-columns: 1fr !important; }
  #sidebar   { display: none !important; }
}
@media (max-width: 768px) {
  header .flex.items-center.gap-14  { gap: 1.5rem; }
  header nav                         { display: none; }
  .hero.p-10                         { padding: 1.5rem; }
  .container-fluid                   { padding-left: 1rem !important; padding-right: 1rem !important; }
  #members-grid                      { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)) !important; }
  .post-wrap                         { grid-template-columns: 1fr !important; }
  .post-sidebar                      { border-right: none !important; border-bottom: 1px solid var(--border-color); flex-direction: row; flex-wrap: wrap; justify-content: center; }
}
@media (max-width: 480px) {
  header .flex.items-center.gap-3 button { display: none; }
  header .flex.items-center.gap-3 button:last-child { display: flex; }
}

/* ── Member list page ── */
.member-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px; padding: 20px;
  display: flex; flex-direction: column;
  align-items: center; text-align: center;
  gap: 10px;
  transition: border-color .2s, transform .2s;
}
.member-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.member-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--border-color);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim);
  font-size: 22px; font-weight: 700;
  flex-shrink: 0;
  border: 2px solid var(--border-color);
}
.member-avatar.online { border-color: var(--accent); }
.online-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #4ade80;
  border: 2px solid var(--bg-card);
}
.role-badge {
  font-size: 10px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px;
  background: var(--accent-bg); color: var(--accent);
}
.letter-tab {
  cursor: pointer; padding: 6px 10px; border-radius: 6px;
  font-size: 13px; font-weight: 600; color: var(--text-dim);
  transition: background .15s, color .15s;
  border: none; background: transparent;
}
.letter-tab:hover    { background: var(--accent-bg); color: var(--accent); }
.letter-tab.active-tab { background: var(--accent); color: #fff; }
.sort-btn {
  font-size: 12px; padding: 5px 12px; border-radius: 6px;
  cursor: pointer; border: 1px solid var(--border-color);
  background: transparent; color: var(--text-dim);
  transition: all .15s;
}
.sort-btn.active-sort { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); }
.search-input {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px; padding: 8px 14px 8px 38px;
  color: var(--text-primary); font-size: 14px;
  width: 100%; outline: none;
  transition: border-color .2s;
  font-family: 'Inter', sans-serif;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-faint); }
.pagination-btn {
  width: 34px; height: 34px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border-color);
  background: transparent; color: var(--text-dim);
  transition: all .15s;
}
.pagination-btn:hover      { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); }
.pagination-btn.active-page { background: var(--accent); color: #fff; border-color: var(--accent); }
#members-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; }
#members-table { width: 100%; border-collapse: collapse; }
#members-table th {
  text-align: left; padding: 10px 14px;
  font-size: 12px; font-weight: 600; color: var(--text-dim);
  border-bottom: 1px solid var(--border-color); white-space: nowrap;
}
#members-table td { padding: 12px 14px; border-bottom: 1px solid var(--border-color); font-size: 14px; }
#members-table tr:last-child td { border-bottom: none; }
#members-table tbody tr { transition: background .15s; }
#members-table tbody tr:hover { background: var(--accent-bg); }
.view-btn {
  width: 32px; height: 32px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; border: 1px solid var(--border-color);
  background: transparent; color: var(--text-dim);
  transition: all .15s;
}
.view-btn.active-view { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); }

/* ── Thread / showthread page ── */
.post-wrap {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 0;
  border-bottom: 1px solid var(--border-color);
}
.post-wrap:last-child { border-bottom: none; }
.post-sidebar {
  padding: 24px 20px;
  border-right: 1px solid var(--border-color);
  display: flex; flex-direction: column;
  align-items: center; gap: 8px; text-align: center;
}
.post-body { padding: 24px; min-width: 0; }
.post-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--accent-bg); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700;
  border: 2px solid var(--border-color); flex-shrink: 0;
}
.post-avatar.online { border-color: var(--accent); }
.user-rank {
  font-size: 10px; font-weight: 600;
  padding: 2px 10px; border-radius: 999px;
  background: var(--accent-bg); color: var(--accent);
}
.post-meta {
  font-size: 12px; color: var(--text-faint);
  display: flex; align-items: center;
  gap: 12px; flex-wrap: wrap;
  margin-bottom: 14px; padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}
.post-content {
  font-size: 15px; line-height: 1.7; color: var(--text-muted);
}
.post-content p          { margin-bottom: 12px; }
.post-content p:last-child { margin-bottom: 0; }
.post-content code {
  background: var(--border-color); border-radius: 4px;
  padding: 2px 6px; font-size: 13px;
  font-family: monospace; color: var(--accent);
}
.post-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 10px 16px; margin: 14px 0;
  background: var(--accent-bg);
  border-radius: 0 6px 6px 0;
}
.post-actions {
  display: flex; align-items: center; gap: 8px;
  margin-top: 16px; padding-top: 14px;
  border-top: 1px solid var(--border-color);
}
.action-btn {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; padding: 5px 10px; border-radius: 6px;
  cursor: pointer; border: none; background: transparent;
  color: var(--text-dim); transition: all .15s;
}
.action-btn:hover  { background: var(--accent-bg); color: var(--accent); }
.action-btn.liked  { color: var(--accent); }
.rep-bar           { height: 4px; border-radius: 2px; background: var(--border-color); overflow: hidden; width: 100%; margin-top: 4px; }
.rep-fill          { height: 100%; background: var(--accent); border-radius: 2px; }
.quick-reply       { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 12px; padding: 24px; }
.reply-textarea {
  width: 100%; background: var(--border-color);
  border: 1px solid transparent; border-radius: 8px;
  padding: 14px; color: var(--text-primary);
  font-family: 'Inter', sans-serif; font-size: 14px;
  line-height: 1.6; resize: vertical; min-height: 120px;
  outline: none; transition: border-color .2s;
}
.reply-textarea:focus { border-color: var(--accent); background: var(--bg-base); }
.reply-textarea::placeholder { color: var(--text-faint); }
.toolbar-btn {
  width: 30px; height: 30px; border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; border: 1px solid var(--border-color);
  background: transparent; color: var(--text-dim);
  font-size: 12px; font-weight: 700; transition: all .15s;
}
.toolbar-btn:hover { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); }

/* ── Breadcrumbs ── */
.breadcrumb { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; color: var(--text-faint); }
.breadcrumb a { color: var(--accent); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

/* ── Pagination (global) ── */
.page_nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.page_link, .page_current {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px; padding: 0 8px;
  border-radius: 8px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--border-color); cursor: pointer;
  text-decoration: none; color: var(--text-dim);
  transition: all .15s;
}
.page_link:hover { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); }
.page_current    { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Responsive post layout ── */
@media (max-width: 640px) {
  .post-wrap { grid-template-columns: 1fr; }
  .post-sidebar { border-right: none; border-bottom: 1px solid var(--border-color); flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 12px; }
}