/* VortexForum styles. Light and dark themes via tokens; no external fonts or CDNs. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e3e6eb;
  --border-strong: #cfd4dc;
  --text: #171a21;
  --text-2: #4b5260;
  --muted: #6b7280;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;
  --accent-text: #ffffff;
  --success: #15803d;
  --success-soft: #e9f8ee;
  --warn: #b45309;
  --warn-soft: #fff6e6;
  --danger: #b91c1c;
  --danger-soft: #fdecec;
  --code-bg: #0f172a;
  --code-text: #e2e8f0;
  --inline-code-bg: #eef1f5;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);
  --radius: 10px;
  --radius-sm: 7px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --topbar-h: 60px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0d1117;
  --surface: #151b23;
  --surface-2: #1c232d;
  --border: #29313d;
  --border-strong: #3a4452;
  --text: #e6e9ef;
  --text-2: #b4bccb;
  --muted: #8a93a3;
  --accent: #818cf8;
  --accent-hover: #a5b4fc;
  --accent-soft: #1f2340;
  --accent-text: #0d1117;
  --success: #4ade80;
  --success-soft: #11291b;
  --warn: #fbbf24;
  --warn-soft: #2d2410;
  --danger: #f87171;
  --danger-soft: #2f1414;
  --code-bg: #0a0e14;
  --inline-code-bg: #222a35;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117; --surface: #151b23; --surface-2: #1c232d; --border: #29313d; --border-strong: #3a4452;
    --text: #e6e9ef; --text-2: #b4bccb; --muted: #8a93a3; --accent: #818cf8; --accent-hover: #a5b4fc;
    --accent-soft: #1f2340; --accent-text: #0d1117; --success: #4ade80; --success-soft: #11291b;
    --warn: #fbbf24; --warn-soft: #2d2410; --danger: #f87171; --danger-soft: #2f1414; --code-bg: #0a0e14;
    --inline-code-bg: #222a35; --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[x-cloak] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 15px/1.6 var(--font);
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .8em; }
img { max-width: 100%; }
.icon { flex-shrink: 0; vertical-align: -3px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.pad { padding: 12px 14px; margin: 0; }
.inline { display: inline; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; }
.skip-link:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
code { font-family: var(--mono); font-size: .88em; }

/* ---------- Buttons and inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font: 600 14px/1 var(--font); cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-text); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-ghost.is-on { color: var(--accent); background: var(--accent-soft); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); background: var(--danger); color: #fff; }
.btn-github { background: #1f2328; border-color: #1f2328; color: #fff; }
.btn-github:hover { background: #32383f; color: #fff; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; }
.btn-xs { height: 28px; padding: 0 9px; font-size: 12.5px; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; position: relative; width: 36px; height: 36px;
  border: 0; border-radius: 8px; background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.link-btn { border: 0; background: none; color: var(--accent); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }

input[type=text], input[type=email], input[type=password], input[type=search], input[type=url], input[type=number],
select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: 14.5px/1.4 var(--font);
}
input[type=color] { width: 56px; height: 38px; padding: 2px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); }
textarea { resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-weight: 600; font-size: 14px; display: flex; justify-content: space-between; align-items: baseline; }
.field-link { font-weight: 500; font-size: 13px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.check input { margin-top: 4px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row select, .row input { width: auto; flex: 1 1 140px; }
.row-form { display: flex; gap: 8px; flex-wrap: wrap; }
.row-form input { flex: 1 1 240px; width: auto; }
.form-actions { display: flex; gap: 10px; align-items: center; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }

/* ---------- Top bar */
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar-h); background: var(--surface);
  border-bottom: 1px solid var(--border); box-shadow: var(--shadow);
}
.topbar-inner { max-width: 1240px; margin: 0 auto; height: 100%; display: flex; align-items: center; gap: 16px; padding: 0 20px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 16.5px; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; color: var(--text); }
.search { flex: 1; max-width: 460px; position: relative; display: flex; align-items: center; }
.search .icon { position: absolute; left: 11px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 34px; background: var(--surface-2); border-color: transparent; height: 38px; }
.search input:focus { background: var(--surface); border-color: var(--accent); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.icon-btn .count {
  position: absolute; top: 2px; right: 1px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  background: var(--danger); color: #fff; font: 700 10.5px/17px var(--font); text-align: center;
}
.avatar-btn { border: 0; background: none; padding: 2px; border-radius: 50%; cursor: pointer; }
.nav-toggle { display: none; }

.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; z-index: 60;
}
.dropdown-wide { width: 360px; max-height: 440px; overflow-y: auto; }
.dropdown-right { right: 0; }
.dropdown-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; flex-wrap: wrap; }
.dropdown-menu > a, .dropdown-menu > button, .dropdown-menu form > button {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; border: 0; border-radius: 6px;
  background: none; color: var(--text); font: 14px/1.3 var(--font); text-align: left; cursor: pointer;
}
.dropdown-menu > a:hover, .dropdown-menu > button:hover, .dropdown-menu form > button:hover { background: var(--surface-2); text-decoration: none; }
.dropdown-menu .danger { color: var(--danger); }
.menu-form { padding: 6px 10px; }
.menu-form label { display: flex; gap: 8px; align-items: center; font-size: 14px; margin-bottom: 6px; }
.notif-row { display: flex; flex-direction: column; gap: 2px; padding: 9px 10px; border-radius: 6px; color: var(--text); font-size: 13.5px; }
.notif-row:hover { background: var(--surface-2); text-decoration: none; }
.notif-row.unread { background: var(--accent-soft); }
.notif-row small { color: var(--muted); }

.announcement { background: var(--accent); color: var(--accent-text); text-align: center; padding: 8px 16px; font-weight: 600; font-size: 14px; }
.banner { background: var(--warn-soft); color: var(--text); border-bottom: 1px solid var(--border); padding: 9px 20px; text-align: center; font-size: 14px; }
.banner-error { background: var(--danger-soft); }

/* ---------- Layout */
.layout { flex: 1; width: 100%; max-width: 1240px; margin: 0 auto; padding: 24px 20px 48px; display: grid; grid-template-columns: 232px minmax(0, 1fr); gap: 28px; }
.layout-narrow { grid-template-columns: minmax(0, 1fr); max-width: 460px; }
.sidebar { position: sticky; top: calc(var(--topbar-h) + 24px); align-self: start; }
.side-nav { display: flex; flex-direction: column; gap: 14px; }
.side-heading { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 6px 10px -6px; }
.side-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.side-list a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px; color: var(--text-2); font-weight: 550; font-size: 14px;
}
.side-list a:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.side-list a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.side-badge { margin-left: auto; color: var(--muted); display: inline-flex; }
.dot { width: 10px; height: 10px; border-radius: 3px; background: var(--cat, var(--accent)); flex-shrink: 0; display: inline-block; }
.side-footer { display: flex; flex-direction: column; gap: 6px; padding: 10px; font-size: 13px; border-top: 1px solid var(--border); }
.side-footer a { color: var(--muted); display: flex; gap: 7px; align-items: center; }
.main { min-width: 0; }
.footer { border-top: 1px solid var(--border); padding: 18px 20px; display: flex; justify-content: center; gap: 16px; font-size: 13px; color: var(--text-2); }

.flashes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.flash { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 9px 9px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); font-size: 14px; }
.flash-success { background: var(--success-soft); border-color: transparent; }
.flash-error { background: var(--danger-soft); border-color: transparent; }
.flash-info { background: var(--accent-soft); border-color: transparent; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: 14px; box-shadow: var(--shadow-lg); z-index: 90; }

/* ---------- Hero and lists */
.hero { margin-bottom: 18px; }
.hero h1 { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.hero p { color: var(--text-2); margin: 0; max-width: 720px; }
.hero-category .dot { width: 14px; height: 14px; border-radius: 4px; }
.hero-note { margin-top: 8px !important; font-size: 14px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.page-title { margin-bottom: 16px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head .page-title { margin: 0; }
.list-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 12px; }
.sort-tabs { display: flex; gap: 2px; background: var(--surface-2); padding: 3px; border-radius: 9px; overflow-x: auto; max-width: 100%; }
.sort-tabs a { padding: 6px 12px; border-radius: 7px; font-size: 13.5px; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.sort-tabs a:hover { color: var(--text); text-decoration: none; }
.sort-tabs a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.discussion-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.discussion-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); position: relative; }
.discussion-item:last-child { border-bottom: 0; }
.discussion-item::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--cat); opacity: 0; }
.discussion-item:hover { background: var(--surface-2); }
.discussion-item:hover::before, .discussion-item.is-unread::before { opacity: 1; }
.discussion-item.is-hidden { opacity: .6; }
.di-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.di-badges:empty { display: none; }
.di-title { display: block; color: var(--text); font-weight: 600; font-size: 15.5px; line-height: 1.35; margin: 2px 0 5px; word-break: break-word; }
.is-unread .di-title { font-weight: 750; }
.di-title:hover { color: var(--accent); text-decoration: none; }
.di-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 13px; color: var(--muted); }
.di-meta a:not(.category-pill):not(.tag-pill) { color: var(--text-2); font-weight: 600; }
.di-activity { display: inline-flex; gap: 5px; align-items: center; }
.di-stats { display: flex; gap: 14px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.di-stats span { display: inline-flex; gap: 5px; align-items: center; min-width: 42px; }
.di-replies.has-new { color: var(--accent); font-weight: 700; }

.category-pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 7px; border-radius: 6px; background: color-mix(in srgb, var(--cat) 12%, transparent); color: var(--text) !important; font-size: 12.5px; font-weight: 600; }
.category-pill .dot { width: 8px; height: 8px; border-radius: 2px; }
.category-pill:hover { text-decoration: none; background: color-mix(in srgb, var(--cat) 22%, transparent); }
.tag-pill { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--text-2) !important; font-size: 12.5px; font-weight: 550; border: 1px solid transparent; cursor: pointer; font-family: var(--font); }
.tag-pill:hover { text-decoration: none; border-color: var(--border-strong); }
.tag-pill.selected { background: var(--accent-soft); border-color: var(--accent); color: var(--accent) !important; }
.flag { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 5px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.flag-pin { background: var(--accent-soft); color: var(--accent); }
.flag-lock { background: var(--surface-2); color: var(--text-2); }
.flag-solved { background: var(--success-soft); color: var(--success); }
.flag-solved:hover { text-decoration: none; color: var(--success); }
.flag-pending { background: var(--warn-soft); color: var(--warn); }
.flag-hidden { background: var(--danger-soft); color: var(--danger); }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 5px; font-size: 11.5px; font-weight: 650; background: var(--surface-2); color: var(--text-2); vertical-align: 2px; }
.badge-staff { background: var(--accent); color: var(--accent-text); }
.badge-verified { background: var(--success-soft); color: var(--success); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }

.avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: #fff; font-weight: 700; overflow: hidden; flex-shrink: 0; background: var(--surface-2); user-select: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-xs { width: 22px; height: 22px; font-size: 11px; }
.avatar-sm { width: 30px; height: 30px; font-size: 13px; }
.avatar-md { width: 40px; height: 40px; font-size: 16px; }
.avatar-lg { width: 48px; height: 48px; font-size: 19px; }
.avatar-xl { width: 88px; height: 88px; font-size: 34px; }

.empty { text-align: center; padding: 48px 20px; background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius); color: var(--text-2); }
.empty .icon { color: var(--muted); margin-bottom: 8px; }
.tag-cloud { margin-top: 28px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag-cloud h3 { width: 100%; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.tag-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.tag-grid a { display: flex; flex-direction: column; gap: 2px; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); height: 100%; }
.tag-grid a:hover { border-color: var(--accent); text-decoration: none; }
.tag-grid small { color: var(--text-2); }

.pager { display: flex; justify-content: center; align-items: center; gap: 4px; margin: 20px 0; flex-wrap: wrap; }
.pager-link, .pager-current, .pager-gap { min-width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border-radius: 7px; font-size: 14px; font-weight: 600; }
.pager-link { color: var(--text-2); }
.pager-link:hover { background: var(--surface); text-decoration: none; }
.pager-current { background: var(--accent); color: var(--accent-text); }

/* ---------- Discussion page */
.discussion-head { margin-bottom: 20px; }
.discussion-head h1 { font-size: 1.75rem; margin: 10px 0 8px; word-break: break-word; }
.dh-meta, .dh-flags { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13.5px; }
.dh-actions { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
.solution-box { background: var(--success-soft); border: 1px solid color-mix(in srgb, var(--success) 35%, transparent); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 20px; }
.solution-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; color: var(--success); font-weight: 700; margin-bottom: 6px; }
.solution-head a.muted { margin-left: auto; font-weight: 500; }
.solution-box .prose { max-height: 260px; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }

.post-stream { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.post { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 14px; scroll-margin-top: calc(var(--topbar-h) + 16px); }
.post-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px 10px; box-shadow: var(--shadow); min-width: 0; }
.post.is-solution .post-card { border-color: var(--success); box-shadow: 0 0 0 1px var(--success); }
.post.is-hidden .post-card, .post.is-pending .post-card { opacity: .75; border-style: dashed; }
.post.is-target .post-card { animation: target-flash 2.2s ease-out; }
@keyframes target-flash { 0% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: var(--shadow); } }
.post-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; font-size: 13.5px; margin-bottom: 8px; }
.post-author { font-weight: 700; color: var(--text); font-size: 14.5px; }
.post-time { color: var(--muted); }
.post-number { margin-left: auto; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.post-notice { display: flex; gap: 7px; align-items: center; font-size: 13px; padding: 6px 10px; border-radius: 6px; background: var(--warn-soft); color: var(--warn); margin-bottom: 10px; font-weight: 600; }
.post-notice-danger { background: var(--danger-soft); color: var(--danger); }
.post-notice-success { background: var(--success-soft); color: var(--success); }
.post-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.reactions { display: flex; gap: 4px; flex-wrap: wrap; }
.reaction { display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 9px; border: 1px solid var(--border); border-radius: 14px; background: transparent; color: var(--text-2); font: 600 12.5px/1 var(--font); cursor: pointer; }
.reaction:hover { border-color: var(--border-strong); color: var(--text); }
.reaction.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.reaction.is-static { cursor: default; }
.reaction .r-label { display: none; }
.reaction:hover .r-label, .reaction.active .r-label { display: inline; }
.post-actions { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.report-box { margin-top: 10px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); display: flex; flex-direction: column; gap: 8px; }

.reply-area { margin-top: 24px; }
.reply-form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.reply-head { display: flex; align-items: center; gap: 10px; }
.notice { padding: 14px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.notice-success { background: var(--success-soft); border-color: transparent; }

/* ---------- Prose (rendered Markdown) */
.prose { font-size: 15px; line-height: 1.65; overflow-wrap: anywhere; }
.prose > :last-child { margin-bottom: 0; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose pre, .prose table { margin: 0 0 .9em; }
.prose h1, .prose h2, .prose h3, .prose h4 { margin: 1.1em 0 .5em; }
.prose h1 { font-size: 1.35rem; } .prose h2 { font-size: 1.2rem; } .prose h3 { font-size: 1.05rem; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li + li { margin-top: .25em; }
.prose blockquote { border-left: 3px solid var(--border-strong); padding: 2px 0 2px 14px; color: var(--text-2); }
.prose code { background: var(--inline-code-bg); padding: .12em .38em; border-radius: 5px; }
.prose pre { background: var(--code-bg); color: var(--code-text); padding: 14px 16px; border-radius: 8px; overflow-x: auto; font-size: 13.5px; line-height: 1.5; }
.prose pre code { background: none; padding: 0; color: inherit; font-size: inherit; }
.prose img { border-radius: 6px; max-height: 520px; }
.prose table { border-collapse: collapse; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--border); padding: 6px 10px; }
.prose th { background: var(--surface-2); }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 1.4em 0; }
.prose a.mention { background: var(--accent-soft); padding: 0 4px; border-radius: 4px; font-weight: 600; }
mark { background: color-mix(in srgb, var(--warn) 30%, transparent); color: inherit; padding: 0 2px; border-radius: 3px; }

/* ---------- Editor */
.editor { border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); position: relative; }
.editor:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.editor-bar { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); padding: 4px 6px; gap: 6px; flex-wrap: wrap; }
.editor-tabs { display: flex; gap: 2px; }
.editor-tabs button, .editor-tools button { border: 0; background: none; padding: 5px 10px; border-radius: 6px; cursor: pointer; color: var(--text-2); font: 600 13px/1 var(--font); display: inline-flex; align-items: center; }
.editor-tools button { padding: 6px 7px; }
.editor-tabs button.active { background: var(--surface-2); color: var(--text); }
.editor-tabs button:hover, .editor-tools button:hover { background: var(--surface-2); color: var(--text); }
.editor-tools { display: flex; gap: 1px; }
.editor-body { position: relative; }
.editor textarea { border: 0; border-radius: 0; box-shadow: none !important; font-family: var(--mono); font-size: 14px; min-height: 160px; background: transparent; }
.editor-preview { padding: 12px 14px; min-height: 160px; }
.editor-hint { border-top: 1px solid var(--border); padding: 6px 12px; font-size: 12.5px; color: var(--muted); }
.editor-hint code { background: var(--inline-code-bg); padding: 0 4px; border-radius: 4px; }
.mention-menu { position: absolute; left: 12px; bottom: 8px; list-style: none; margin: 0; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-lg); min-width: 240px; z-index: 30; }
.mention-menu li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.mention-menu li.active, .mention-menu li:hover { background: var(--accent-soft); }
.tag-picker { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Panels and pages */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.panel h2 { display: flex; align-items: center; gap: 8px; }
details.panel > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel[open] > summary { margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.cat-form { display: flex; flex-direction: column; gap: 12px; }
.danger-zone { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border-strong); font-size: 14px; }

.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); margin-top: 16px; }
.auth-card h1 { margin-bottom: 4px; }
.auth-alt { text-align: center; margin: 18px 0 0; font-size: 14px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 16px 0; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }

.profile-card { display: grid; grid-template-columns: auto 1fr auto; gap: 20px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); margin-bottom: 18px; }
.profile-card > .btn { grid-column: 1 / -1; justify-self: start; }
.profile-info h1 { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 2px; }
.profile-info .bio { color: var(--text-2); white-space: pre-line; margin-top: 8px; }
.profile-stats { display: flex; gap: 22px; margin: 0; }
.profile-stats div { text-align: center; }
.profile-stats dt { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.profile-stats dd { margin: 0; font-size: 1.4rem; font-weight: 750; }
.avatar-edit { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.activity-list { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.activity-list li { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.activity-list li:last-child { border-bottom: 0; }
.activity-head { font-size: 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.activity-head a { font-weight: 650; }
.activity-excerpt { color: var(--text-2); font-size: 14px; margin: 4px 0 0; }

.notif-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.notif-list li a { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--text); }
.notif-list li:last-child a { border-bottom: 0; }
.notif-list li a:hover { background: var(--surface-2); text-decoration: none; }
.notif-list li.unread a { background: var(--accent-soft); }
.notif-text { flex: 1; font-size: 14.5px; }

.search-big { display: flex; gap: 8px; align-items: center; position: relative; margin-bottom: 14px; }
.search-big .icon { position: absolute; left: 12px; color: var(--muted); }
.search-big input { padding-left: 38px; height: 44px; font-size: 16px; }
.search-big .btn { height: 44px; }
.search-results { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.search-results li { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.search-results li:last-child { border-bottom: 0; }
.sr-title { font-weight: 650; font-size: 15.5px; color: var(--text); }
.sr-snippet { color: var(--text-2); font-size: 14px; margin: 6px 0 0; }

.error-page .error-code { display: block; font-size: 3.2rem; font-weight: 800; color: var(--accent); line-height: 1; margin-bottom: 8px; }

/* ---------- Admin */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; color: var(--text); box-shadow: var(--shadow); }
a.stat:hover { border-color: var(--accent); text-decoration: none; color: var(--text); }
.stat span { font-size: 12.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat strong { font-size: 1.7rem; font-weight: 750; }
.stat small { color: var(--text-2); }
.stat-alert { border-color: var(--warn); background: var(--warn-soft); }
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.checklist li { display: flex; gap: 8px; align-items: center; color: var(--warn); font-size: 14px; }
.checklist li.ok { color: var(--success); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; }
.table tr:last-child td { border-bottom: 0; }
.filter-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.filter-bar input[type=search] { flex: 1 1 220px; width: auto; }
.filter-bar select { width: auto; }
.user-row summary .muted { font-size: 13px; }
.user-actions { display: flex; flex-direction: column; gap: 10px; }
.queue { list-style: none; margin: 0; padding: 0; }
.queue-head { font-size: 14px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.queue-body { background: var(--surface-2); padding: 12px 14px; border-radius: 8px; margin-bottom: 12px; max-height: 320px; overflow: auto; }
.queue-body.is-hidden { opacity: .6; }

/* ---------- Responsive */
@media (max-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding-top: 16px; }
  .nav-toggle { display: inline-flex; }
  .sidebar { position: fixed; left: 0; right: 0; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); height: calc(100dvh - var(--topbar-h)); z-index: 35; background: rgba(0, 0, 0, .35); display: none; }
  .sidebar .side-nav { background: var(--bg); width: 280px; height: 100%; overflow-y: auto; padding: 18px 14px; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { display: block; }
  .layout-narrow .sidebar { display: none !important; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .topbar-inner { padding: 0 10px; gap: 8px; }
  .brand span { display: none; }
  .search { max-width: none; }
  .topbar-actions { gap: 2px; }
  .topbar-actions .btn { height: 34px; padding: 0 9px; font-size: 13px; }
  .layout { padding: 14px 12px 36px; }
  .discussion-item { grid-template-columns: auto minmax(0, 1fr); padding: 12px; gap: 10px; }
  .di-stats { grid-column: 2; gap: 10px; }
  .di-avatar .avatar { width: 34px; height: 34px; font-size: 14px; }
  .post { grid-template-columns: minmax(0, 1fr); }
  .post-side { display: none; }
  .post-card { padding: 12px 14px 8px; }
  .discussion-head h1 { font-size: 1.4rem; }
  .profile-card { grid-template-columns: auto 1fr; }
  .profile-stats { grid-column: 1 / -1; justify-content: space-around; }
  .grid-2, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .dropdown-wide { width: min(360px, calc(100vw - 20px)); right: -60px; }
  .auth-card { padding: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
