/* flatbb — core stylesheet. Everything is driven by the CSS variables below.
 * Plugins and themes override variables; see docs/THEME.md. */

:root {
  --brand: #e7672e; --brand-hover: #cf5722; --brand-soft: #fdeee6; --brand-text: #fff;
  --bg: #f5f6f8; --panel: #ffffff; --panel-2: #f8f9fb; --line: #e6e8ec; --line-soft: #eff1f4;
  --text: #1f2328; --text-muted: #667085; --text-subtle: #98a2b3; --text-disabled: #c0c6d0;
  --success: #16a34a; --success-soft: #dcfce7; --danger: #dc2626; --danger-soft: #fee2e2;
  --warning: #d97706; --warning-soft: #fef3c7; --info: #2563eb; --info-soft: #dbeafe;
  --backdrop: rgba(15, 18, 24, .5); --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .05); --shadow-md: 0 12px 32px rgba(16, 24, 40, .14);
  --radius: 12px; --radius-sm: 8px; --radius-pill: 999px;
  --font: "Nunito", sans-serif;
  --font-size-xs: 11px; --font-size-sm: 12px; --font-size-md: 14px; --font-size-lg: 16px; --font-size-xl: 18px; --font-size-2xl: 22px; --font-size-3xl: 26px;
  --topbar-h: 56px; --left-w: 220px; --right-w: 280px; --gap: 24px; --container: 1280px;
  color-scheme: light;
}
[data-theme="dark"] { --bg: #111418; --panel: #191d23; --panel-2: #1f242b; --line: #2a3038; --line-soft: #232930; --text: #e6e8eb; --text-muted: #9aa4b2; --text-subtle: #6b7482; --text-disabled: #4a525e; --brand-soft: rgba(231, 103, 46, .16); --success-soft: rgba(22, 163, 74, .18); --danger-soft: rgba(220, 38, 38, .18); --warning-soft: rgba(217, 119, 6, .18); --info-soft: rgba(37, 99, 235, .18); --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-md: 0 8px 24px rgba(0, 0, 0, .5); color-scheme: dark; }
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] { --bg: #111418; --panel: #191d23; --panel-2: #1f242b; --line: #2a3038; --line-soft: #232930; --text: #e6e8eb; --text-muted: #9aa4b2; --text-subtle: #6b7482; --text-disabled: #4a525e; --brand-soft: rgba(231, 103, 46, .16); --success-soft: rgba(22, 163, 74, .18); --danger-soft: rgba(220, 38, 38, .18); --warning-soft: rgba(217, 119, 6, .18); --info-soft: rgba(37, 99, 235, .18); --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-md: 0 8px 24px rgba(0, 0, 0, .5); color-scheme: dark; }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: var(--font-size-md)/1.55 var(--font); color: var(--text); background: var(--bg); min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--brand); text-decoration: none; transition: color .12s; }
a:hover { color: var(--brand-hover); }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; font-weight: 650; }
h1 { font-size: var(--font-size-2xl); letter-spacing: -.01em; } h2 { font-size: var(--font-size-xl); } h3 { font-size: var(--font-size-lg); } h4 { font-size: var(--font-size-sm); text-transform: uppercase; letter-spacing: .04em; color: var(--text-subtle); }
p { margin: 0 0 1em; }
img { max-width: 100%; height: auto; }
code, pre { font-family: var(--mono); font-size: 13px; }
code { background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: 4px; padding: .1em .35em; }
pre { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; overflow: auto; }
pre code { background: none; border: 0; padding: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
small, .small { font-size: var(--font-size-sm); }
.muted { color: var(--text-muted); }
.hidden { display: none !important; }
.mono { font-family: var(--mono); }
.icon { width: 1.15em; height: 1.15em; vertical-align: -.2em; flex: none; }
.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 20px; }
.code-row { display: flex; gap: 8px; } .code-row input { flex: 1; min-width: 0; } .code-row .btn { white-space: nowrap; }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--radius-pill); background: var(--brand); color: #fff; font-size: var(--font-size-xs); font-weight: 600; line-height: 1; }
.flag { display: inline-block; padding: 1px 7px; border-radius: 4px; background: var(--brand-soft); color: var(--brand); font-size: var(--font-size-xs); font-weight: 600; vertical-align: middle; }
.flag-danger { background: var(--danger-soft); color: var(--danger); }
.flag-success { background: var(--success-soft); color: var(--success); }
.empty { text-align: center; padding: 56px 16px; color: var(--text-subtle); background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty .icon { width: 40px; height: 40px; opacity: .45; margin-bottom: 6px; }
mark { background: var(--warning-soft); color: inherit; border-radius: 2px; padding: 0 2px; }

/* ---------- buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); color: var(--text); font: inherit; font-weight: 550; cursor: pointer; line-height: 1.3; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--panel-2); border-color: var(--text-subtle); color: var(--text); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-text); box-shadow: 0 1px 2px color-mix(in srgb, var(--brand) 35%, transparent); }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: var(--brand-text); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--panel-2); border-color: transparent; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-sm { padding: 4px 10px; font-size: var(--font-size-sm); }
.btn-lg { padding: 10px 22px; font-size: var(--font-size-lg); }
.btn-block { width: 100%; justify-content: center; }
.btn.active { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-muted); cursor: pointer; position: relative; }
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn .icon { width: 20px; height: 20px; }
.icon-btn .badge { position: absolute; top: 3px; inset-inline-end: 3px; }
button.link { background: none; border: 0; padding: 0; color: var(--brand); cursor: pointer; font: inherit; }
input:not([type]), input[type="text"], input[type="search"], input[type="email"], input[type="password"], input[type="number"], input[type="url"], input[type="file"], select, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); color: var(--text); font: inherit; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--brand-soft); border-color: var(--brand); }
input:-webkit-autofill { -webkit-box-shadow: 0 0 0 1000px var(--panel) inset; -webkit-text-fill-color: var(--text); }
textarea { resize: vertical; min-height: 80px; }
input[type="color"] { width: 48px; height: 32px; padding: 2px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); }
.input-lg { font-size: var(--font-size-xl); padding: 10px 12px; }
.form-row { margin-bottom: 14px; }
.form-row > label { display: block; font-weight: 600; margin-bottom: 5px; font-size: var(--font-size-sm); }
.form-help { color: var(--text-muted); font-size: var(--font-size-sm); margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 16px; }
.form-actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.composer .form-actions, .page-compose .form-actions { justify-content: flex-end; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.check input { width: auto; }
.radio-row { display: flex; gap: 16px; flex-wrap: wrap; }
.hp { position: absolute; inset-inline-start: -9999px; }
.flash { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; background: var(--info-soft); color: var(--info); font-weight: 500; transition: opacity .4s; }
.flash-success { background: var(--success-soft); color: var(--success); }
.flash-error { background: var(--danger-soft); color: var(--danger); }
.flash.fade { opacity: 0; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); padding: 10px 16px; border-radius: var(--radius-sm); background: var(--text); color: var(--bg); box-shadow: var(--shadow-md); opacity: 0; transition: all .25s; z-index: 200; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-error { background: var(--danger); color: #fff; }

/* ---------- topbar ---------- */
.topbar { position: sticky; top: 0; z-index: 50; background: var(--panel); border-bottom: 1px solid var(--line); height: var(--topbar-h); }
.topbar-inner { display: flex; align-items: center; gap: 8px; height: 100%; }
.logo { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 700; font-size: var(--font-size-lg); margin-inline-end: 12px; }
.logo img { height: 32px; width: auto; }
.logo-mark { display: block; flex: none; }
.topnav { display: flex; gap: 4px; }
.topnav a { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: var(--radius-sm); color: var(--text-muted); font-weight: 500; }
.topnav a .icon { width: 16px; height: 16px; opacity: .8; }
.topnav a:hover, .topnav a.active { background: var(--panel-2); color: var(--text); }
.topbar-right { margin-inline-start: auto; display: flex; align-items: center; gap: 4px; }
.search-form { display: flex; align-items: center; gap: 6px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-pill); padding: 0 12px; height: 36px; width: 220px; color: var(--text-subtle); margin-inline-end: 6px; }
.search-form input { border: 0; background: none; padding: 0; height: 100%; }
.search-form input:focus { outline: 0; }
.search-form:focus-within { border-color: var(--brand); background: var(--panel); }
.search-toggle { display: none; }
.theme-sun { display: none; }
[data-theme="dark"] .theme-sun { display: block; } [data-theme="dark"] .theme-moon { display: none; }
@media (prefers-color-scheme: dark) { [data-theme="auto"] .theme-sun { display: block; } [data-theme="auto"] .theme-moon { display: none; } }
.drawer-toggle { display: none; }
.dropdown { position: relative; }
.dropdown-toggle { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; padding: 2px; cursor: pointer; font: inherit; color: inherit; border-radius: var(--radius-pill); }
.dropdown-menu { display: none; position: absolute; inset-inline-end: 0; top: calc(100% + 6px); min-width: 180px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 6px; z-index: 60; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu.floating { display: block; position: absolute; top: 0; inset-inline: auto; margin: 0; }
.dropdown-menu a, .dropdown-menu button, .dropdown-menu select { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--text); font: inherit; text-align: start; cursor: pointer; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--panel-2); }
.dropdown-menu button.danger { color: var(--danger); }
.dropdown-menu form { margin: 0; }
.lang-menu .dropdown-toggle { width: 36px; height: 36px; padding: 0; }
.lang-menu .dropdown-menu { min-width: 150px; }
.dropdown-menu button.active { color: var(--brand); font-weight: 600; }
.dropdown-head { padding: 6px 10px; font-weight: 600; color: var(--text-muted); font-size: var(--font-size-sm); border-bottom: 1px solid var(--line-soft); margin-bottom: 4px; }

/* ---------- three-column grid ---------- */
.page-grid { display: grid; grid-template-columns: var(--left-w) minmax(0, 1fr) var(--right-w); gap: var(--gap); padding-top: 20px; padding-bottom: 40px; flex: 1; align-items: start; }
body.no-left .page-grid { grid-template-columns: minmax(0, 1fr) var(--right-w); }
body.no-right .page-grid { grid-template-columns: var(--left-w) minmax(0, 1fr); }
body.no-left.no-right .page-grid { grid-template-columns: minmax(0, 1fr); max-width: 900px; }
.col-left { position: sticky; top: calc(var(--topbar-h) + 20px); }
.col-main { min-width: 0; }
.region:empty { display: none; }
.side-nav, .side-section { margin-bottom: 18px; }
.drawer-nav { display: none; padding-bottom: 12px; border-bottom: 1px solid var(--line-soft); } /* header.nav links, shown inside the mobile drawer only */
.side-link { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm); color: var(--text-muted); font-weight: 500; transition: background .12s, color .12s; }
.side-link .icon { width: 18px; height: 18px; }
.side-link:hover { background: var(--panel); color: var(--text); }
.side-link.active { background: var(--brand-soft); color: var(--brand); }
.side-link small { margin-inline-start: auto; color: var(--text-subtle); font-size: var(--font-size-xs); }
.side-section h4 { padding: 0 10px; margin-bottom: 6px; }
.cat-child { padding-inline-start: 26px; }
.side-tags .tag-cloud { padding: 0 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.card-stack { display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); }
.card-head h3 { margin: 0; font-size: var(--font-size-md); }
.card-body { padding: 16px; }
.card-body > :last-child { margin-bottom: 0; }
.me-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.me-head small { display: block; color: var(--text-muted); }
.me-stats { display: flex; gap: 8px; margin-bottom: 12px; }
.me-stats > * { flex: 1; text-align: center; background: var(--panel-2); border-radius: var(--radius-sm); padding: 8px 4px; color: var(--text); }
.me-stats b { display: block; font-size: var(--font-size-lg); }
.me-stats span { font-size: var(--font-size-xs); color: var(--text-muted); }
.stat-list { list-style: none; margin: 0; padding: 0; }
.stat-list li { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid var(--line-soft); }
.stat-list li:last-child { border: 0; }
/* newest members card: 4 per row, rounded-square avatar with the name underneath */
.newest-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 4px; }
.newest-item { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; color: var(--text); font-size: var(--font-size-xs); text-decoration: none; }
.newest-item .avatar { border-radius: 15%; }
.newest-item span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.newest-item:hover span { color: var(--brand); }
.link-list { list-style: none; margin: 0; padding: 6px 0; }
.link-list li { padding: 7px 16px; }
.link-list li a { color: var(--text); display: block; }
.link-list li small { color: var(--text-subtle); }
.layout-block { margin-bottom: 16px; }
.breadcrumbs { display: flex; flex-wrap: wrap; gap: 6px; font-size: var(--font-size-sm); color: var(--text-subtle); margin-bottom: 10px; }

/* ---------- avatars ---------- */
.avatar { width: var(--s, 32px); height: var(--s, 32px); border-radius: 50%; object-fit: cover; display: inline-block; vertical-align: middle; flex: none; }
.avatar-letter { display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: calc(var(--s, 32px) * .44); line-height: 1; background: linear-gradient(135deg, hsl(var(--hue, 20) 65% 58%), hsl(var(--hue, 20) 60% 46%)); }
.avatar-link { display: inline-flex; }
.user-link { color: var(--text); font-weight: 600; }
.user-link:hover { color: var(--brand); }

/* ---------- tabs & list head ---------- */
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.list-head > * { min-width: 0; max-width: 100%; }
.tabs { display: flex; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: var(--radius-sm); color: var(--text-muted); font-weight: 550; white-space: nowrap; flex: none; }
.tab:hover { color: var(--text); background: var(--panel-2); }
.tab.active { background: var(--brand-soft); color: var(--brand); }
.tabs-sub { border: 0; background: none; padding: 0; margin-bottom: 12px; }
.cat-bar { display: flex; gap: 4px; margin-bottom: 12px; max-width: 100%; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); }
.cat-bar::-webkit-scrollbar { display: none; }
.cat-item { display: inline-flex; align-items: center; gap: 5px; padding: 8px 10px; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--text-muted); font-size: var(--font-size-sm); font-weight: 550; white-space: nowrap; flex: none; }
.cat-item .icon { width: 15px; height: 15px; opacity: .75; }
.cat-badge .icon, .cat-link .icon { width: 14px; height: 14px; }
.cat-item:hover { color: var(--text); }
.cat-item.active { color: var(--brand); border-bottom-color: var(--brand); }
.cat-item.active .icon { opacity: 1; }
.cat-bar-mobile { display: none; }
.tabs-sub .tab { padding: 4px 10px; font-size: var(--font-size-sm); }
.tab .badge { background: var(--line); color: var(--text-muted); }

/* ---------- topic rows ---------- */
.topic-rows { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.topic-row { display: flex; align-items: flex-start; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--line-soft); }
.topic-row:last-child { border-bottom: 0; }
.topic-row:hover { background: var(--panel-2); }
.row-avatar { padding-top: 1px; }
.row-main { flex: 1; min-width: 0; }
.row-title { margin: 0 0 3px; font-size: var(--font-size-lg); font-weight: 500; line-height: 1.35; }
.row-title a { color: var(--text); }
.row-title a:hover { color: var(--brand); }
.topic-row.read .row-title a { color: var(--text-muted); font-weight: 450; }
.topic-row.read .row-title a:hover { color: var(--brand); }
.topic-row.unread .row-title a { font-weight: 650; }
.topic-row.unread .row-title::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--brand); margin-inline-end: 8px; vertical-align: 2px; }
.row-icon { color: var(--text-subtle); display: inline-flex; vertical-align: -2px; margin-inline-end: 2px; }
.row-icon .icon { width: 14px; height: 14px; }
.row-meta .meta.meta-cat { display: none; }
.row-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: var(--font-size-sm); color: var(--text-subtle); line-height: 1.4; }
.row-meta .meta { display: inline-flex; align-items: center; gap: 3px; color: var(--text-subtle); }
.row-meta .meta .icon { width: 13px; height: 13px; opacity: .8; }
.row-meta .user-link.plain { font-weight: 400; color: var(--text-muted); }
.row-meta .user-link.plain:hover, .row-meta a.meta:hover { color: var(--brand); }
.row-tag::before { content: ""; }
.row-cat { flex: none; align-self: center; padding: 1px 8px; border: 1px solid var(--line); border-radius: 4px; color: var(--text-muted); font-size: var(--font-size-xs); white-space: nowrap; }
.row-cat:hover { border-color: var(--text-subtle); color: var(--text); }
.cat-badge { display: inline-flex; align-items: center; gap: 5px; color: var(--text-muted); font-weight: 550; font-size: var(--font-size-sm); }
.cat-badge:hover { color: var(--text); }
.tag-badge { display: inline-block; padding: 1px 8px; border-radius: var(--radius-pill); background: var(--panel-2); border: 1px solid var(--line); color: var(--text-muted); font-size: var(--font-size-xs); font-weight: 500; }
.tag-badge:hover { border-color: var(--brand); color: var(--brand); }
.stat { display: inline-flex; align-items: center; gap: 4px; }
.pagination { display: flex; gap: 4px; justify-content: center; margin: 20px 0; flex-wrap: wrap; }
.pagination a, .pagination span { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 34px; padding: 0 8px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--panel); color: var(--text); }
.pagination a:hover { border-color: var(--brand); color: var(--brand); }
.pagination .page-cur { background: var(--brand); border-color: var(--brand); color: #fff; }
.pagination .page-gap { border: 0; background: none; }
.category-head { margin: 0 0 14px; }
.category-head h1 { margin-bottom: 2px; }
.category-head p { margin: 0; }
.cat-children { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.category-list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.category-row { display: grid; grid-template-columns: 1fr 140px 220px; gap: 16px; padding: 16px; border-bottom: 1px solid var(--line-soft); align-items: center; }
.category-row:last-child { border: 0; }
.category-row h3 { margin-bottom: 4px; }
.category-row h3 a { color: var(--text); display: inline-flex; align-items: center; gap: 8px; }
.category-row p { margin: 0; font-size: var(--font-size-sm); }
.cat-stats { display: flex; flex-direction: column; font-size: var(--font-size-sm); color: var(--text-muted); }
.cat-last { font-size: var(--font-size-sm); min-width: 0; }
.cat-last a { display: block; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-last small { color: var(--text-subtle); }
.tag-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.tag-card { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; padding: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.tag-card small { color: var(--text-subtle); }

/* ---------- topic page ---------- */
.topic-head { margin-bottom: 14px; }
.topic-title { font-size: var(--font-size-3xl); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.topic-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; color: var(--text-muted); font-size: var(--font-size-sm); margin-bottom: 10px; }
.topic-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.topic-tools .inline { display: inline; }
.dropdown-form { padding: 4px 6px; }
.post-stream { display: flex; flex-direction: column; gap: 12px; }
.post { display: block; padding: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); scroll-margin-top: calc(var(--topbar-h) + 12px); }

.post.deleted { opacity: .7; border-style: dashed; }
.post.highlight { animation: highlight 2.5s ease-out; }
@keyframes highlight { 0% { box-shadow: 0 0 0 3px var(--brand); } 100% { box-shadow: var(--shadow); } }
/* post header: avatar on the left, name above the meta line; the body below runs the full width */
.post-body { min-width: 0; }
.post-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.post-avatar { flex: none; }
.post-who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.post-name { display: flex; align-items: center; gap: 6px; font-size: var(--font-size-md); line-height: 1.3; min-width: 0; }
.post-name .user-link { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.post-meta { display: flex; align-items: center; gap: 8px; font-size: var(--font-size-xs); color: var(--text-subtle); line-height: 1.3; }
.post-time { color: var(--text-subtle); }
.post-floor { margin-inline-start: auto; align-self: flex-start; color: var(--text-subtle); font-family: var(--mono); font-size: var(--font-size-xs); }
.post-edited { color: var(--text-subtle); display: inline-flex; align-items: center; gap: 3px; }
.reply-quote { display: flex; align-items: center; gap: 8px; padding: 6px 10px; margin-bottom: 8px; background: var(--panel-2); border-inline-start: 3px solid var(--line); border-radius: 4px; color: var(--text-muted); font-size: var(--font-size-sm); }
.reply-quote span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.post-content { font-size: 15.5px; line-height: 1.7; word-wrap: break-word; overflow-wrap: anywhere; }
.post-content > :first-child { margin-top: 0; } .post-content > :last-child { margin-bottom: 0; }
.post-content h2, .post-content h3, .post-content h4 { margin: 1.2em 0 .5em; text-transform: none; letter-spacing: 0; color: inherit; }
.post-content h2 { font-size: var(--font-size-xl); } .post-content h3 { font-size: var(--font-size-lg); } .post-content h4 { font-size: var(--font-size-md); }
.post-content blockquote { margin: 0 0 1em; padding: 6px 14px; border-inline-start: 3px solid var(--brand); background: var(--panel-2); color: var(--text-muted); border-radius: 0; border-start-end-radius: 4px; border-end-end-radius: 4px; }
.post-content blockquote > :last-child { margin-bottom: 0; }
.post-content img {margin-left: auto; margin-right: auto; display: block; border-radius: var(--radius-sm); max-height: 600px; max-width: min(100%, var(--post-img-max, 100%)); height: auto; }
.post-tags { display: flex; gap: 6px; flex-wrap: wrap; margin: 14px 0 2px; }
.post-content ul, .post-content ol { padding-inline-start: 1.6em; margin: 0 0 1em; }
.post-content .table-wrap { overflow-x: auto; max-width: 100%; margin-bottom: 1em; -webkit-overflow-scrolling: touch; contain: inline-size; } /* contain: the wide table must not widen the column */
.post-content table { border-collapse: collapse; width: max-content; min-width: 100%; max-width: none; font-size: var(--font-size-sm); }
.post-content th, .post-content td { border: 1px solid var(--line); padding: 6px 10px; text-align: start; }
.post-content th { background: var(--panel-2); }
.post-content .mention { font-weight: 600; background: var(--brand-soft); padding: 0 4px; border-radius: 4px; }
.post-actions { display: flex; align-items: center; gap: 4px; margin-top: 12px; flex-wrap: wrap; }
.post-actions .inline { display: inline; }
.act { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--text-subtle); font: inherit; font-size: var(--font-size-sm); cursor: pointer; }
.act:hover { background: var(--panel-2); color: var(--text); }
.act.active { color: var(--brand); }
.act.active .icon { fill: var(--brand); }
.act.danger:hover { color: var(--danger); }
.act-static { cursor: default; opacity: .6; }
.act-static:hover { background: none; color: var(--text-subtle); }
.composer { margin-top: 24px; padding: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.composer h2 { font-size: var(--font-size-lg); }
.composer-locked { display: flex; align-items: center; gap: 10px; margin-top: 20px; padding: 14px 16px; background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); color: var(--text-muted); }
.composer-locked span { flex: 1; }
.reply-target { display: flex; align-items: center; gap: 8px; padding: 6px 10px; margin-bottom: 8px; background: var(--brand-soft); color: var(--brand); border-radius: var(--radius-sm); font-size: var(--font-size-sm); }
.compose h1 { margin-bottom: 14px; }

/* ---------- editor ---------- */
.editor { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); position: relative; }
.editor:focus-within { border-color: var(--brand); }
.editor.dragover { outline: 2px dashed var(--brand); }
.editor-toolbar { display: flex; align-items: center; gap: 2px; padding: 6px; border-bottom: 1px solid var(--line-soft); overflow-x: auto; scrollbar-width: none; }
.editor-toolbar::-webkit-scrollbar { display: none; }
.tb-btn { display: inline-flex; align-items: center; gap: 4px; padding: 5px 7px; border: 0; border-radius: 4px; background: none; color: var(--text-muted); cursor: pointer; font: inherit; font-size: var(--font-size-sm); flex: none; }
.tb-btn:hover, .tb-btn.active { background: var(--panel-2); color: var(--text); }
.tb-btn.active { color: var(--brand); }
.tb-btn .icon { width: 17px; height: 17px; }
.tb-sep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; flex: none; }
.tb-spacer { flex: 1; }
.editor-body { display: grid; grid-template-columns: 1fr; }
.editor.split .editor-body { grid-template-columns: 1fr 1fr; }
.editor.split .editor-preview { border-inline-start: 1px solid var(--line-soft); }
.editor.preview-only .editor-input { display: none; }
.editor-input { border: 0; border-radius: 0; min-height: 200px; font-family: var(--mono); font-size: 13.5px; line-height: 1.55; resize: vertical; }
.editor-input:focus { outline: 0; }
.editor-preview { padding: 12px 14px; min-height: 200px; overflow: auto; }
.editor-foot { display: flex; justify-content: space-between; align-items: center; padding: 5px 10px; border-top: 1px solid var(--line-soft); color: var(--text-subtle); font-size: var(--font-size-xs); }
.editor-foot .link { font-size: inherit; }
.editor-draft { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--warning-soft); color: var(--warning); font-size: var(--font-size-sm); border-bottom: 1px solid var(--line-soft); }
.editor-draft span { flex: 1; }
.editor-emoji { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 2px; padding: 8px; border-bottom: 1px solid var(--line-soft); max-height: 160px; overflow: auto; }
.editor-emoji button { border: 0; background: none; font-size: 20px; line-height: 1; padding: 5px 0; border-radius: 4px; cursor: pointer; }
.editor-emoji button:hover { background: var(--panel-2); }
.editor-help { position: absolute; inset-inline-start: 10px; bottom: 34px; z-index: 20; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-md); padding: 8px 12px; max-width: 520px; }
.editor-help table { border-collapse: collapse; font-size: var(--font-size-sm); }
.editor-help td { padding: 4px 10px 4px 0; vertical-align: top; color: var(--text-muted); }
.editor-help td:first-child { white-space: nowrap; }
.editor.fullscreen { position: fixed; inset: 0; z-index: 130; border-radius: 0; display: flex; flex-direction: column; }
.editor.fullscreen .editor-body { flex: 1; min-height: 0; }
.editor.fullscreen .editor-input, .editor.fullscreen .editor-preview { height: 100%; min-height: 0; resize: none; }
body.editor-fs { overflow: hidden; }
.mention-menu { position: absolute; inset-inline-start: 12px; bottom: 34px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-md); z-index: 20; min-width: 180px; }
.mention-menu button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; border: 0; background: none; color: var(--text); font: inherit; cursor: pointer; text-align: start; }
.mention-menu button:hover { background: var(--panel-2); }
.mention-menu img { width: 20px; height: 20px; border-radius: 50%; }

/* ---------- auth, profile, settings, search, notifications ---------- */
.auth-box { max-width: 400px; margin: 30px auto; padding: 28px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.auth-box h1 { text-align: center; margin-bottom: 20px; }
.auth-alt { text-align: center; margin: 16px 0 0; color: var(--text-muted); }
.profile-head { display: grid; grid-template-columns: auto 1fr auto; gap: 6px 18px; align-items: start; padding: 20px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; }
.profile-info { min-width: 0; }
.profile-info h1 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 2px; }
.profile-bio { color: var(--text-muted); margin: 4px 0 6px; }
.profile-meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: var(--font-size-sm); color: var(--text-muted); }
.profile-meta span { display: inline-flex; align-items: center; gap: 4px; }
.profile-side { display: flex; gap: 6px; }
.profile-stats { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.pstat { display: inline-flex; align-items: baseline; gap: 6px; padding: 6px 12px; border-radius: var(--radius-sm); background: var(--panel-2); color: var(--text); }
.pstat b { font-size: var(--font-size-lg); }
.pstat span, .pstat small { color: var(--text-muted); font-size: var(--font-size-sm); }
a.pstat:hover { background: var(--brand-soft); color: var(--brand); }
.post-rows { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.post-row { padding: 14px 16px; border-bottom: 1px solid var(--line-soft); }
.post-row:last-child { border: 0; }
.post-excerpt { color: var(--text-muted); font-size: var(--font-size-sm); margin: 4px 0 6px; }
.post-hold { display: flex; align-items: flex-start; gap: 10px; margin-top: 16px; padding: 14px 16px; border: 1px solid var(--warning); border-radius: var(--radius); background: var(--warning-soft); }
.post-hold > .icon { width: 20px; height: 20px; flex: none; color: var(--warning); margin-top: 1px; }
.post-hold b { display: block; font-weight: 600; }
.composer-extra { margin-top: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2); }
.composer-extra > summary { display: flex; align-items: center; gap: 6px; padding: 9px 12px; cursor: pointer; color: var(--text-muted); font-size: var(--font-size-sm); }
.composer-extra > summary .icon { width: 16px; height: 16px; }
.composer-extra[open] > summary { border-bottom: 1px solid var(--line-soft); }
.composer-extra > .form-row, .composer-extra > div { padding: 0 12px; }
.composer-extra > div:last-child, .composer-extra > .form-row:last-child { padding-bottom: 12px; }
.reply-denied { margin-top: 16px; }
.settings { max-width: 880px; margin: 0 auto; }
.settings-grid { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 24px; align-items: start; }
.settings-menu { position: sticky; top: calc(var(--topbar-h) + 20px); }
.settings-menu h4 { margin: 16px 0 4px; padding: 0 10px; }
.settings-menu h4:first-child { margin-top: 4px; }
.settings-menu .side-link { padding: 6px 10px; }
.settings-chev, .settings-back, .settings-current { display: none; }
@media (max-width: 768px) {
  /* phones: /settings is a list of sections (grouped rows with a chevron); a section page shows a back link and the form */
  .settings-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .settings-menu { display: none; position: static; }
  .settings-index .settings-menu { display: block; }
  .settings-index .settings-body, .settings-index h1 + .settings-grid .settings-body { display: none; }
  .settings-index .settings-menu h4 { margin: 18px 0 6px; padding: 0 4px; }
  .settings-index .settings-menu h4:first-child { margin-top: 0; }
  .settings-index .settings-menu .side-link { display: flex; align-items: center; margin: 0; padding: 13px 14px; border: 1px solid var(--line); border-top: 0; border-radius: 0; background: var(--panel); color: var(--text); font-size: var(--font-size-md); }
  .settings-index .settings-menu .side-link.active { background: var(--panel); color: var(--text); }
  .settings-index .settings-menu h4 + .side-link { border-top: 1px solid var(--line); border-start-start-radius: var(--radius); border-start-end-radius: var(--radius); }
  .settings-index .settings-menu .side-link:last-child, .settings-index .settings-menu .side-link:has(+ h4) { border-end-start-radius: var(--radius); border-end-end-radius: var(--radius); }
  .settings-index .settings-chev { display: block; margin-inline-start: auto; width: 16px; height: 16px; color: var(--text-subtle); }
  .settings:not(.settings-index) h1 { display: none; }
  .settings-back { display: inline-flex; align-items: center; gap: 2px; margin-bottom: 6px; color: var(--text-muted); font-size: var(--font-size-sm); }
  .settings-back .icon { width: 16px; height: 16px; }
  .settings-current { display: block; margin: 0 0 12px; }
  .settings-form { max-width: none; }
}
.settings-form { max-width: 560px; padding: 20px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.search-big { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; }
.search-big input { border: 0; padding: 6px 0; font-size: var(--font-size-lg); }
.search-big input:focus { outline: 0; }
.search-results { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.search-result { padding: 14px 16px; border-bottom: 1px solid var(--line-soft); }
.search-result:last-child { border: 0; }
.snippet { color: var(--text-muted); font-size: var(--font-size-sm); margin: 4px 0 6px; }
.notif-list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.notif { display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); color: var(--text); }
.notif:last-child { border: 0; }
.notif:hover { background: var(--panel-2); }
.notif.unread { background: color-mix(in srgb, var(--brand-soft) 50%, var(--panel)); }
.notif-icon { width: 32px; height: 32px; border-radius: 50%; background: var(--panel-2); display: inline-flex; align-items: center; justify-content: center; color: var(--brand); flex: none; }
.notif-body { flex: 1; min-width: 0; }
.notif-title { display: block; }
.notif-excerpt { display: block; color: var(--text-muted); font-size: var(--font-size-sm); }
.notif-time { color: var(--text-subtle); font-size: var(--font-size-sm); white-space: nowrap; }
.error-box { text-align: center; padding: 60px 20px; }
.error-box h1 { font-size: 56px; color: var(--text-disabled); }

/* ---------- points (core ledger UI) ---------- */
.points-balance { margin: 0 0 12px; }
.points-balance b { font-size: var(--font-size-2xl); color: var(--brand); margin-inline-end: 4px; }
.points-log { list-style: none; margin: 0; padding: 0; }
.points-log li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: var(--font-size-sm); }
.points-log li:last-child { border: 0; }
.points-log b { min-width: 36px; text-align: end; }
.points-log b.up { color: var(--success); }
.points-log b.down { color: var(--danger); }
.points-log small { margin-inline-start: auto; color: var(--text-subtle); white-space: nowrap; }
.settings-points { max-width: 640px; }

/* ---------- footer ---------- */
.footer { border-top: 1px solid var(--line); background: var(--panel); margin-top: auto; }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 16px; padding-bottom: 16px; font-size: var(--font-size-sm); color: var(--text-muted); flex-wrap: wrap; }
.footer-inner .region { display: flex; gap: 12px; }
.footer-links { display: flex; gap: 6px 14px; flex-wrap: wrap; }
.footer-links a { color: var(--text-muted); white-space: nowrap; }
.footer-links a:hover { color: var(--brand); }

/* ---------- setup ---------- */
.page-setup { display: block; padding: 30px 16px; }
.setup { max-width: 720px; margin: 0 auto; }
.setup .card { margin-bottom: 16px; }
.setup-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.setup-head h1 { margin: 0; } .setup-head small { color: var(--text-subtle); font-weight: 400; }
.check-list { list-style: none; margin: 0; padding: 0; }
.check-list li { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
.check-list li::before { content: "✓"; color: var(--success); margin-inline-end: 8px; font-weight: 700; }
.check-list li.bad::before { content: "✗"; color: var(--danger); }
.check-list li.warn::before { content: "!"; color: var(--warning); }
.check-list li span { flex: 1; }
.check-list small { color: var(--text-subtle); }

/* ---------- admin ---------- */
.admin-page h1 { display: flex; align-items: center; gap: 10px; }
.admin-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.admin-cards .card-body b { display: block; font-size: var(--font-size-3xl); }
.admin-cards .card-body span { color: var(--text-muted); font-size: var(--font-size-sm); }
.admin-form { padding: 20px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); max-width: 760px; }
.admin-form fieldset { border: 0; padding: 0; margin: 0 0 20px; }
.admin-form legend { font-weight: 650; font-size: var(--font-size-lg); margin-bottom: 10px; padding: 0; }
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
table.admin { width: 100%; border-collapse: collapse; font-size: var(--font-size-sm); }
table.admin th, table.admin td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); text-align: start; vertical-align: middle; }
table.admin th { background: var(--panel-2); font-weight: 600; color: var(--text-muted); }
table.admin tr:last-child td { border: 0; }
table.admin td form { display: inline; }
.admin-toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.admin-toolbar input[type="search"] { max-width: 320px; }
.image-current { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.image-current img { max-height: 48px; max-width: 200px; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 4px; background: var(--panel-2); }
.admin-toolbar form { display: flex; gap: 8px; }
.plugin-item { display: flex; gap: 16px; padding: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; align-items: flex-start; }
.plugin-main { flex: 1; min-width: 0; }
.plugin-main h3 { margin-bottom: 2px; }
.plugin-meta { color: var(--text-subtle); font-size: var(--font-size-xs); display: flex; gap: 10px; flex-wrap: wrap; margin: 4px 0; }
.plugin-ops { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.admin-sub { font-size: var(--font-size-md); margin: 18px 0 2px; }
.admin-sub:first-child { margin-top: 0; }
.chips { display: flex; gap: 10px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: var(--font-size-sm); }
.chip .order { display: inline-flex; margin-inline-start: -2px; }
.chip .order button { border: 0; background: none; padding: 0 1px; cursor: pointer; color: var(--text-subtle); line-height: 1; }
.chip .order button:hover { color: var(--text); }
.chip .order .icon { width: 14px; height: 14px; }
textarea.mono { font-family: var(--mono); font-size: 12px; }


/* ---------- admin: page head, tables, drawer, switch ---------- */
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.admin-head h1 { margin: 0; }
.side-group { padding: 12px 10px 4px; margin: 0; }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 4px; white-space: nowrap; }
.row-menu .dropdown-menu { min-width: 170px; }
.dropdown-menu .danger, .dropdown-menu a.danger { color: var(--danger); }
.dropdown-menu .action-form { margin: 0; }
.switch { position: relative; width: 34px; height: 20px; border: 0; border-radius: 10px; background: var(--text-disabled); cursor: pointer; padding: 0; transition: background .15s; vertical-align: middle; }
.switch span { position: absolute; top: 2px; inset-inline-start: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: inset-inline-start .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch.on { background: var(--success); }
.switch.on span { inset-inline-start: 16px; }
.form-actions.sticky { position: sticky; bottom: 0; margin: 16px -18px -18px; padding: 12px 18px; background: var(--panel); border-top: 1px solid var(--line); }
.admin-full .form-actions.sticky { margin: 16px -20px -20px; padding: 12px 20px; }
.drawer-links { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 18px 0; }
.drawer-links a { padding: 3px 10px; border: 1px solid var(--line); border-radius: var(--radius-pill); font-size: var(--font-size-sm); color: var(--text-muted); }
.drawer-links a.active, .drawer-links a:hover { border-color: var(--brand); color: var(--brand); }
.admin-full .drawer-links { padding: 0 0 12px; }
.adrawer-backdrop { position: fixed; inset: 0; background: var(--backdrop); z-index: 110; }
.adrawer { position: fixed; top: 0; inset-inline-end: 0; bottom: 0; width: 480px; max-width: 100vw; background: var(--panel); border-inline-start: 1px solid var(--line); box-shadow: var(--shadow-md); z-index: 120; display: flex; flex-direction: column; animation: adrawer-in .18s ease-out; }
@keyframes adrawer-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.adrawer-head { display: flex; align-items: flex-start; gap: 6px; padding: 14px 12px 12px 18px; border-bottom: 1px solid var(--line); }
.adrawer-head > div { flex: 1; min-width: 0; }
.adrawer-head b { font-size: var(--font-size-lg); }
.adrawer-body { flex: 1; overflow: auto; padding: 18px; }
.adrawer-body .form-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
body.adrawer-open { overflow: hidden; }
@media (max-width: 640px) { .adrawer { width: 100%; border: 0; } .admin-head { flex-direction: column; align-items: flex-start; } }

/* ---------- responsive ---------- */
@media (max-width: 1200px) {
  .page-grid { grid-template-columns: var(--left-w) minmax(0, 1fr); }
  body.no-left .page-grid { grid-template-columns: minmax(0, 1fr); }
  .col-right { grid-column: 2; }
  body.no-left .col-right { grid-column: 1; }
  .card-stack { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
  .page-topic .card-stack { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
}
@media (max-width: 992px) {
  :root { --gap: 16px; }
  html, body { overflow-x: hidden; }
  .col-main, .col-right { min-width: 0; max-width: 100%; }
  .topic-title, .post-content, .row-meta, .list-head h1 { overflow-wrap: anywhere; }
  .post-content pre { max-width: 100%; }
  .page-grid, body.no-left .page-grid, body.no-right .page-grid { grid-template-columns: minmax(0, 1fr); padding-top: 14px; }
  .cat-bar-mobile { display: flex; }
  .cat-bar { margin: -14px -20px 12px; padding: 0 12px; max-width: none; background: var(--panel); gap: 0; }
  .cat-item { padding: 10px 9px; }
  .col-right, body.no-left .col-right { grid-column: 1; }
  .drawer-toggle { display: inline-flex; }
  .col-left { position: fixed; top: 0; inset-inline-start: 0; bottom: 0; width: 280px; max-width: 85vw; background: var(--panel); border-inline-end: 1px solid var(--line); padding: 16px 12px; overflow-y: auto; z-index: 100; transform: translateX(-100%); visibility: hidden; transition: transform .2s, visibility 0s .2s; }
  body.drawer-open .col-left { transform: none; visibility: visible; transition: transform .2s; }
  [dir="rtl"] .col-left { transform: translateX(100%); }
  [dir="rtl"] body.drawer-open .col-left { transform: none; }
  .drawer-backdrop { position: fixed; inset: 0; background: var(--backdrop); z-index: 90; display: none; }
  body.drawer-open .drawer-backdrop { display: block; }
  .topnav { display: none; }
  .drawer-nav { display: block; }
  .search-form { width: 160px; }
  .category-row { grid-template-columns: 1fr; gap: 6px; }
  .cat-last { display: none; }
  .cat-stats { flex-direction: row; gap: 12px; }
}
@media (max-width: 640px) {
  .container { padding: 0 12px; }
  .search-form { display: none; }
  .search-toggle { display: inline-flex; }
  .logo-text { display: none; }
  .topbar-right .btn { padding: 6px 10px; }
  :root { --gap: 12px; }
  .page-grid { padding-top: 12px; }
  .list-head { margin-bottom: 8px; gap: 8px; }
  .cat-bar { margin: -12px -12px 10px; padding: 0 6px; }
  .list-head > .btn-primary { display: none; }
  .tabs { padding: 3px; }
  .tab { padding: 4px 9px; font-size: var(--font-size-sm); }
  .topic-rows { margin: 0 -12px; border-inline: 0; border-radius: 0; }
  .topic-row { gap: 8px; padding: 10px; }
  .row-avatar .avatar { width: 32px; height: 32px; font-size: 14px; }
  .row-title { font-size: 15px; margin-bottom: 5px; }
  .row-meta { gap: 8px; font-size: var(--font-size-xs); }
  .row-cat, .row-meta .row-tag { display: none; }
  .row-meta .meta.meta-cat { display: inline-flex; color: var(--text-muted); }
  .card-body { padding: 12px 14px; }
  .card-head { padding: 10px 14px; }
  .me-stats > * { padding: 6px 4px; }
  .me-stats b { font-size: var(--font-size-md); }
  .card-stack { gap: 10px; }
  .post-stream { gap: 8px; }
  .composer { padding: 12px; margin-top: 14px; }
  .topic-head { margin-bottom: 10px; }
  .topic-title { font-size: var(--font-size-2xl); }
  .post { padding: 12px; }
  .post-head { margin-bottom: 10px; }
  .post-avatar .avatar { width: 36px; height: 36px; font-size: 15px; }
  .act span, .tb-preview span { display: none; }
  .act[data-like] span { display: inline; }
  .profile-head { grid-template-columns: auto 1fr; gap: 4px 12px; padding: 14px; }
  .profile-head .avatar { width: 56px; height: 56px; font-size: 22px; }
  .profile-side { grid-column: 1 / -1; flex-wrap: wrap; margin-top: 6px; }
  .profile-meta { gap: 6px 12px; }
  .profile-meta span { white-space: nowrap; }
  /* phones: the links first as a centred wrapped row, the copyright and "powered by" as one centred line below */
  .footer-inner { justify-content: center; text-align: center; gap: 8px 14px; padding-top: 14px; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .footer-links { order: -1; flex-basis: 100%; justify-content: center; gap: 6px 18px; margin-bottom: 4px; }
  .footer-inner .region { justify-content: center; flex-wrap: wrap; gap: 4px 12px; }
  .me-stats span { font-size: 10px; }
}

/* right-to-left languages (lang pack __dir => rtl): mirror the icons that point somewhere */
[dir="rtl"] .icon-reply, [dir="rtl"] .icon-arrow-left, [dir="rtl"] .icon-chevron-left, [dir="rtl"] .icon-chevron-right, [dir="rtl"] .icon-logout { transform: scaleX(-1); }

.video-container {
  position: relative;
  width: 100%;
  height: 0;
  padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
  margin: 1rem 0;
}

.video-container iframe,
.video-container video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 0.375rem;
}