/* ============================================================
   RPG Catalyst — forum theme
   Dark fantasy by default, light theme via [data-theme="light"]
   ============================================================ */

:root, [data-theme="dark"] {
  --bg: #12141c;
  --bg-deep: #0d0f15;
  --panel: #1a1d28;
  --panel-2: #212536;
  --panel-3: #2a2f44;
  --border: #2e3348;
  --border-soft: #262b3d;
  --text: #d9dcea;
  --text-strong: #f2f3fa;
  --muted: #8b90a8;
  --accent: #e8b64c;
  --accent-soft: rgba(232, 182, 76, 0.14);
  --accent-2: #7f9cf5;
  --link: #a8bffa;
  --link-hover: #cdd9ff;
  --danger: #e06c75;
  --danger-soft: rgba(224, 108, 117, 0.12);
  --success: #5cc9a7;
  --success-soft: rgba(92, 201, 167, 0.12);
  --info-soft: rgba(127, 156, 245, 0.12);
  --unread: #e8b64c;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  --radius: 10px;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f2f0ea;
  --bg-deep: #e9e6dd;
  --panel: #ffffff;
  --panel-2: #f6f4ee;
  --panel-3: #ece9e0;
  --border: #d8d3c5;
  --border-soft: #e3dfd4;
  --text: #333744;
  --text-strong: #14161d;
  --muted: #77796f;
  --accent: #a8721c;
  --accent-soft: rgba(168, 114, 28, 0.12);
  --accent-2: #4c63c4;
  --link: #3e51a5;
  --link-hover: #212c66;
  --danger: #bf3b46;
  --danger-soft: rgba(191, 59, 70, 0.1);
  --success: #1f8a68;
  --success-soft: rgba(31, 138, 104, 0.12);
  --info-soft: rgba(76, 99, 196, 0.1);
  --unread: #a8721c;
  --shadow: 0 2px 8px rgba(60, 50, 30, 0.12);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  background-image: radial-gradient(ellipse at top, rgba(127, 156, 245, 0.05), transparent 60%);
  color: var(--text);
  font: 15px/1.55 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; width: 100%; }
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }
h1, h2, h3 { color: var(--text-strong); line-height: 1.25; }
h1 { font-size: 1.5rem; margin: 0.4em 0; }
h2 { font-size: 1.2rem; margin: 0.4em 0; }
h3 { font-size: 1.02rem; margin: 0.3em 0 0.6em; }
code { background: var(--panel-3); padding: 1px 5px; border-radius: 4px; font-size: 0.88em; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; width: 100%; }
.muted { color: var(--muted); }
.small { font-size: 0.85em; }
.grow { flex: 1; }
.inline { display: inline; }

/* Icons */
.icon {
  width: 1.05em; height: 1.05em;
  vertical-align: -0.16em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: inline-block;
  flex-shrink: 0;
}
h1 .icon, h2 .icon { color: var(--accent); }
h3 .icon { color: var(--accent); width: 1em; height: 1em; }

/* ---------------- header ---------------- */
.site-header {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 50;
}
.header-inner { display: flex; align-items: center; gap: 14px; min-height: 58px; padding: 6px 0; }
.logo { display: flex; align-items: center; gap: 8px; font-size: 1.25rem; font-weight: 700; color: var(--text-strong); }
.logo:hover { text-decoration: none; }
.logo-icon { color: var(--accent); display: flex; }
.logo-icon .icon { width: 1.3em; height: 1.3em; }
.logo-accent { color: var(--accent); }
.main-nav { display: flex; gap: 2px; flex-shrink: 0; }
@media (max-width: 1180px) {
  .nav-link { padding: 8px 8px; font-size: 0.92rem; }
  .header-inner { gap: 8px; }
}
.nav-link {
  color: var(--text); padding: 8px 12px; border-radius: 8px; font-weight: 500; white-space: nowrap;
}
.nav-link:hover { background: var(--panel-3); color: var(--text-strong); text-decoration: none; }
.nav-staff { color: var(--accent); }
.header-search { margin-left: auto; flex: 0 1 230px; min-width: 130px; }
.header-search input {
  background: var(--bg-deep); border: 1px solid var(--border); color: var(--text);
  border-radius: 20px; padding: 7px 14px; width: 100%;
}
.header-search input:focus { outline: none; border-color: var(--accent-2); }
.header-user .search-link { display: none; }
.header-user { display: flex; align-items: center; gap: 6px; }
/* the ghost "Log In" button sits on the header gradient, so give it a visible fill */
.header-user .btn-ghost { background: var(--panel-3); border-color: var(--border); }
.header-user .btn-ghost:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--text-strong); }
.icon-btn {
  position: relative; background: none; border: none; color: var(--text); cursor: pointer;
  padding: 8px; border-radius: 8px; font-size: 1rem; display: inline-flex; align-items: center;
}
.icon-btn:hover { background: var(--panel-3); text-decoration: none; color: var(--text-strong); }
.icon-btn .icon { width: 1.2em; height: 1.2em; }
[data-theme="dark"] .show-light { display: none; }
[data-theme="light"] .show-dark { display: none; }
.badge {
  position: absolute; top: 1px; right: 0;
  font-size: 0.66rem; font-weight: 700; line-height: 1;
  padding: 2px 5px; border-radius: 9px;
}
.badge-red { background: var(--danger); color: #fff; }
.nav-link .badge { position: static; margin-left: 4px; }
.nav-burger { display: none; background: none; border: none; color: var(--text); font-size: 1.3rem; cursor: pointer; padding: 6px 10px; }

.user-menu { position: relative; }
.user-menu-btn { background: none; border: none; padding: 2px; cursor: pointer; border-radius: 50%; display: flex; }
.user-menu-drop {
  display: none; position: absolute; right: 0; top: calc(100% + 8px);
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); min-width: 220px; padding: 6px; z-index: 60;
}
.user-menu-drop.open { display: block; }
.user-menu-drop a, .user-menu-drop .linklike {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; color: var(--text); border-radius: 6px; width: 100%;
  text-align: left; font-size: 0.95rem;
}
.user-menu-drop a:hover, .user-menu-drop .linklike:hover { background: var(--panel-3); text-decoration: none; }
.ud-head { padding: 10px 12px; border-bottom: 1px solid var(--border-soft); margin-bottom: 4px; }

/* ---------------- avatars / users ---------------- */
.avatar { border-radius: 50%; display: inline-block; vertical-align: middle; object-fit: cover; background: var(--panel-3); }
.avatar-letter {
  display: inline-flex; align-items: center; justify-content: center;
  background: hsl(var(--ah, 200), 45%, 38%); color: #fff; font-weight: 700;
}
.avatar-wrap { display: inline-flex; border-radius: 50%; }
.username { font-weight: 600; }
.username-link:hover { text-decoration: none; filter: brightness(1.15); }
.level-badge {
  display: inline-block; background: var(--accent-soft); color: var(--accent);
  font-size: 0.7rem; font-weight: 700; padding: 1px 7px; border-radius: 9px;
  border: 1px solid var(--accent); vertical-align: middle; white-space: nowrap;
}
.group-badge {
  display: inline-block; font-size: 0.68rem; font-weight: 700; color: #14161d;
  background: var(--accent); padding: 1px 8px; border-radius: 4px; margin: 2px 0; text-transform: uppercase;
  letter-spacing: 0.04em;
}
.xp-bar {
  height: 5px; background: var(--bg-deep); border-radius: 3px; overflow: hidden; margin: 6px 0;
}
.xp-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #f0d089); border-radius: 3px; }
.xp-bar.wide { width: 240px; max-width: 100%; }
.xp-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------------- panels / layout ---------------- */
.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.breadcrumbs { padding: 12px 2px 4px; font-size: 0.88rem; color: var(--muted); }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--link); }
.bc-sep { margin: 0 6px; opacity: 0.6; }
.bc-current { color: var(--text); }
.flash { padding: 10px 16px; border-radius: 8px; margin: 10px 0; border: 1px solid; font-size: 0.94rem; }
.flash-success { background: var(--success-soft); border-color: var(--success); color: var(--success); }
.flash-error { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.flash-info { background: var(--info-soft); border-color: var(--accent-2); color: var(--accent-2); }
.empty-state { text-align: center; color: var(--muted); padding: 28px 12px; }
.toolbar-row { display: flex; gap: 8px; align-items: center; margin: 18px 0 14px; }
.toolbar-row .btn-ghost {
  background: var(--panel); border-color: var(--border); box-shadow: var(--shadow);
}
.toolbar-row .btn-ghost:hover { background: var(--panel-3); border-color: var(--accent-2); }

/* ---------------- buttons / forms ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  border-radius: 8px; padding: 8px 16px; font-size: 0.92rem; font-weight: 600;
  line-height: 1.4; border: 1px solid transparent;
  transition: filter 0.15s, background 0.15s; white-space: nowrap;
}
.btn:hover { text-decoration: none; filter: brightness(1.1); }
.btn-primary { background: var(--accent); color: #1a1405; }
.btn-primary:hover { color: #1a1405; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--panel-3); color: var(--text-strong); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.btn-sm { padding: 5px 11px; font-size: 0.85rem; }
.btn-block { width: 100%; justify-content: center; }
.linklike {
  background: none; border: none; color: var(--link); cursor: pointer; padding: 0;
  font: inherit; font-size: 0.88rem; display: inline-flex; align-items: center; gap: 4px;
}
.linklike:hover { text-decoration: underline; }
.linklike.danger { color: var(--danger); }
.muted-invert { opacity: 0.75; }

label { display: block; margin: 10px 0; font-size: 0.92rem; color: var(--text); font-weight: 500; }
label small { font-weight: 400; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"],
input[type="url"], input[type="number"], textarea, select {
  width: 100%; margin-top: 4px;
  background: var(--bg-deep); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px; font: inherit;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent-2); }
input[type="number"] { width: auto; min-width: 90px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.check input { width: auto; margin: 0; }
.field-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.field-row > label { flex: 1; min-width: 140px; }
.field-row > button { margin-bottom: 10px; }
.field-prefix { max-width: 180px; }
.field-title { flex: 3; }
.hp { position: absolute; left: -9999px; opacity: 0; }

.auth-panel { max-width: 420px; margin: 40px auto; }
.auth-links { margin-top: 14px; text-align: center; font-size: 0.9rem; color: var(--muted); }

/* ---------------- home ---------------- */
.hero { text-align: center; padding: 34px 24px; background: linear-gradient(160deg, var(--panel), var(--panel-2)); }
.hero h1 { font-size: 1.7rem; }
.hero p { max-width: 640px; margin: 10px auto 18px; color: var(--muted); }
.hero-actions { display: flex; gap: 10px; justify-content: center; }
.home-grid { display: grid; grid-template-columns: 1fr 290px; gap: 18px; align-items: start; }
.category { padding: 0; overflow: hidden; }
.category-head { padding: 13px 18px 10px; background: var(--panel-2); border-bottom: 1px solid var(--border-soft); }
.category-head p { margin: 2px 0 0; font-size: 0.85rem; }
.forum-rows { display: flex; flex-direction: column; }
.forum-row {
  display: grid; grid-template-columns: 46px 1fr 150px 230px;
  gap: 12px; align-items: center; padding: 12px 18px;
  border-bottom: 1px solid var(--border-soft);
}
.forum-row:last-child { border-bottom: none; }
.forum-row:hover { background: var(--panel-2); }
.forum-icon {
  width: 42px; height: 42px; display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  color: hsl(var(--ih, 220), 62%, 64%);
  background: hsla(var(--ih, 220), 62%, 60%, 0.14);
}
[data-theme="light"] .forum-icon {
  color: hsl(var(--ih, 220), 58%, 34%);
  background: hsla(var(--ih, 220), 55%, 42%, 0.12);
}
.forum-icon .icon { width: 20px; height: 20px; }
.cat-ico .icon { color: hsl(var(--ih, 42), 62%, 60%); }
[data-theme="light"] .cat-ico .icon { color: hsl(var(--ih, 42), 58%, 34%); }
.chip-hued .icon { color: hsl(var(--ih, 220), 62%, 62%); }
[data-theme="light"] .chip-hued .icon { color: hsl(var(--ih, 220), 58%, 34%); }
.forum-title { font-weight: 600; font-size: 1.0rem; color: var(--text-strong); }
.forum-row.unread .forum-title { color: var(--accent); }
.forum-desc { font-size: 0.84rem; margin-top: 1px; }
.subforum-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.subforum-link {
  font-size: 0.78rem; padding: 2px 10px; border-radius: 12px;
  background: var(--panel-3); color: var(--text); border: 1px solid var(--border);
}
.subforum-link:hover { color: var(--text-strong); border-color: var(--accent-2); text-decoration: none; }
.subforum-link.unread { border-color: var(--accent); color: var(--text-strong); font-weight: 600; }
.forum-stats { display: flex; flex-direction: column; font-size: 0.88rem; color: var(--text); text-align: right; }
.forum-stats small { color: var(--muted); }
.forum-last { display: flex; gap: 9px; align-items: center; min-width: 0; }
.last-info { min-width: 0; }
.last-thread { display: block; font-size: 0.86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.home-side { position: sticky; top: 92px; }
.side-panel h3 { margin-top: 0; }
.side-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.side-thread { font-weight: 500; font-size: 0.9rem; }
.online-list { display: flex; flex-wrap: wrap; gap: 3px 10px; margin-bottom: 8px; }
.stat-list { margin: 0; }
.stat-list div { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px dashed var(--border-soft); }
.stat-list div:last-child { border-bottom: none; }
.stat-list dt { color: var(--muted); }
.stat-list dd { margin: 0; font-weight: 600; }

/* ---------------- forum & thread lists ---------------- */
.forum-head-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 8px 0 14px; }
.forum-head-bar h1 { margin: 0; }
.forum-head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filter-bar { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.filter-prefixes { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-sort select { width: auto; padding: 5px 10px; margin: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; font-size: 0.78rem; font-weight: 600;
  background: var(--panel-3); color: var(--text); padding: 3px 10px; border-radius: 12px;
  border: 1px solid var(--border);
}
a.chip:hover { text-decoration: none; border-color: var(--accent-2); }
.chip.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.chip-danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.chip-staff { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

.thread-list { padding: 0; overflow: hidden; }
.thread-row {
  display: grid; grid-template-columns: 34px 1fr 140px 150px;
  gap: 12px; align-items: center; padding: 11px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.thread-row:last-child { border-bottom: none; }
.thread-row:hover { background: var(--panel-2); }
.thread-row.sticky { background: var(--accent-soft); }
.thread-row.deleted { opacity: 0.55; }
.thread-marks { display: flex; align-items: center; justify-content: center; gap: 2px; color: var(--muted); }
.mark-ico .icon { width: 15px; height: 15px; }
.thread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); display: inline-block; }
.thread-dot.hot { background: var(--unread); box-shadow: 0 0 6px var(--unread); }
.thread-title { font-weight: 600; color: var(--text-strong); font-size: 0.98rem; }
.thread-row.unread .thread-title { color: var(--accent); }
.thread-title-line { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.thread-sub { margin-top: 1px; }
.thread-nums { display: flex; flex-direction: column; text-align: right; font-size: 0.88rem; }
.thread-nums small { color: var(--muted); }
.thread-last { text-align: right; min-width: 0; }
.forum-foot { margin-top: 6px; }

.prefix {
  display: inline-block; font-size: 0.72rem; font-weight: 700; padding: 2px 8px;
  border-radius: 5px; text-transform: uppercase; letter-spacing: 0.03em; line-height: 1.4;
  color: #fff;
}
.prefix-default { background: #5a6178; }
.prefix-blue { background: #4a6fd0; }
.prefix-green { background: #2f9e6e; }
.prefix-red { background: #c94f56; }
.prefix-orange { background: #cd7a29; }
.prefix-purple { background: #8659c9; }
.prefix-teal { background: #2b9d9d; }
.prefix-pink { background: #c65592; }
.prefix-gold { background: #b8912c; }
.prefix-gray { background: #6b7080; }
.prefix-engine { background: #3f5b8f; }
.prefix-reactor { background: #226d84; }

/* ---------------- pagination ---------------- */
.pagination { display: flex; gap: 5px; margin: 14px 0; flex-wrap: wrap; }
.page-btn {
  min-width: 34px; text-align: center; padding: 5px 9px; border-radius: 7px;
  background: var(--panel); border: 1px solid var(--border); color: var(--text); font-size: 0.9rem;
}
.page-btn:hover { border-color: var(--accent-2); text-decoration: none; }
.page-btn.current { background: var(--accent); color: #1a1405; border-color: var(--accent); font-weight: 700; }
.page-gap { padding: 5px 2px; color: var(--muted); }

/* ---------------- thread view / posts ---------------- */
.thread-head { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; flex-wrap: wrap; margin: 8px 0 14px; }
.thread-head h1 { margin: 0 0 4px; display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.thread-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.mod-tools summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.mod-tools-grid { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; align-items: center; }
.mod-inline { display: flex; gap: 6px; align-items: center; }
.mod-inline select, .mod-inline input[type="text"] { width: auto; margin: 0; padding: 5px 9px; }

.post-list { display: flex; flex-direction: column; gap: 14px; margin-bottom: 14px; }
.post { display: grid; grid-template-columns: 168px 1fr; gap: 0; padding: 0; overflow: hidden; }
.post-deleted { border-color: var(--danger); opacity: 0.85; }
.post-author {
  background: var(--panel-2); padding: 18px 14px; text-align: center;
  border-right: 1px solid var(--border-soft); display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.pa-name { font-size: 1rem; margin-top: 4px; }
.pa-title { font-style: italic; }
.pa-level { display: flex; align-items: center; gap: 5px; margin-top: 2px; }
.post-author .xp-bar { width: 100%; }
.pa-stats { width: 100%; margin: 6px 0 0; }
.pa-stats div { display: flex; justify-content: space-between; padding: 2px 0; }
.pa-stats dt { font-weight: 400; }
.pa-stats dd { margin: 0; font-weight: 600; color: var(--text); }
.post-body-col { padding: 14px 20px 12px; display: flex; flex-direction: column; min-width: 0; }
.post-meta { display: flex; justify-content: space-between; border-bottom: 1px solid var(--border-soft); padding-bottom: 7px; margin-bottom: 12px; }
.post-body { flex: 1; overflow-wrap: break-word; }
.deleted-note { background: var(--danger-soft); color: var(--danger); border-radius: 7px; padding: 8px 12px; margin-bottom: 10px; font-size: 0.9rem; }
.edit-note { margin-top: 10px; font-style: italic; }
.post-signature {
  border-top: 1px dashed var(--border); margin-top: 14px; padding-top: 8px; font-size: 0.85rem; opacity: 0.8;
}
.post-signature .bb-img { max-height: 90px; }
.post-attachment { margin-top: 10px; }
.post-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; padding-top: 9px; border-top: 1px solid var(--border-soft); flex-wrap: wrap; }
.post-actions { display: flex; gap: 13px; align-items: center; flex-wrap: wrap; }
.ignored-post summary { cursor: pointer; padding: 6px 0; }

.reactions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.reaction-pill {
  display: inline-flex; align-items: center; gap: 5px; background: var(--panel-3); border: 1px solid var(--border);
  border-radius: 12px; padding: 2px 9px; font-size: 0.83rem;
}
.reaction-pill.mine { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.reaction-pill[data-type="like"], .react-choice[data-type="like"] { --rc: 217; }
.reaction-pill[data-type="love"], .react-choice[data-type="love"] { --rc: 346; }
.reaction-pill[data-type="haha"], .react-choice[data-type="haha"] { --rc: 42; }
.reaction-pill[data-type="wow"], .react-choice[data-type="wow"] { --rc: 262; }
.reaction-pill[data-type="helpful"], .react-choice[data-type="helpful"] { --rc: 152; }
.reaction-pill[data-type="creative"], .react-choice[data-type="creative"] { --rc: 300; }
.reaction-pill[data-type] {
  color: hsl(var(--rc) 70% 48%); background: hsl(var(--rc) 70% 48% / 0.14); border-color: hsl(var(--rc) 70% 48% / 0.45);
}
.reaction-pill[data-type].mine { background: hsl(var(--rc) 70% 48% / 0.24); border-color: hsl(var(--rc) 70% 48%); }
.react-choice[data-type]:hover { color: hsl(var(--rc) 70% 48%); background: hsl(var(--rc) 70% 48% / 0.14); }
.react-picker { position: relative; display: inline-block; }
.react-menu {
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
  display: flex; gap: 2px; padding: 5px; z-index: 20;
}
.react-menu[hidden] { display: none; }
.react-choice {
  background: none; border: none; cursor: pointer; border-radius: 8px; padding: 6px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--text); font-size: 0.65rem;
}
.react-choice .icon { width: 18px; height: 18px; }
.react-choice:hover { background: var(--panel-3); color: var(--accent); }
.rc-label { white-space: nowrap; }

.reply-panel h3 { margin-top: 0; }
.reply-actions { display: flex; gap: 10px; align-items: center; margin-top: 12px; }

/* ---------------- editor ---------------- */
.editor { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--bg-deep); }
.editor-toolbar {
  display: flex; align-items: center; gap: 2px; padding: 6px 8px;
  background: var(--panel-2); border-bottom: 1px solid var(--border-soft); flex-wrap: wrap;
}
.editor-toolbar button, .tb-help {
  background: none; border: none; color: var(--text); cursor: pointer; border-radius: 6px;
  padding: 5px 9px; font-size: 0.9rem; min-width: 30px; text-align: center; display: inline-flex; align-items: center; justify-content: center;
}
.editor-toolbar button:hover, .tb-help:hover { background: var(--panel-3); color: var(--text-strong); text-decoration: none; }
.tb-sep { width: 1px; height: 18px; background: var(--border); margin: 0 5px; }
.tb-spacer { flex: 1; }
.tb-preview { font-weight: 600; color: var(--accent-2) !important; }
.editor-textarea {
  width: 100%; border: none; border-radius: 0; margin: 0; padding: 12px 14px;
  background: var(--bg-deep); color: var(--text); resize: vertical; min-height: 120px; font: inherit;
}
.editor-textarea:focus { outline: none; }
.editor-preview { padding: 12px 14px; border-top: 1px dashed var(--border); background: var(--panel); }
.editor-attach { padding: 8px 12px; border-top: 1px solid var(--border-soft); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.attach-btn { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--link); font-size: 0.9rem; margin: 0; }
.attach-hint { color: var(--muted); font-size: 0.8rem; }
.attach-list { display: flex; flex-direction: column; gap: 4px; width: 100%; font-size: 0.85rem; }
.attach-item { display: flex; align-items: center; gap: 8px; }
.attach-item.error { color: var(--danger); }

/* ---------------- BBCode content ---------------- */
.bb-content { line-height: 1.6; }
.bb-content img.bb-img { max-width: 100%; max-height: 560px; border-radius: 8px; margin: 4px 0; }
.bb-quote {
  margin: 8px 0; padding: 9px 14px; background: var(--panel-2);
  border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0; font-size: 0.93em;
}
.quote-head { font-weight: 600; color: var(--accent); font-size: 0.85em; margin-bottom: 5px; }
.quote-jump { font-weight: 400; }
.bb-code { margin: 10px 0; background: var(--bg-deep); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.bb-code pre { margin: 0; padding: 12px 14px; overflow-x: auto; font-size: 0.86em; line-height: 1.5; }
.code-lang {
  display: block; padding: 4px 14px; background: var(--panel-3); font-size: 0.75em;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted);
}
.bb-icode { background: var(--panel-3); }
.bb-spoiler { margin: 10px 0; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); }
.bb-spoiler summary { cursor: pointer; padding: 8px 14px; font-weight: 600; color: var(--accent-2); }
.spoiler-body { padding: 4px 14px 12px; }
.bb-video { position: relative; padding-top: 56.25%; margin: 10px 0; border-radius: 8px; overflow: hidden; max-width: 720px; }
.bb-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.bb-list { margin: 8px 0; padding-left: 26px; }
.bb-hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.bb-u { text-decoration: underline; }
.bb-mention { font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 0 4px; border-radius: 4px; }
.bb-attach-file {
  display: inline-flex; align-items: center; gap: 6px; background: var(--panel-2); border: 1px solid var(--border);
  padding: 7px 12px; border-radius: 8px; margin: 4px 0;
}
.attach-size { color: var(--muted); font-size: 0.83em; }

/* ---------------- polls ---------------- */
.poll-panel h3 { display: flex; align-items: center; gap: 8px; }
.poll-option {
  display: grid; grid-template-columns: auto 220px 1fr 90px; gap: 10px; align-items: center;
  margin: 7px 0; font-weight: 400;
}
.poll-option.static { grid-template-columns: 220px 1fr 90px; }
.poll-option input { width: auto; margin: 0; }
.poll-text { font-weight: 500; }
.poll-bar { height: 14px; background: var(--bg-deep); border-radius: 7px; overflow: hidden; }
.poll-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-2), #a6bcff); }
.poll-count { text-align: right; font-size: 0.85rem; color: var(--muted); }
.poll-foot { display: flex; gap: 12px; align-items: center; margin-top: 10px; }
.poll-voters { margin: -3px 0 6px; padding-left: 26px; }
.poll-builder { margin: 14px 0; border: 1px dashed var(--border); border-radius: 10px; padding: 10px 14px; }
.poll-builder summary { cursor: pointer; font-weight: 600; }

/* ---------------- feeds / search ---------------- */
.post-feed { display: flex; flex-direction: column; gap: 12px; }
.feed-post { padding: 14px 18px; }
.feed-head { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.feed-body { font-size: 0.92rem; margin: 6px 0; }
.search-form { margin-bottom: 0; }

/* ---------------- members ---------------- */
.member-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; margin-bottom: 14px; }
.member-card { display: flex; gap: 12px; align-items: center; margin: 0; }
.mc-info { min-width: 0; }
.letter-bar { display: flex; gap: 2px; flex-wrap: wrap; }
.letter { padding: 3px 7px; border-radius: 5px; font-size: 0.82rem; color: var(--muted); }
.letter:hover { background: var(--panel-3); text-decoration: none; }
.letter.active { background: var(--accent); color: #1a1405; font-weight: 700; }

/* ---------------- profile ---------------- */
.profile-header { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.profile-header-main { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.profile-id h1 { margin: 0 0 2px; }
.profile-stats-row { display: flex; gap: 18px; margin: 8px 0; flex-wrap: wrap; }
.profile-actions { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.mod-user-tools { position: relative; }
.mod-user-tools summary { list-style: none; }
.mod-user-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; width: 300px;
  display: flex; flex-direction: column; gap: 10px;
}
.tab-bar { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; overflow-x: auto; }
.tab {
  padding: 9px 16px; color: var(--muted); font-weight: 600; font-size: 0.94rem;
  border-bottom: 2px solid transparent; margin-bottom: -2px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
}
.tab:hover { color: var(--text-strong); text-decoration: none; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.about-list div { display: flex; padding: 7px 0; border-bottom: 1px dashed var(--border-soft); }
.about-list div:last-child { border-bottom: none; }
.about-list dt { width: 150px; color: var(--muted); flex-shrink: 0; }
.about-list dd { margin: 0; }
.wall-form { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 18px; }
.wall-form textarea { margin: 0; }
.wall-post { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border-soft); }
.wall-body { flex: 1; min-width: 0; }
.wall-text { white-space: pre-line; }
.wall-comment { padding: 6px 0 2px 14px; border-left: 2px solid var(--border-soft); margin-top: 6px; font-size: 0.92rem; }
.wall-comment-form { display: flex; gap: 8px; margin-top: 8px; }
.wall-comment-form input { margin: 0; }
.achievement-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.achievement-card { display: flex; gap: 14px; align-items: center; margin: 0; }
.achievement-card.locked { opacity: 0.5; }
.achievement-card.earned { border-color: var(--accent); }
.ach-icon {
  width: 46px; height: 46px; display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent); border-radius: 50%; flex-shrink: 0;
}
.ach-icon .icon { width: 22px; height: 22px; }
.achievement-card.locked .ach-icon { background: var(--panel-3); color: var(--muted); }
.ach-date { color: var(--success); }

/* ---------------- account ---------------- */
.account-grid { display: grid; grid-template-columns: 230px 1fr; gap: 16px; align-items: start; }
.account-nav { display: flex; flex-direction: column; padding: 8px; }
.account-nav a {
  padding: 10px 14px; border-radius: 8px; color: var(--text); font-weight: 500;
  display: flex; align-items: center; gap: 8px;
}
.account-nav a:hover { background: var(--panel-3); text-decoration: none; }
.account-nav a.active { background: var(--accent-soft); color: var(--accent); }
.avatar-edit { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.avatar-form input[type="file"] { margin: 0; }

/* ---------------- notifications ---------------- */
.notif-list { padding: 6px; }
.notif-row {
  display: flex; justify-content: space-between; gap: 14px; padding: 12px 14px;
  border-radius: 8px; color: var(--text); align-items: center;
}
.notif-row:hover { background: var(--panel-2); text-decoration: none; }
.notif-row.unread { background: var(--info-soft); }
.notif-row.unread .notif-text::before {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent-2); margin-right: 8px; vertical-align: middle;
}
.notif-time { color: var(--muted); font-size: 0.83rem; white-space: nowrap; }

/* ---------------- leaderboard ---------------- */
.lb-grid { display: grid; grid-template-columns: 1fr 320px; gap: 16px; align-items: start; }
.lb-list { list-style: none; margin: 0; padding: 0; }
.lb-row { display: flex; align-items: center; gap: 12px; padding: 9px 6px; border-bottom: 1px solid var(--border-soft); }
.lb-row:last-child { border-bottom: none; }
.lb-list.compact .lb-row { padding: 6px 2px; font-size: 0.92rem; }
.lb-rank { width: 40px; text-align: center; font-weight: 700; color: var(--muted); flex-shrink: 0; }
.lb-rank.medal .icon { width: 20px; height: 20px; }
.medal-1 { color: #e8b64c; }
.medal-2 { color: #b8c0d4; }
.medal-3 { color: #c98a5a; }
.lb-who { flex: 1; min-width: 0; }
.lb-score { font-size: 0.95rem; margin-left: auto; }
.lb-top { background: var(--accent-soft); border-radius: 8px; }

/* ---------------- tables / admin ---------------- */
.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th {
  text-align: left; padding: 8px 10px; color: var(--muted); font-size: 0.8rem;
  text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 2px solid var(--border);
}
.table td { padding: 8px 10px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.table tr:hover td { background: var(--panel-2); }
.row-actions { display: flex; gap: 6px; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-tile { text-align: center; margin: 0; }
.stat-tile.alert { border-color: var(--danger); }
.st-num { font-size: 1.8rem; font-weight: 700; color: var(--text-strong); }
.admin-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.perm-grid { display: flex; gap: 6px 16px; flex-wrap: wrap; margin: 8px 0; }
.perm-grid .check { margin: 2px 0; }
.report-card .report-head { margin-bottom: 6px; }
.report-reason {
  background: var(--danger-soft); color: var(--danger); border-radius: 7px; padding: 8px 12px;
  margin: 8px 0; font-size: 0.92rem; display: flex; gap: 8px; align-items: flex-start;
}
.report-post-body { background: var(--panel-2); border-radius: 8px; padding: 10px 14px; margin-top: 8px; }
.history-version { background: var(--panel-2); border-radius: 8px; padding: 12px 16px; margin-bottom: 12px; }
.history-version.old { opacity: 0.8; border-left: 3px solid var(--muted); }
.history-head { margin-top: 18px; }
.reaction-user-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 8px; }

/* ---------------- rich (WYSIWYG) editor ---------------- */
.editor-rich {
  padding: 12px 14px; background: var(--bg-deep); color: var(--text);
  outline: none; overflow-y: auto; max-height: 60vh; line-height: 1.55;
  white-space: pre-wrap; overflow-wrap: break-word;
}
.editor-rich blockquote {
  margin: 8px 0; padding: 8px 14px; background: var(--panel-2);
  border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0; white-space: pre-wrap;
}
.editor-rich blockquote[data-bbattr]::before {
  content: attr(data-bbattr) " said:"; display: block; font-weight: 600; font-size: 0.85em;
  color: var(--accent); margin-bottom: 4px;
}
.editor-rich pre {
  margin: 8px 0; padding: 10px 14px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; font-family: monospace; font-size: 0.88em; white-space: pre-wrap;
}
.editor-rich pre[data-lang]::before {
  content: attr(data-lang); display: block; text-transform: uppercase; letter-spacing: 0.06em;
  font-size: 0.72em; color: var(--muted); margin-bottom: 4px;
}
.editor-rich .rich-spoiler {
  margin: 8px 0; padding: 8px 14px; background: var(--panel-2); border: 1px dashed var(--border);
  border-radius: 8px; white-space: pre-wrap;
}
.editor-rich .rich-spoiler::before {
  content: "Spoiler: " attr(data-title); display: block; font-weight: 600; font-size: 0.85em;
  color: var(--accent-2); margin-bottom: 4px;
}
.editor-rich table { border-collapse: collapse; margin: 8px 0; }
.editor-rich th, .editor-rich td { border: 1px solid var(--border); padding: 5px 12px; min-width: 60px; }
.editor-rich th { background: var(--panel-2); font-weight: 600; }
.editor-rich img { max-width: 320px; max-height: 200px; border-radius: 6px; display: inline-block; vertical-align: middle; }
.editor-rich ul, .editor-rich ol { margin: 6px 0; padding-left: 26px; white-space: normal; }
.editor-rich hr { border: none; border-top: 1px solid var(--border); margin: 10px 0; }
.embed-chip {
  display: inline-block; background: var(--accent-soft); color: var(--accent);
  border: 1px solid var(--accent); border-radius: 6px; padding: 1px 10px;
  font-size: 0.82em; font-weight: 600; cursor: default; user-select: none;
}
.editor-rich:empty::before { content: attr(data-placeholder); color: var(--muted); pointer-events: none; }
.editor-rich a { text-decoration: underline; }
.editor:not(.raw-mode) .editor-textarea { display: none; }
.editor.raw-mode .editor-rich { display: none; }
.tb-mode { font-family: monospace; font-size: 0.78rem !important; color: var(--muted) !important; }
.tb-mode:hover { color: var(--text-strong) !important; }

/* ---------------- admin appearance / banners ---------------- */
.site-logo { height: 60px; width: auto; max-width: 400px; display: block; }
.logo-preview {
  background: var(--panel-2); border: 1px dashed var(--border); border-radius: 8px;
  padding: 10px 16px; display: inline-block; margin-bottom: 8px;
}
.logo-preview img { max-height: 48px; max-width: 300px; display: block; }
.logo-edit { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.banner-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin: 12px 0; }
.banner-card { border: 2px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--panel-2); }
.banner-card.selected { border-color: var(--accent); }
.banner-card img { width: 100%; height: 120px; object-fit: cover; display: block; }
.banner-card-foot { padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }

/* ---------------- resource manager ---------------- */
.res-list { padding: 0; overflow: hidden; }
.res-row {
  display: grid; grid-template-columns: 52px 1fr 170px; gap: 14px; align-items: center;
  padding: 13px 18px; border-bottom: 1px solid var(--border-soft);
}
.res-row:last-child { border-bottom: none; }
.res-row:hover { background: var(--panel-2); }
.res-icon {
  width: 46px; height: 46px; display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  color: hsl(var(--ih, 42), 62%, 62%);
  background: hsla(var(--ih, 42), 62%, 60%, 0.14);
}
[data-theme="light"] .res-icon {
  color: hsl(var(--ih, 42), 58%, 34%);
  background: hsla(var(--ih, 42), 55%, 42%, 0.12);
}
.res-icon .icon { width: 22px; height: 22px; }
.res-title { font-weight: 600; font-size: 1.02rem; color: var(--text-strong); }
.res-title-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.res-tagline { margin: 1px 0; }
.res-stats { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.res-search { display: flex; gap: 6px; align-items: center; }
.res-search input, .res-search select { width: auto; margin: 0; }
.stars { display: inline-flex; gap: 1px; color: var(--accent); }
.star-ico { width: 0.95em; height: 0.95em; }
.res-header { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.res-header-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.res-ver { font-size: 1rem; font-weight: 400; }
.res-numbers { display: flex; gap: 18px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.res-version { padding: 10px 0; border-bottom: 1px dashed var(--border-soft); }
.res-version:last-of-type { border-bottom: none; }
.res-version.latest .rv-head strong { color: var(--success); }
.rv-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.rv-log { margin-top: 4px; font-size: 0.92rem; }
.res-update-box { margin-top: 12px; }
.res-update-box summary { display: inline-flex; list-style: none; cursor: pointer; }
.review-form { margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border-soft); }
/* resource page: OGA-style two-column layout */
.res-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
.res-col-side { display: flex; flex-direction: column; gap: 18px; position: sticky; top: 76px; }
@media (max-width: 900px) { .res-layout { grid-template-columns: 1fr; } .res-col-side { position: static; } }

.res-preview-panel { display: flex; flex-direction: column; gap: 10px; }
.res-preview-stage { text-align: center; background: var(--bg-deep); border-radius: 10px; padding: 10px; }
.res-preview-stage img { max-width: 100%; max-height: 420px; border-radius: 6px; image-rendering: pixelated; }
.res-preview-thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.res-thumb-wrap { position: relative; display: inline-flex; }
.res-preview-thumb {
  width: 72px; height: 72px; object-fit: cover; border-radius: 6px; cursor: pointer;
  border: 2px solid var(--border); image-rendering: pixelated;
}
.res-preview-thumb:hover { border-color: var(--accent); }
.res-thumb-del { position: absolute; top: -6px; right: -6px; }
.res-thumb-del button {
  background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger);
  border-radius: 50%; width: 20px; height: 20px; cursor: pointer; display: flex;
  align-items: center; justify-content: center; padding: 0;
}
.res-thumb-del .icon { width: 11px; height: 11px; }
.res-audio { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.res-audio audio { flex: 1 1 240px; min-width: 200px; }
.res-audio > .icon { color: var(--accent); width: 22px; height: 22px; }

.license-row { padding: 8px 0; border-bottom: 1px dashed var(--border-soft); }
.license-row:last-of-type { border-bottom: none; }
.license-chip { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent); font-weight: 600; }
a.license-chip:hover { text-decoration: none; filter: brightness(1.15); }
.license-attr-head { margin-top: 12px; font-size: 0.9rem; }
.license-attr {
  background: var(--bg-deep); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-size: 0.82rem; white-space: pre-wrap; word-break: break-word;
  font-family: inherit; margin: 6px 0 0; user-select: all;
}
.res-file-line { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 10px; word-break: break-word; }
.res-file-line > .icon { color: var(--accent); flex-shrink: 0; margin-top: 3px; }
.res-comment-form { margin-top: 12px; }

/* resource browse: card grid */
.res-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.res-card { display: flex; flex-direction: column; padding: 0; overflow: hidden; color: var(--text); }
.res-card:hover { text-decoration: none; border-color: var(--accent-2); transform: translateY(-2px); }
.res-card-thumb {
  height: 140px; background: var(--bg-deep); display: flex; align-items: center; justify-content: center;
  border-bottom: 1px solid var(--border);
}
.res-card-thumb img { width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; }
.res-card-ico .icon { width: 42px; height: 42px; color: hsl(var(--ih, 220) 60% 60%); }
.res-card-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.res-card .res-title { font-weight: 600; color: var(--text-strong); }
.res-card-foot { margin-top: auto; padding-top: 8px; display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.res-card-licenses { display: flex; gap: 4px; flex-wrap: wrap; }
.res-card-licenses .chip { font-size: 0.68rem; padding: 1px 7px; }
.res-card-stats { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }

/* license picker on the publish form */
.license-picker { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin: 14px 0; }
.license-picker legend { padding: 0 6px; font-weight: 600; }
.license-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 6px; }
.license-option { align-items: flex-start; }
.license-option input { margin-top: 4px; }

.review-row { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--border-soft); }
.review-row:last-child { border-bottom: none; }
.review-body { flex: 1; min-width: 0; }
.review-text { margin-top: 2px; }
@media (max-width: 760px) {
  .res-row { grid-template-columns: 44px 1fr; }
  .res-stats { display: none; }
  .res-header-actions { align-items: flex-start; }
}

/* ---------------- code highlighting ---------------- */
.hl-com { color: var(--muted); font-style: italic; }
.hl-str { color: var(--success); }
.hl-num { color: #d19a66; }
[data-theme="light"] .hl-num { color: #b25f13; }
.hl-kw { color: var(--accent-2); font-weight: 600; }

/* ---------------- solutions / round-3 additions ---------------- */
.solved-banner {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--success-soft); border: 1px solid var(--success); color: var(--success);
  border-radius: var(--radius); padding: 10px 16px; margin-bottom: 14px; font-weight: 600;
}
.solved-banner a { color: var(--success); text-decoration: underline; }
.post-solution { border-color: var(--success); box-shadow: 0 0 0 1px var(--success), var(--shadow); }
.chip-solution { background: var(--success-soft); color: var(--success); border-color: var(--success); font-size: 0.68rem; }
.mark-ico.solved { color: var(--success); }

.bb-itch { width: 100%; max-width: 552px; height: 167px; border: 0; border-radius: 8px; margin: 8px 0; display: block; }

.backup-codes { background: var(--panel-2); border: 1px dashed var(--accent); border-radius: 10px; padding: 14px 18px; margin: 12px 0; }
.code-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-top: 8px; }
.code-grid code { font-size: 1rem; letter-spacing: 0.05em; padding: 6px 10px; text-align: center; }

.quote-body.collapsed { max-height: 170px; overflow: hidden; position: relative; }
.quote-body.collapsed::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 56px;
  background: linear-gradient(transparent, var(--panel-2));
}
.quote-expand { margin-top: 4px; }

#backTop {
  position: fixed; bottom: 18px; left: 18px; z-index: 80;
  background: var(--panel); border: 1px solid var(--border); color: var(--text);
  border-radius: 50%; width: 40px; height: 40px; cursor: pointer; box-shadow: var(--shadow);
  display: none; align-items: center; justify-content: center;
}
#backTop.show { display: flex; }
#backTop:hover { border-color: var(--accent-2); color: var(--text-strong); }

.help-page .bb-content { max-width: 800px; }

/* ---------------- feature-complete additions ---------------- */
.bb-table-wrap { overflow-x: auto; margin: 10px 0; }
.bb-table { border-collapse: collapse; min-width: 280px; }
.bb-table th, .bb-table td { border: 1px solid var(--border); padding: 6px 12px; text-align: left; }
.bb-table th { background: var(--panel-2); color: var(--text-strong); font-weight: 600; }
.bb-table tr:nth-child(even) td { background: var(--panel-2); }

.avatar-holder { position: relative; display: inline-block; }
.online-dot {
  position: absolute; bottom: 3px; right: 3px; width: 13px; height: 13px; border-radius: 50%;
  background: var(--success); border: 2px solid var(--panel);
}
.pa-pronouns { margin-top: -2px; }
.chip-op { background: var(--info-soft); color: var(--accent-2); border-color: var(--accent-2); font-size: 0.66rem; padding: 1px 7px; }
.post-ip { margin-left: 8px; opacity: 0.7; }

.thread-nav { display: flex; justify-content: space-between; gap: 10px; margin: 4px 0 14px; flex-wrap: wrap; }

.active-bookmark { color: var(--accent); font-weight: 600; }
.mq-bar {
  position: fixed; bottom: 18px; right: 18px; z-index: 90;
  background: var(--panel); border: 1px solid var(--accent); border-radius: 10px;
  padding: 8px 10px; display: flex; gap: 8px; box-shadow: var(--shadow);
}

.batch-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.batch-bar select { width: auto; margin: 0; }
.batch-check { width: auto !important; margin: 0; justify-self: center; }
.thread-row:has(.batch-check) { grid-template-columns: 24px 34px 1fr 140px 150px; }

.totp-secret { margin: 8px 0; }
.totp-secret code { font-size: 1.1rem; letter-spacing: 0.08em; padding: 6px 12px; }
.totp-uri { word-break: break-all; font-size: 0.75rem; }
.setup-steps li { margin-bottom: 12px; }

/* ---------------- similar threads / mini pages ---------------- */
.similar-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.similar-list li { display: flex; flex-direction: column; }
.similar-list a { font-weight: 500; }
.mini-pages { display: inline-flex; gap: 3px; }
.mini-pages a {
  font-size: 0.72rem; padding: 0 6px; border: 1px solid var(--border); border-radius: 5px;
  color: var(--muted); line-height: 1.5;
}
.mini-pages a:hover { border-color: var(--accent-2); color: var(--link); text-decoration: none; }
.mini-pages .muted { font-size: 0.72rem; }
.bb-content { overflow-wrap: break-word; word-break: break-word; }

/* ---------------- misc ---------------- */
.error-page { text-align: center; padding: 60px 20px; max-width: 520px; margin: 40px auto; }
.error-dice { color: var(--accent); }
.error-dice .icon { width: 64px; height: 64px; }
.report-modal {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.report-modal[hidden] { display: none; }
.report-modal-inner { width: 100%; max-width: 460px; margin: 0; }
.invite-form { position: absolute; z-index: 30; display: flex; gap: 8px; width: 260px; }
.invite-form input { margin: 0; }
.inline-details { position: relative; display: inline-block; }
.inline-details summary { list-style: none; }
.bb-help td { font-size: 0.9rem; }

.site-footer { background: var(--bg-deep); border-top: 1px solid var(--border); margin-top: 30px; padding: 22px 0; font-size: 0.88rem; color: var(--muted); }
.footer-inner { display: flex; flex-direction: column; gap: 6px; }
.footer-brand .icon { color: var(--accent); }

/* ---------------- responsive ---------------- */
@media (max-width: 1080px) {
  .header-search { display: none; }
  .header-user .search-link { display: inline-flex; }
  .header-user { margin-left: auto; }
}
@media (max-width: 1000px) {
  .home-grid, .lb-grid, .admin-two-col { grid-template-columns: 1fr; }
  .home-side { position: static; }
  .forum-row { grid-template-columns: 40px 1fr 90px; }
  .forum-last { display: none; }
}
@media (max-width: 900px) {
  .table { display: block; overflow-x: auto; }
}
@media (max-width: 760px) {
  .nav-burger { display: block; margin-left: auto; }
  .main-nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    background: var(--panel); border-bottom: 1px solid var(--border); flex-direction: column; padding: 8px;
  }
  .main-nav.open { display: flex; }
  .header-inner { gap: 8px; }
  .post { grid-template-columns: 1fr; }
  .post-author {
    flex-direction: row; text-align: left; border-right: none; border-bottom: 1px solid var(--border-soft);
    padding: 10px 14px; flex-wrap: wrap; gap: 10px; align-items: center;
  }
  .post-author .xp-bar, .pa-stats { display: none; }
  .thread-row { grid-template-columns: 26px 1fr 80px; }
  .thread-last { display: none; }
  .account-grid { grid-template-columns: 1fr; }
  .breadcrumbs { overflow-wrap: anywhere; }
  .poll-option, .poll-option.static { grid-template-columns: auto 1fr 70px; }
  .poll-option .poll-bar { grid-column: auto; }
  .poll-option.static { grid-template-columns: 1fr 70px; }
  .poll-option.static .poll-bar { grid-column: 1 / -1; }
  .profile-header, .profile-header-main { flex-direction: column; }
}

@media (max-width: 480px) {
  .site-logo { height: 44px; max-width: 190px; }
  .logo-text { font-size: 1.05rem; }
  .icon-btn { padding: 6px; }
  .wrap { padding: 0 10px; }
  .post-body-col { padding: 12px 12px 10px; }
  .panel { padding: 12px; }
}

/* ================================================================
   Messenger-style conversations: chat bubbles + floating widget
   ================================================================ */
.msg-thread { display: flex; flex-direction: column; gap: 2px; min-height: 120px; }
.msg-row { display: flex; align-items: flex-end; gap: 8px; max-width: 78%; }
.msg-row.incoming { align-self: flex-start; }
.msg-row.outgoing { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar { flex-shrink: 0; align-self: flex-end; }
.msg-col { display: flex; flex-direction: column; min-width: 0; }
.msg-row.outgoing .msg-col { align-items: flex-end; }
.msg-name { font-size: 0.76rem; font-weight: 600; color: var(--muted); margin: 6px 0 2px 2px; }
.msg-bubble {
  background: var(--panel-3); border-radius: 16px; padding: 8px 13px; overflow-wrap: break-word;
  word-break: break-word; max-width: 100%;
}
.msg-row.outgoing .msg-bubble { background: var(--accent-soft); border: 1px solid var(--accent); }
.msg-content { line-height: 1.45; }
.msg-content > *:first-child { margin-top: 0; }
.msg-content > *:last-child { margin-bottom: 0; }
.msg-reply-quote {
  border-left: 3px solid var(--border); padding: 2px 8px; margin-bottom: 6px; font-size: 0.82rem;
  color: var(--muted); overflow-wrap: break-word;
}
.msg-meta {
  display: flex; align-items: center; gap: 6px; margin-top: 3px; opacity: 0; transition: opacity 0.12s;
  font-size: 0.7rem; color: var(--muted);
}
.msg-row:hover .msg-meta, .msg-row:focus-within .msg-meta { opacity: 1; }
.msg-meta .icon { width: 14px; height: 14px; }
.msg-meta .react-picker { position: relative; display: inline-flex; }
.msg-row.outgoing .msg-meta { flex-direction: row-reverse; }
.msg-row .reactions[data-msg] { margin-top: 3px; }
.msg-row .reactions[data-msg]:empty { display: none; }
.msg-reply-preview {
  display: none; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; margin-bottom: 8px; font-size: 0.85rem;
}
.msg-reply-preview:not([hidden]) { display: flex; }
.msg-reply-preview .linklike { display: inline-flex; }
.bb-audio { max-width: 280px; width: 100%; height: 34px; }

/* ---- conversations: sidebar + main two-column layout ---- */
.conv-layout { display: flex; gap: 16px; align-items: stretch; height: 76vh; min-height: 480px; }
.conv-sidebar {
  width: 300px; flex-shrink: 0; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden;
}
.conv-sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 14px 10px; flex-shrink: 0; }
.conv-sidebar-head h2 { margin: 0; font-size: 1.05rem; display: flex; align-items: center; gap: 6px; }
.conv-list { flex: 1; overflow-y: auto; padding: 4px; }
.conv-row { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 10px; color: var(--text); }
.conv-row:hover { background: var(--panel-3); text-decoration: none; }
.conv-row.active { background: var(--accent-soft); }
.conv-row-avatar { flex-shrink: 0; }
.conv-row-main { flex: 1; min-width: 0; }
.conv-row-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.conv-row-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-row.unread .conv-row-title { font-weight: 800; color: var(--text-strong); }
.conv-row-time { flex-shrink: 0; }
.conv-row-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.conv-row.unread .conv-row-preview { color: var(--text); }
.conv-row-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--unread); flex-shrink: 0; }

.conv-main {
  flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.conv-main-empty { align-items: center; justify-content: center; }
.conv-main-empty .empty-state { text-align: center; }
.conv-main-empty .empty-state .icon { width: 40px; height: 40px; color: var(--muted); margin-bottom: 8px; }
.conv-main-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--border-soft); flex-shrink: 0;
}
.conv-main-head h2 { margin: 0 0 3px; font-size: 1.1rem; }
.conv-main-actions { display: flex; gap: 8px; flex-shrink: 0; }
.conv-main-pager { padding: 8px 16px 0; flex-shrink: 0; }
.conv-main .msg-thread { flex: 1; overflow-y: auto; padding: 16px; }
.conv-main #msg-bottom { display: none; }
.conv-main .msg-reply-preview { margin: 0 16px; }
.conv-main-reply { padding: 10px 16px 14px; border-top: 1px solid var(--border-soft); flex-shrink: 0; }
.conv-main-reply .reply-actions { margin-top: 8px; }

@media (max-width: 900px) {
  .conv-layout { flex-direction: column; height: auto; }
  .conv-sidebar { width: auto; max-height: 280px; }
  .conv-main { height: 65vh; min-height: 420px; }
}

/* ---- floating widget ---- */
#mwWrap { position: fixed; right: 20px; bottom: 20px; z-index: 90; }
#mwFab {
  position: relative; width: 54px; height: 54px; border-radius: 50%; background: var(--accent); color: #14161d;
  border: none; box-shadow: var(--shadow); cursor: pointer; display: flex; align-items: center; justify-content: center;
}
#mwFab .icon { width: 24px; height: 24px; }
#mwFab .badge { top: -2px; right: -2px; }
#mwPanel {
  position: absolute; right: 0; bottom: 66px; width: 340px; height: 480px; max-height: 70vh;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  display: none; flex-direction: column; overflow: hidden;
}
#mwPanel:not([hidden]) { display: flex; }
.mw-view { display: none; flex-direction: column; flex: 1; min-height: 0; }
.mw-view:not([hidden]) { display: flex; }
.mw-header {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border-soft);
  background: var(--panel-2); flex-shrink: 0;
}
.mw-title { font-weight: 700; flex: 1; display: flex; align-items: center; gap: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mw-header-actions { display: flex; gap: 2px; }
.mw-back { font-size: 1.3rem; line-height: 1; padding: 2px 4px; }
.mw-expand { font-size: 0.78rem; color: var(--muted); }
.mw-list { flex: 1; overflow-y: auto; }
.mw-conv-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; border-bottom: 1px solid var(--border-soft); }
.mw-conv-item:hover { background: var(--panel-3); }
.mw-conv-item.unread .mw-conv-title { font-weight: 700; }
.mw-conv-info { flex: 1; min-width: 0; }
.mw-conv-title, .mw-conv-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mw-conv-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--unread); flex-shrink: 0; }
.mw-empty { padding: 30px 16px; text-align: center; color: var(--muted); font-size: 0.9rem; }
.mw-messages { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.mw-input-row { display: flex; align-items: center; gap: 6px; padding: 8px; border-top: 1px solid var(--border-soft); flex-shrink: 0; }
.mw-input-row textarea {
  flex: 1; resize: none; max-height: 90px; border-radius: 16px; padding: 7px 12px; border: 1px solid var(--border);
  background: var(--bg-deep); color: var(--text); font: inherit;
}
.mw-attach-btn, .mw-mic-btn, .mw-send-btn {
  background: none; border: none; color: var(--muted); cursor: pointer; padding: 0; flex-shrink: 0;
  width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
}
.mw-attach-btn .icon, .mw-mic-btn .icon, .mw-send-btn .icon { width: 19px; height: 19px; }
.mw-attach-btn:hover, .mw-mic-btn:hover, .mw-send-btn:hover:not(:disabled) { background: var(--panel-3); color: var(--text-strong); }
.mw-send-btn:disabled { opacity: 0.4; cursor: default; }
.mw-mic-btn.recording { color: var(--danger); background: var(--danger-soft); animation: mw-pulse 1.2s ease-in-out infinite; }
@keyframes mw-pulse { 50% { opacity: 0.5; } }
.mw-compose { padding: 12px; display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 0; }
.mw-compose input[type="text"] { margin: 0; }
.mw-compose-suggestions { max-height: 160px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.mw-suggestion { display: flex; align-items: center; gap: 8px; padding: 7px 10px; cursor: pointer; }
.mw-suggestion:hover { background: var(--panel-3); }
.mw-suggestion-empty { padding: 10px; color: var(--muted); font-size: 0.85rem; }
.mw-compose-selected:empty { display: none; }
.mw-recipient-chip {
  display: inline-flex; align-items: center; gap: 4px; background: var(--accent-soft); color: var(--accent);
  border-radius: 12px; padding: 3px 5px 3px 10px; font-size: 0.85rem; margin: 2px;
}
.mw-recipient-chip button { background: none; border: none; color: inherit; cursor: pointer; display: flex; padding: 2px; opacity: 0.7; }
.mw-recipient-chip button:hover { opacity: 1; }
.mw-recipient-chip .icon { width: 12px; height: 12px; }
.mw-compose textarea { flex: 1; resize: vertical; min-height: 90px; }

@media (max-width: 480px) {
  #mwWrap { right: 12px; bottom: 12px; }
  #mwPanel { width: calc(100vw - 24px); right: -8px; }
}
