:root {
  --bg: #0b0b0d;
  --bg2: #101013;
  --panel: #141417;
  --panel2: #1b1b20;
  --panel3: #23232a;
  --line: #2a2a33;
  --line-soft: #1f1f26;
  --txt: #e9e9f0;
  --dim: #8b8b9a;
  --red: #ff2e3f;
  --red2: #d91f30;
  --redsoft: rgba(255, 46, 63, .12);
  --redglow: rgba(255, 46, 63, .35);
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 12px 32px rgba(0, 0, 0, .5);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Code", Consolas, "JetBrains Mono", Menlo, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  background:
    radial-gradient(900px 420px at 50% -80px, rgba(255, 46, 63, .08), transparent 70%),
    var(--bg);
  color: var(--txt);
  font-family: var(--font);
  font-size: 14px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- custom cross cursor ---------- */
html, body {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 26 26'%3E%3Cpath d='M13 2.5v5.5M13 18v5.5M2.5 13h5.5M18 13h5.5' stroke='%23ff2e3f' stroke-width='2.2' stroke-linecap='round'/%3E%3Ccircle cx='13' cy='13' r='2' fill='%23ff2e3f'/%3E%3C/svg%3E") 13 13, crosshair;
}
a, button, select, .btn, label[for], .logo, nav a, .catbar a, .color-opt, .glow-opt, .badge-opt, .banner-opt, .copybtn {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 26 26'%3E%3Ccircle cx='13' cy='13' r='5' fill='none' stroke='%23ffffff' stroke-opacity='0.9' stroke-width='1.5'/%3E%3Cpath d='M13 2.5v5.5M13 18v5.5M2.5 13h5.5M18 13h5.5' stroke='%23ff2e3f' stroke-width='2.2' stroke-linecap='round'/%3E%3Ccircle cx='13' cy='13' r='2' fill='%23ff2e3f'/%3E%3C/svg%3E") 13 13, pointer;
}
input[type="text"], input[type="password"], textarea { cursor: text; }

::selection { background: rgba(255, 46, 63, .28); }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #2b2b34; border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--red2); }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; width: 100%; }

/* ---------- top bar ---------- */
header#topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(16, 16, 19, .85);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}
header#topbar .wrap {
  display: flex; align-items: center; gap: 24px;
  padding-top: 12px; padding-bottom: 12px;
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; white-space: nowrap; }
.logo-mark {
  width: 34px; height: 34px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--red), #7a0f18);
  color: #fff; font-weight: 800; font-size: 17px;
  box-shadow: 0 4px 14px var(--redglow);
}
.logo-text { font-weight: 800; font-size: 16px; letter-spacing: .5px; color: var(--txt); }
.logo-text span { color: var(--red); }

nav { display: flex; gap: 6px; }
nav a {
  color: var(--dim); text-decoration: none; font-size: 13px;
  padding: 8px 15px; border-radius: 999px;
  border: 1px solid transparent; transition: all .15s ease;
}
nav a:hover { color: var(--txt); background: var(--panel2); }
nav a.active {
  color: #fff; background: var(--redsoft);
  border-color: rgba(255, 46, 63, .45); font-weight: 600;
}
.spacer { flex: 1; }

#authBox { display: flex; align-items: center; gap: 10px; }
.userchip { display: flex; align-items: center; gap: 8px; }
.userchip a.profile-link { text-decoration: none; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: inline-grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 13px;
  border: 2px solid rgba(255, 46, 63, .6);
  flex-shrink: 0;
}
.avatar.lg { width: 78px; height: 78px; font-size: 32px; border-width: 3px; }

/* ---------- buttons ---------- */
.btn {
  background: var(--panel2); border: 1px solid var(--line);
  color: var(--txt); font-family: var(--font); font-size: 13px;
  font-weight: 600; letter-spacing: .3px;
  padding: 10px 20px; border-radius: 999px;
  cursor: pointer; transition: all .15s ease; text-decoration: none;
  display: inline-flex; align-items: center; gap: 7px; line-height: 1;
}
.btn:hover { border-color: var(--red); color: var(--red); transform: translateY(-1px); }
.btn.primary {
  background: linear-gradient(135deg, var(--red), var(--red2));
  border-color: transparent; color: #fff;
  box-shadow: 0 6px 18px var(--redglow);
}
.btn.primary:hover { box-shadow: 0 8px 24px rgba(255, 46, 63, .5); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: rgba(255, 46, 63, .5); }
.btn.sm { padding: 7px 14px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* ---------- forms ---------- */
input, textarea, select {
  background: var(--bg2); border: 1px solid var(--line);
  color: var(--txt); font-family: var(--font); font-size: 14px;
  padding: 11px 14px; border-radius: var(--radius-sm); width: 100%; outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--red); box-shadow: 0 0 0 3px rgba(255, 46, 63, .15);
}
textarea { resize: vertical; min-height: 120px; line-height: 1.65; }
label.f { display: block; font-size: 11px; font-weight: 700; letter-spacing: 1px; color: var(--dim); margin: 0 0 7px 2px; text-transform: uppercase; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 680px) { .form-row { grid-template-columns: 1fr; } }

/* ---------- cards / layout ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow);
}
.panel-title {
  font-size: 12px; color: var(--dim); letter-spacing: 2px;
  margin-bottom: 16px; font-weight: 700; text-transform: uppercase;
}
.card-title { font-size: 18px; font-weight: 800; margin-bottom: 6px; }

/* ---------- hero ---------- */
.hero { padding: 26px 4px 22px; }
.hero-title {
  font-size: 34px; font-weight: 900; letter-spacing: -.5px;
  background: linear-gradient(120deg, #fff, var(--red));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-sub { color: var(--dim); margin-top: 8px; font-size: 14px; }

/* ---------- board / category bars ---------- */
.boardbar, .catbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.boardbar a, .catbar a {
  font-size: 12px; font-weight: 600; letter-spacing: .3px; color: var(--dim);
  padding: 7px 15px; border: 1px solid var(--line); border-radius: 999px;
  text-decoration: none; transition: all .15s ease;
}
.boardbar a.active, .catbar a.active {
  color: #fff; border-color: var(--red); background: var(--redsoft);
}
.boardbar a:hover, .catbar a:hover { color: var(--red); border-color: var(--red); }
.searchbar { display: flex; gap: 10px; margin-bottom: 16px; align-items: center; }
.searchbar input { flex: 1; }

/* ---------- topic cards ---------- */
.topic {
  display: block; background: var(--panel); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 10px;
  text-decoration: none; color: var(--txt);
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.topic:hover { border-color: rgba(255, 46, 63, .55); transform: translateY(-2px); box-shadow: var(--shadow); }
.topic .trow { display: flex; gap: 12px; align-items: flex-start; }
.topic .tmeta { flex-shrink: 0; display: flex; gap: 6px; flex-wrap: wrap; }
.chip, .topic .tmeta .cat, .groupchip {
  font-size: 10px; font-weight: 700; letter-spacing: .8px; padding: 4px 10px;
  border-radius: 999px; white-space: nowrap;
}
.topic .tmeta .cat { color: var(--red); border: 1px solid rgba(255, 46, 63, .5); background: var(--redsoft); }
.groupchip { color: var(--dim); border: 1px solid var(--line); background: var(--panel2); }
.topic .ttitle { font-size: 15px; font-weight: 700; color: var(--txt); }
.topic .tsnip { font-size: 13px; color: var(--dim); margin-top: 6px; line-height: 1.5; overflow: hidden; }
.topic .tfoot {
  margin-top: 12px; font-size: 12px; color: var(--dim);
  display: flex; gap: 16px; flex-wrap: wrap; align-items: center;
}
.topic .tfoot .codechip { color: #fff; background: var(--redsoft); border: 1px solid rgba(255,46,63,.5); padding: 2px 9px; border-radius: 999px; font-size: 10px; font-weight: 700; letter-spacing: 1px; }

/* ---------- names / badges ---------- */
.name { font-weight: 700; }
.badge {
  font-size: 10px; font-weight: 800; letter-spacing: .8px;
  padding: 2px 9px; border-radius: 999px;
  color: var(--dim); border: 1px solid var(--line);
  background: var(--panel2); margin-left: 5px; white-space: nowrap;
}
.badge.owner {
  color: #fff; border-color: var(--red);
  background: linear-gradient(135deg, var(--red), var(--red2));
  box-shadow: 0 0 12px var(--redglow);
}
.tag-owner {
  font-size: 10px; font-weight: 800; letter-spacing: .8px; padding: 2px 9px;
  border-radius: 999px; color: #fff;
  border: 1px solid var(--red); background: linear-gradient(135deg, var(--red), var(--red2));
}

/* ---------- topic view ---------- */
.post-head { margin-bottom: 16px; }
.post-head .meta-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.post-head .cat {
  font-size: 11px; font-weight: 700; letter-spacing: .8px; color: var(--red);
  border: 1px solid rgba(255, 46, 63, .5); border-radius: 999px; padding: 4px 12px;
  background: var(--redsoft);
}
.post-head h1 { font-size: 24px; line-height: 1.3; word-break: break-word; }
.post-byline { margin-top: 10px; font-size: 13px; color: var(--dim); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.post-body { line-height: 1.75; white-space: pre-wrap; word-break: break-word; font-size: 14.5px; margin-top: 14px; }

.reply {
  background: var(--panel); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 10px;
}
.reply .rhead {
  font-size: 12px; color: var(--dim); margin-bottom: 12px;
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.reply .rbody { line-height: 1.7; white-space: pre-wrap; word-break: break-word; font-size: 14px; }

/* ---------- code blocks ---------- */
.codeblock {
  background: #0c0c0f; border: 1px solid var(--line-soft);
  border-radius: var(--radius); margin: 14px 0; overflow: hidden;
}
.codeblock .cbar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; background: var(--panel2);
  border-bottom: 1px solid var(--line-soft); font-size: 11px;
  color: var(--red); letter-spacing: 1px; font-family: var(--mono);
}
.codeblock .cbar .spacer { flex: 1; }
.codeblock .copybtn {
  background: none; border: 1px solid var(--line); color: var(--dim);
  font-family: var(--font); font-size: 11px; font-weight: 700; letter-spacing: 1px;
  padding: 4px 12px; border-radius: 999px; cursor: pointer;
}
.codeblock .copybtn:hover { color: var(--red); border-color: var(--red); }
.codeblock pre {
  padding: 16px; overflow-x: auto; font-size: 13px; line-height: 1.6;
  font-family: var(--mono); color: #d5d5df;
}
.codeblock pre code { font-family: inherit; }
.tk-kw { color: #ff7b88; }
.tk-str { color: #9ee493; }
.tk-num { color: #ffd166; }
.tk-com { color: #5c5c6b; font-style: italic; }
.tk-fn { color: #7ec8ff; }

/* ---------- profile ---------- */
.profile { overflow: hidden; padding: 0; }
.profile-banner { height: 130px; position: relative; }
.banner-carbon   { background: linear-gradient(135deg, #0f0f12, #1d1d24); }
.banner-crimson  { background: linear-gradient(135deg, #2a0a0d, #7a1420); }
.banner-ember    { background: linear-gradient(135deg, #241205, #8a2c0a); }
.banner-void     { background: linear-gradient(135deg, #050507, #17171d); }
.banner-blood    { background: linear-gradient(135deg, #1c0305, #a4101f); }
.profile-top {
  display: flex; align-items: flex-end; gap: 18px;
  padding: 0 22px; margin-top: -34px; position: relative;
}
.profile-top .avatar { border: 4px solid var(--panel); width: 84px; height: 84px; font-size: 34px; }
.profile-info { flex: 1; padding: 14px 0 0; }
.profile-name { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 22px; font-weight: 800; }
.profile-role { font-size: 11px; font-weight: 700; letter-spacing: 1px; color: var(--dim); text-transform: uppercase; }
.profile-role.owner { color: var(--red); }
.profile-bio { margin-top: 16px; padding: 0 22px 8px; line-height: 1.7; font-size: 14px; }
.profile-meta { display: flex; gap: 18px; flex-wrap: wrap; padding: 6px 22px 20px; color: var(--dim); font-size: 12.5px; }
.profile-meta b { color: var(--txt); }
.profile-body { padding: 0 22px 22px; }

.banner-options { display: flex; gap: 10px; flex-wrap: wrap; }
.banner-opt {
  width: 92px; height: 44px; border-radius: var(--radius-sm);
  border: 2px solid var(--line); position: relative; transition: all .15s ease;
}
.banner-opt span { position: absolute; left: 8px; bottom: 5px; font-size: 9px; font-weight: 800; letter-spacing: .5px; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.8); }
.banner-opt.active { border-color: var(--red); box-shadow: 0 0 0 3px rgba(255,46,63,.2); }

.color-options { display: flex; gap: 10px; flex-wrap: wrap; }
.color-opt {
  width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid var(--line); transition: all .15s ease;
}
.color-opt.active { border-color: #fff; box-shadow: 0 0 0 3px var(--redglow), 0 0 12px currentColor; }

.glow-options { display: flex; gap: 8px; flex-wrap: wrap; }
.glow-opt {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  border: 2px solid var(--line); color: var(--dim); font-size: 11px; font-weight: 800;
  background: var(--bg2); transition: all .15s ease;
}
.glow-opt.active { border-color: var(--red); color: var(--red); background: var(--redsoft); }

.badge-options { display: flex; gap: 8px; flex-wrap: wrap; }
.badge-opt {
  padding: 7px 14px; border-radius: 999px;
  border: 1.5px solid var(--line); color: var(--dim);
  font-size: 12px; font-weight: 700; letter-spacing: .5px;
  background: var(--bg2); transition: all .15s ease;
}
.badge-opt.active { border-color: var(--red); color: #fff; background: var(--redsoft); }
.badge-opt.off { opacity: .45; }

/* ---------- groups ---------- */
.section-title { font-size: 20px; font-weight: 800; margin-bottom: 14px; display: flex; align-items: center; gap: 10px; }
.section-title .count { font-size: 12px; color: var(--dim); font-weight: 600; }
.groups-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.group-card {
  background: var(--panel); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: 18px; text-decoration: none; color: var(--txt);
  display: flex; flex-direction: column; gap: 10px; transition: all .15s ease;
}
.group-card:hover { border-color: rgba(255,46,63,.55); transform: translateY(-2px); box-shadow: var(--shadow); }
.group-card h3 { font-size: 16px; font-weight: 800; }
.group-card .gdesc { font-size: 13px; color: var(--dim); line-height: 1.5; flex: 1; }
.group-card .gmeta { font-size: 12px; color: var(--dim); display: flex; justify-content: space-between; align-items: center; }

.group-hero { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.group-hero .logo-mark { width: 44px; height: 44px; font-size: 20px; }
.group-hero h1 { font-size: 24px; font-weight: 900; }
.group-hero .gdesc { color: var(--dim); margin-top: 4px; font-size: 14px; }

.cat-chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
.cat-chips .chip { color: var(--red); border: 1px solid rgba(255,46,63,.5); background: var(--redsoft); }

.members { display: flex; flex-wrap: wrap; gap: 8px; }
.member-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 12px 5px 5px; border-radius: 999px;
  border: 1px solid var(--line-soft); background: var(--panel2);
  font-size: 12px; color: var(--txt); text-decoration: none;
}
.member-chip .avatar { width: 24px; height: 24px; font-size: 11px; border-width: 1.5px; }

/* ---------- empty / misc ---------- */
.empty { text-align: center; color: var(--dim); padding: 48px 0; font-size: 13px; letter-spacing: .5px; line-height: 1.8; }
.empty a { color: var(--red); }
.loading { color: var(--dim); padding: 40px 0; text-align: center; font-size: 13px; letter-spacing: 1px; }
.loading .pulse { display: inline-block; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: .4; } 50% { opacity: 1; } }
.hint { font-size: 12px; color: var(--dim); margin-top: 8px; line-height: 1.6; }
.mt16 { margin-top: 16px; }
.mt8 { margin-top: 8px; }
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- auth ---------- */
.auth-card { max-width: 420px; margin: 40px auto; }
.auth-err { color: var(--red); font-size: 13px; margin-top: 12px; font-weight: 600; }
.auth-switch { margin-top: 16px; font-size: 13px; color: var(--dim); text-align: center; }
.auth-switch a { color: var(--red); text-decoration: none; font-weight: 700; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 22px; right: 22px; background: var(--panel2);
  border: 1px solid var(--red); color: var(--txt); border-radius: 999px;
  padding: 13px 22px; font-size: 13px; font-weight: 600; letter-spacing: .3px; z-index: 200;
  opacity: 0; transform: translateY(10px) scale(.98); transition: all .2s ease;
  pointer-events: none; max-width: 380px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.toast.show { opacity: 1; transform: none; }
.toast.warn { border-color: var(--red); color: #fff; background: linear-gradient(135deg, var(--red2), #6d0d16); }

footer { padding: 34px 0 44px; }
.mini { font-size: 11px; color: var(--dim); letter-spacing: .5px; }

@media (max-width: 720px) {
  header#topbar .wrap { gap: 10px; flex-wrap: wrap; }
  nav { order: 3; width: 100%; justify-content: center; }
  nav a { font-size: 12px; padding: 7px 12px; }
  .hero-title { font-size: 26px; }
  .profile-top { flex-wrap: wrap; }
}
