/* ============================================================
   XenBB default theme — lightweight, content first.
   Blocks are separated by gaps so the page background stays visible.
   No external fonts, no frameworks: every request is one CSS file.
   ============================================================ */

/* The palette is warm: the background of the page is a soft paper beige,
   the text is a warm near-black and the links are a muted terracotta.
   The blue of the usual link colour is tiring for the eyes — the reader
   stays on the forum for hours, so the colours are chosen for a long read:
   a low glare background, a calm contrast of the text and one warm accent
   for the links and the buttons. The dark theme is the same idea: warm
   charcoal instead of cold blue-black. */
:root {
    --bg: #f4f1eb;
    --bg-soft: #eae6dd;
    --card: #fffdf9;
    --card-alt: #f8f5ef;
    --text: #23201a;
    --muted: #6c665b;
    --border: #e3ddd1;
    --border-strong: #cec6b7;
    --accent: #9c4a21;
    --accent-dark: #7c3917;
    --accent-soft: #f4e6da;
    --on-accent: #ffffff;
    --vote: #b8560f;
    --danger: #c0392b;
    --success: #1e7d4b;
    --warn: #a86a00;
    --header: #fffdf9;
    --header-2: #f7f3ec;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(46, 36, 24, .05);
    --shadow-lg: 0 12px 32px rgba(46, 36, 24, .16);
    --gap: 18px;
    --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

[data-theme="dark"] {
    --bg: #16130f;
    --bg-soft: #1e1a15;
    --card: #211d18;
    --card-alt: #2a251e;
    --text: #ece5d8;
    --muted: #a89c88;
    --border: #342e26;
    --border-strong: #4a4237;
    --accent: #e08a52;
    --accent-dark: #eda070;
    --accent-soft: #3a2c1f;
    --on-accent: #241608;
    --vote: #f0904f;
    --danger: #e0655a;
    --success: #57b184;
    --warn: #d9a441;
    --header: #1b1712;
    --header-2: #221d17;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15.5px;
    line-height: 1.58;
    display: flex;
    min-height: 100vh;
    flex-direction: column;
}

a { color: #14110deb; text-decoration: none; }
a:hover { color: var(--accent-dark); }
img { max-width: 100%; height: auto; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .4em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
code, pre { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }

.container { width: 100%; max-width: 1440px; margin: 0 auto; padding: 0 20px; }
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
    position: absolute; left: -999px; top: 0; background: var(--card); color: var(--text);
    padding: 8px 14px; z-index: 60; border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; margin-top: 2px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mt { margin-top: 10px; }
.i { width: 16px; height: 16px; flex: 0 0 auto; }
svg.i use { pointer-events: none; }
/* The icon sprite is hidden by a class and not by an inline style: the strict
   Content-Security-Policy blocks inline styles, and a visible sprite would
   push the header 150 pixels down. */
.icon-sprite { display: none; }
/* The attribute `hidden` must win over any display rule of the theme. */
[hidden] { display: none !important; }
.hidden { display: none !important; }

/* ---------- Header ---------- */
.site-header {
    background: var(--card);
    color: var(--text);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 0 rgba(16, 24, 40, .02);
    position: sticky; top: 0; z-index: 40;
}
.header-inner { display: flex; align-items: center; gap: 16px; height: 60px; }
/* Anchors of the messages never hide behind the sticky header. */
.post, #comments, .comments-head { scroll-margin-top: 74px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 800; font-size: 1.16rem; }
.brand:hover { color: var(--accent); }
.brand-mark {
    width: 34px; height: 34px; border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    display: grid; place-items: center; font-weight: 800; color: var(--on-accent);
}
.main-nav { display: flex; gap: 3px; margin-left: 8px; flex: 1 1 auto; min-width: 0; align-items: center; }
.main-nav a {
    color: var(--muted); padding: 8px 12px; border-radius: var(--radius-sm); font-weight: 650; font-size: .92rem;
    white-space: nowrap;
}
.main-nav a:hover { background: var(--accent-soft); color: var(--accent); }
.main-nav a.is-active { background: var(--accent-soft); color: var(--accent); }
.header-search {
    position: relative; margin-left: auto; display: flex; align-items: center;
    background: var(--bg-soft); border: 1px solid transparent; border-radius: 20px;
    padding: 0 12px; height: 38px; min-width: 230px;
    transition: border-color .15s, background .15s;
}
.header-search:focus-within { border-color: var(--accent); background: var(--card); }
.header-search .i { color: var(--muted); }
.header-search input {
    border: 0; background: transparent; color: var(--text); font-size: .92rem; padding: 0 8px; width: 100%; outline: none;
}
.header-search input::placeholder { color: var(--muted); }
.suggest {
    position: absolute; top: 46px; left: 0; right: 0; background: var(--card); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
    padding: 6px; z-index: 50;
}
.suggest a { display: block; padding: 7px 10px; border-radius: var(--radius-sm); color: var(--text); font-size: .9rem; }
.suggest a:hover { background: var(--accent-soft); }
.user-area { display: flex; align-items: center; gap: 8px; }
.header-create {
    display: inline-flex; align-items: center; gap: 6px; padding: 8px 13px; border-radius: 20px;
    background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: .88rem; white-space: nowrap;
}
.header-create:hover { background: var(--accent-dark); color: var(--on-accent); }
.header-create .i { width: 15px; height: 15px; }
.user-button {
    display: flex; align-items: center; gap: 8px; background: var(--bg-soft);
    border: 1px solid transparent; color: var(--text); padding: 4px 10px 4px 4px; border-radius: 20px; cursor: pointer; font: inherit;
}
.user-button:hover { border-color: var(--border-strong); }
.user-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.dropdown { position: relative; }
.dropdown-menu {
    position: absolute; right: 0; top: 46px; min-width: 190px; background: var(--card);
    border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
    padding: 6px; display: flex; flex-direction: column; z-index: 50;
    /* The menu of a long profile (points, gifts, awards, the admin panel) must
       scroll instead of running off the bottom of the screen. */
    max-height: calc(100vh - 70px); overflow-y: auto;
    -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
}
.dropdown-menu a, .dropdown-menu button { flex: 0 0 auto; }
.dropdown-menu a, .dropdown-menu button {
    text-align: left; padding: 9px 12px; border-radius: var(--radius-sm); color: var(--text);
    background: none; border: 0; font: inherit; cursor: pointer; width: 100%;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--accent-soft); }
/* The main action of the menu is highlighted. */
.dropdown-menu a.dropdown-primary { font-weight: 700; color: var(--accent); }
.dropdown-menu a.dropdown-primary:hover { background: var(--accent-soft); }

/* ---------- The bell of the notifications ----------
   The menu is a native <details>: it opens and closes without JavaScript
   and never asks the server for anything. */
.notif { position: relative; }
.notif-toggle {
    position: relative; display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 50%; cursor: pointer; color: var(--text);
    list-style: none; background: var(--bg-soft);
}
.notif-toggle::-webkit-details-marker { display: none; }
.notif-toggle::marker { content: ""; }
.notif-toggle:hover, .notif[open] .notif-toggle { background: var(--accent-soft); color: var(--accent); }
.notif-badge {
    position: absolute; top: -3px; right: -3px; min-width: 18px; height: 18px; padding: 0 4px;
    border-radius: 9px; background: var(--danger); color: #fff; font-size: .68rem; font-weight: 700;
    line-height: 18px; text-align: center;
}
.header-messages {
    position: relative; display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 50%; color: var(--text); background: var(--bg-soft);
}
.header-messages:hover { background: var(--accent-soft); color: var(--accent); }
.notif-panel {
    position: absolute; right: 0; top: 38px; width: 320px; max-width: calc(100vw - 32px);
    background: var(--card); color: var(--text); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 10px; z-index: 50;
}
.notif-head { display: flex; align-items: center; gap: 8px; padding: 2px 4px 8px; border-bottom: 1px solid var(--border); }
.notif-empty { padding: 10px 4px; }
.notif-list { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow-y: auto; }
.notif-list li + li { border-top: 1px solid var(--border); }
.notif-item a, .notif-page-item a {
    display: block; padding: 8px 4px; color: var(--text); font-size: .86rem; line-height: 1.4;
}
.notif-item a:hover, .notif-page-item a:hover { background: var(--accent-soft); border-radius: var(--radius-sm); }
.notif-item.is-new a, .notif-page-item.is-new a { font-weight: 600; }
.notif-kind { display: block; font-size: .72rem; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
.notif-text { display: block; }
.notif-time { display: block; font-size: .74rem; color: var(--muted); margin-top: 2px; }
.notif-actions {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding-top: 8px; margin-top: 6px; border-top: 1px solid var(--border);
}
.notif-actions form { margin: 0; }
.notif-page-list { list-style: none; margin: 0; padding: 0; }
.notif-page-item + .notif-page-item { border-top: 1px solid var(--border); }
.notif-page-item a { padding: 11px 4px; }
.icon-button { background: none; border: 0; color: var(--text); cursor: pointer; padding: 6px; display: none; }
.nav-toggle { display: none; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
    font-weight: 600; font-size: .92rem; cursor: pointer; font-family: inherit; line-height: 1.2;
    transition: background .15s, border-color .15s, color .15s;
}
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-dark); color: var(--on-accent); }
.btn-ghost { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover { background: var(--card-alt); }
.site-header .btn-ghost { color: var(--text); border-color: var(--border-strong); }
.site-header .btn-ghost:hover { background: var(--accent-soft); color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a5301f; color: #fff; }
.btn-sm { padding: 6px 11px; font-size: .85rem; }
.btn-block { width: 100%; }
.link-button { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; text-align: left; }
.link-button:hover { color: var(--accent-dark); text-decoration: underline; }

/* ---------- Layout ---------- */
.layout { flex: 1 0 auto; padding: 20px 0 40px; }
.layout-inner { display: grid; gap: 22px; align-items: start; }
.layout.with-sidebar .layout-inner { grid-template-columns: minmax(0, 1fr) 320px; }
.content > * + * { margin-top: var(--gap); }
/* A grid child must be allowed to shrink: the tab strip and the long titles
   never stretch the page on a narrow screen. */
.content { min-width: 0; }
.sidebar > * + * { margin-top: var(--gap); }

/* ---------- Cards / blocks ---------- */
.card {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 18px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-head-actions form { margin: 0; }
.flashes { margin: 12px auto 0; display: flex; flex-direction: column; gap: 8px; }
.flash { padding: 11px 14px; border-radius: var(--radius-sm); border: 1px solid transparent; font-size: .92rem; }
.flash ul { margin: 0; padding-left: 18px; }
.flash-success { background: #e9f4ec; border-color: #c2e0cc; color: #1b6b44; }
.flash-error { background: #fbeae7; border-color: #f0c4bc; color: #8f2418; }
.flash-info { background: var(--accent-soft); border-color: #e3cdb9; color: var(--accent-dark); }
[data-theme="dark"] .flash-success { background: #16311f; border-color: #245c39; color: #8fe0b0; }
[data-theme="dark"] .flash-error { background: #341a18; border-color: #6b2a24; color: #f3a79c; }
.flash ul { padding-left: 20px; }

/* ---------- Breadcrumbs ---------- */
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 4px; padding: 0; font-size: .85rem; }
.breadcrumbs li + li::before { content: "›"; margin-right: 6px; color: var(--muted); }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--accent); }

/* ---------- Hero ---------- */
.hero {
    background: linear-gradient(135deg, var(--accent-soft), var(--card) 65%);
    color: var(--text); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 24px 26px; box-shadow: var(--shadow);
    display: flex; flex-wrap: wrap; gap: 22px; align-items: center; justify-content: space-between;
}
.hero h1 { color: var(--text); margin-bottom: 4px; font-size: 1.65rem; }
.hero p { margin: 0; color: var(--muted); max-width: 620px; }
.hero-stats { list-style: none; display: flex; gap: 24px; margin: 0; padding: 0; flex-wrap: wrap; }
.hero-stats li { text-align: center; }
.hero-stats strong { display: block; font-size: 1.35rem; color: var(--text); }
.hero-stats span { font-size: .8rem; color: var(--muted); }
.hero-stats .newest { display: flex; align-items: center; gap: 8px; text-align: left; }
.hero-stats .newest strong { font-size: .95rem; }

/* ---------- Forums ---------- */
.category { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.category + .category { margin-top: var(--gap); }
.category-head { padding: 13px 18px; background: var(--card-alt); border-bottom: 1px solid var(--border); }
.category-head h2 { margin: 0; font-size: 1.05rem; }
.category-head h2 a { color: inherit; }
.category-head h2 a:hover { color: var(--accent); }
.category-head p { margin: 3px 0 0; color: var(--muted); font-size: .86rem; }
.forum-list { list-style: none; margin: 0; padding: 0; }
.forum-node { display: grid; grid-template-columns: 44px minmax(0, 1fr) 150px 230px; gap: 14px; align-items: center; padding: 14px 18px; }
.forum-node + .forum-node { border-top: 1px solid var(--border); }
.forum-node:hover { background: var(--card-alt); }
.forum-node.is-closed .forum-title { opacity: .65; }
.forum-icon {
    width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center;
    background: var(--accent-soft); color: var(--accent); border: 1px solid var(--border);
}
.forum-icon .i { width: 20px; height: 20px; }
.forum-title { font-weight: 700; font-size: 1.02rem; display: block; }
.forum-desc { margin: 2px 0 0; color: var(--muted); font-size: .87rem; }
.forum-counts { display: flex; gap: 14px; font-size: .84rem; color: var(--muted); }
.forum-counts strong { color: var(--text); }
.forum-last { font-size: .84rem; }
.forum-last-title { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.forum-last-meta { display: flex; align-items: center; gap: 7px; color: var(--muted); margin-top: 4px; }

/* ---------- Topic lists ---------- */
.topic-list { list-style: none; margin: 0; padding: 0; }
.topic-row {
    display: grid; grid-template-columns: 44px minmax(0, 1fr) 110px 160px;
    gap: 12px; align-items: center; padding: 12px 4px;
}
.topic-row + .topic-row { border-top: 1px solid var(--border); }
.topic-row:hover { background: var(--card-alt); }
.topic-row.is-pinned { background: linear-gradient(90deg, var(--accent-soft), transparent 55%); }
.topic-title { font-weight: 650; font-size: .99rem; display: inline-flex; align-items: center; gap: 6px; }
.i-pin { color: var(--accent); }
.i-lock { color: var(--muted); }
.topic-meta { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; color: var(--muted); font-size: .82rem; margin-top: 2px; }
.topic-stats { display: flex; gap: 12px; color: var(--muted); font-size: .84rem; }
.topic-stats .stat { display: inline-flex; align-items: center; gap: 4px; }
.topic-last { text-align: right; font-size: .82rem; color: var(--muted); }
.topic-last-user { display: block; color: var(--text); font-weight: 600; }
.pagination { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 14px; }.page-link {
    min-width: 34px; height: 34px; padding: 0 10px; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card); color: var(--text); font-size: .88rem;
}
.page-link:hover { border-color: var(--accent); color: var(--accent); }
.page-link.is-current { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 700; }
.page-gap { color: var(--muted); }

/* ---------- Blog ---------- */
.blog-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--gap); list-style: none; margin: 0; padding: 0;
}
/* One column or two columns — the mode is chosen in the admin panel. */
.blog-grid.cols-1 { grid-template-columns: 1fr; }
.blog-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.blog-card {
    display: flex; flex-direction: column; background: var(--card);
    border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); overflow: hidden;
}
/* The title is the first element of the card, then the picture or the video,
   then the description. */
.blog-title { font-size: 1rem; font-weight: 700; line-height: 1.3; margin: 0; padding: 14px 16px 0; }
.blog-title a { color: inherit; }
.blog-title a:hover { color: var(--accent); }
/* One column: the picture or the video is on top and in the centre of the
   card, the title and the description are below it, from the left. */
.blog-grid.cols-1 .blog-card { flex-direction: column; align-items: stretch; }
.blog-grid.cols-1 .blog-title { padding: 18px 20px 0; font-size: 1.15rem; }
.blog-grid.cols-1 .blog-media { display: flex; justify-content: center; align-items: center; background: var(--card-alt); margin-top: 12px; }
.blog-grid.cols-1 .blog-media img { width: auto; max-width: 100%; height: auto; max-height: 460px; object-fit: contain; margin: 0 auto; }
.blog-grid.cols-1 .blog-body { padding: 14px 20px 18px; }
.blog-media { display: block; background: var(--card-alt); border-bottom: 1px solid var(--border); line-height: 0; margin-top: 10px; }
.blog-media img { display: block; width: 100%; height: 190px; object-fit: cover; }
/* The video keeps its proportions and stands in the centre of the card. */
.blog-embed-wrap { width: 100%; max-width: 760px; margin: 10px auto 0; }
.blog-embed { position: relative; width: 100%; padding-top: 56.25%; background: #14110d; }
.blog-embed iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0; }
.blog-body { display: flex; flex-direction: column; gap: 8px; padding: 12px 16px 16px; flex: 1; }
.blog-excerpt { font-size: .88rem; color: var(--muted); }
.blog-meta {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
    color: var(--muted); font-size: .8rem; margin-top: auto; padding-top: 9px;
    border-top: 1px solid var(--border);
}
.blog-meta .stat { display: inline-flex; align-items: center; gap: 4px; }
.blog-group { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }

/* ---------- Groups ---------- */
.groups-tabs { padding: 0; overflow: hidden; }
.groups-tabs .tabs { border-radius: var(--radius); }
/* The icon of the group: it stands on the left, the name and the description
   are on the right — as in the other social networks. */
.group-icon {
    flex: none; display: block; width: 100px; height: 100px;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--card-alt); overflow: hidden;
}
.group-icon img { display: block; width: 100%; height: 100%; object-fit: cover; }
.group-icon-sm { width: 72px; height: 72px; }
.group-head { display: flex; gap: 18px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.group-head-main { min-width: 0; flex: 1 1 320px; }
.group-head-info { display: flex; gap: 16px; align-items: flex-start; }
.group-head-text { min-width: 0; flex: 1 1 auto; }
.group-head-main h1 { margin-bottom: 4px; }
.group-desc { color: var(--muted); margin: 0 0 8px; }
.group-meta { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; color: var(--muted); font-size: .86rem; margin: 6px 0; }
.group-meta > span { display: inline-flex; align-items: center; gap: 5px; }
.group-head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
/* The card of the group: the icon is on the left, the text is on the right. */
.blog-grid .group-card,
.blog-grid.cols-1 .group-card,
.blog-grid.cols-2 .group-card {
    flex-direction: row; align-items: flex-start; gap: 12px; padding: 14px 16px;
}
.group-card-main { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.blog-grid .group-card .blog-title,
.blog-grid.cols-1 .group-card .blog-title { padding: 0; }
.blog-grid .group-card .blog-body,
.blog-grid.cols-1 .group-card .blog-body { padding: 8px 0 0; }
.group-icon-field { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.group-icon-field .field-label { margin-bottom: 0; }
/* The avatar of the author of a blog stands next to the name of the blog. */
.blog-owner-avatar { flex: none; display: block; line-height: 0; }
.blog-owner-avatar-lg { padding-top: 2px; }
.group-rules-text { white-space: pre-line; color: var(--muted); }
.members-grid {
    list-style: none; margin: 0; padding: 0;
    display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px;
}
.member { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.member > a { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-weight: 600; font-size: .88rem; min-width: 0; }
.member-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-role { flex: 1 0 100%; }
.member-role .link-button { font-size: .76rem; color: var(--muted); }
.member-role .link-button:hover { color: var(--accent); }

/* ---------- Rewards ---------- */
.user-points {
    display: inline-flex; align-items: center; gap: 3px; font-size: .8rem; font-weight: 700;
    background: rgba(255, 255, 255, .16); padding: 2px 8px; border-radius: 20px;
}
.user-points .i { width: 13px; height: 13px; }
.rank-badge {
    display: inline-flex; align-items: center; gap: 5px; margin-top: 6px; padding: 2px 10px;
    border-radius: 20px; font-size: .74rem; font-weight: 700;
    background: var(--accent-soft); color: var(--accent-dark);
}
.rank-list, .leader-list, .points-history { list-style: none; margin: 0; padding: 0; }
.rank { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.rank:last-child, .leader:last-child, .points-history li:last-child { border-bottom: 0; }
.rank-badge, .rank-title { font-weight: 700; }
.rank .badge { margin-left: auto; }
.leader { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.leader-place {
    width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-dark);
    display: grid; place-items: center; font-weight: 800; font-size: .8rem; flex: 0 0 auto;
}
.leader-name { font-weight: 700; }
.leader-points { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; color: var(--accent); }
.points-history li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: .88rem; }
.points-history time { margin-left: auto; color: var(--muted); font-size: .78rem; }
.points-value { font-weight: 700; color: var(--success); }
.points-value.is-minus { color: var(--danger); }
.reward-grid {
    list-style: none; margin: 0; padding: 0;
    display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px;
}
.reward {
    display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
    padding: 12px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card-alt);
}
.reward-image { width: var(--reward-icon, 44px); height: var(--reward-icon, 44px); object-fit: contain; }
.reward-emoji { font-size: 1.7rem; line-height: 1.2; }
.reward-title { font-weight: 700; font-size: .9rem; }

/* A profile may have dozens of awards: the block stays one row and scrolls
   horizontally, so the page never grows into an endless wall of icons. */
.reward-strip {
    display: flex;
    flex-wrap: nowrap;
    gap: 12px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    padding: 2px 2px 10px;
    scrollbar-width: thin;
}
.reward-strip > .reward {
    flex: 0 0 auto;
    width: calc(var(--reward-icon, 44px) + 96px);
    max-width: 190px;
    scroll-snap-align: start;
}
.reward-strip::-webkit-scrollbar { height: 8px; }
.reward-strip::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }

/* The subscription to a topic: the bell after the favourite button. */
.follow-button.is-active { color: var(--accent); background: var(--accent-soft); }
.follow-button.is-active svg { fill: currentColor; }

/* The compact tags of a topic: one icon, the list opens on hover or focus.
   Nothing is loaded and no script runs — the popover is pure CSS. */
.tag-pop {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    cursor: help;
    border-radius: 6px;
}
.tag-pop:hover, .tag-pop:focus-within { color: var(--accent); }
.tag-pop:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* The two classes keep the popover hidden even inside .topic-head-meta,
   whose own `span { display:inline-flex }` rule would otherwise win. */
.tag-pop .tag-pop-list {
    position: absolute;
    z-index: 30;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translateX(-50%);
    display: none;
    flex-direction: column;
    gap: 2px;
    min-width: 130px;
    max-width: 240px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card);
    box-shadow: 0 10px 28px rgba(0, 0, 0, .14);
    text-align: left;
    white-space: nowrap;
}
.tag-pop-list a {
    display: block;
    padding: 3px 4px;
    border-radius: 5px;
    color: var(--text);
    font-size: .82rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tag-pop-list a:hover { background: var(--accent-soft); color: var(--accent-dark); }
.tag-pop:hover .tag-pop-list,
.tag-pop:focus-within .tag-pop-list { display: flex; }
.topic-head-meta .tag-pop { margin-left: 4px; }
/* The bell sits in the same meta row and keeps the size of the other icons. */
.topic-head-meta form.inline-form { display: inline-flex; align-items: center; margin: 0; line-height: 1; }
.topic-head-meta .follow-button {
    padding: 0; border: 0; background: none; line-height: 1;
    color: var(--muted); cursor: pointer;
}
.topic-head-meta .follow-button .i { width: 16px; height: 16px; }
.topic-head-meta .follow-button:hover,
.topic-head-meta .follow-button.is-active { color: var(--accent); background: none; }
.tag-catalog { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 0; }
.tags-search { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.tags-search input {
    flex: 1 1 240px; min-width: 180px; padding: 9px 12px;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    background: var(--card); color: var(--text); font: inherit;
}
.tags-search input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.tag-item { display: inline-flex; align-items: center; gap: 4px; }
.tag-chip {
    display: inline-flex; align-items: baseline; gap: 6px;
    padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px;
    background: var(--card-alt); font-weight: 600;
}
.tag-chip:hover { border-color: var(--accent); color: var(--accent-dark); }
.tag-chip .muted { font-weight: 400; font-size: .78rem; }
.tag-hero { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }

/* The little preview of the loaded icon (the admin panel). */
.icon-preview {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; padding: 2px; flex: 0 0 auto;
    border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card);
}
.icon-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* ---------- The shop of the gifts ---------- */
/* The size of the icon and of the card is set by the administrator: the
   values come to the page as the CSS variables --gift-icon and --gift-card. */
.gift-grid {
    grid-template-columns: repeat(auto-fill, minmax(var(--gift-card, 150px), 1fr));
    gap: 16px;
}
.gift-grid .reward {
    align-items: center;
    text-align: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 18px 14px;
    border-radius: var(--radius);
    background: var(--card);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
    transition: transform .15s ease, box-shadow .15s ease;
}
.gift-grid .reward:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0, 0, 0, .08); }
.gift-grid .reward-image {
    width: var(--gift-icon, 96px);
    height: var(--gift-icon, 96px);
    object-fit: contain;
    margin: 0 auto;
}
.gift-grid .reward-emoji {
    font-size: calc(var(--gift-icon, 96px) * .5);
    line-height: 1.15;
    text-align: center;
    min-height: calc(var(--gift-icon, 96px) * .55);
    display: flex;
    align-items: center;
    justify-content: center;
}
.gift-grid .reward-title { font-size: .95rem; text-align: center; }
.gift-grid .reward .badge { align-self: center; }

/* The gifts in the profile of the participant. */
.gift-list .reward-image { width: var(--gift-icon, 96px); height: var(--gift-icon, 96px); }
.gift-list .reward-emoji { font-size: calc(var(--gift-icon, 96px) * .45); }

/* ---------- Profile actions ---------- */
.profile-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.profile-actions form { margin: 0; }

/* ---------- The picker of the section (the form of a new topic) ---------- */
.forum-picker { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card-alt); padding: 12px; }
.forum-picker-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.forum-picker-head input[type="search"] {
    flex: 1 1 220px; min-width: 0; padding: 8px 12px; border: 1px solid var(--border-strong);
    border-radius: 20px; background: var(--card); color: var(--text); font: inherit; font-size: .92rem;
}
.forum-picker-hint { color: var(--muted); font-size: .82rem; }
.forum-picker-body { display: grid; grid-template-columns: minmax(160px, 240px) 1fr; gap: 12px; align-items: start; }
.forum-picker-cats, .forum-picker-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 320px; overflow: auto; }
.forum-picker-cats button, .forum-picker-item {
    display: block; width: 100%; text-align: left; background: var(--card); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 11px;
    cursor: pointer; font: inherit; font-size: .9rem;
}
.forum-picker-cats button:hover, .forum-picker-item:hover { border-color: var(--accent); color: var(--accent-dark); }
.forum-picker-cats button.is-active, .forum-picker-item.is-active {
    background: var(--accent-soft); border-color: var(--accent); color: var(--accent-dark); font-weight: 700;
}
.forum-picker-current { margin: 10px 0 0; font-size: .88rem; color: var(--muted); }
@media (max-width: 640px) {
    .forum-picker-body { grid-template-columns: 1fr; }
}

/* ---------- The feed of the home page ----------
   A compact Reddit/Pikabu-style stream: the rating on the left, the text in
   the centre, the picture on the right. One card — one cached query row. */
.feed-head {
    display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
    flex-wrap: wrap; padding: 2px 2px 0;
}
.feed-head h1 { font-size: 1.55rem; margin: 2px 0 4px; }
.feed-head .muted { margin: 0; max-width: 760px; }
.feed-kicker {
    display: inline-flex; align-items: center; gap: 6px; margin: 0; color: var(--accent);
    font-size: .76rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
}
.feed-kicker .i { width: 14px; height: 14px; }
.feed-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.feed-topbar {
    position: sticky; top: 60px; z-index: 30;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 7px; background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.feed-tabs { display: flex; gap: 3px; overflow-x: auto; scrollbar-width: none; flex: 1 1 auto; min-width: 0; }
.feed-tabs::-webkit-scrollbar { display: none; }
.feed-tab {
    display: inline-flex; align-items: center; gap: 6px; padding: 8px 13px; border-radius: 20px;
    color: var(--muted); font-weight: 650; font-size: .9rem; white-space: nowrap;
    transition: background .15s, color .15s;
}
.feed-tab:hover { background: var(--bg-soft); color: var(--text); }
.feed-tab.is-active { background: var(--accent); color: var(--on-accent); }
.feed-tab.is-active:hover { color: var(--on-accent); }
.feed-tab .i { width: 15px; height: 15px; }
.feed-topbar-side { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.feed-total { color: var(--muted); font-size: .8rem; white-space: nowrap; }

.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--bg-soft); border-radius: 20px; }
.seg {
    padding: 5px 11px; border-radius: 16px; color: var(--muted);
    font-size: .8rem; font-weight: 650; white-space: nowrap;
}
.seg:hover { color: var(--text); }
.seg.is-active { background: var(--card); color: var(--accent); box-shadow: var(--shadow); }

.feed-list { display: flex; flex-direction: column; gap: 10px; }
.feed-item {
    display: grid; grid-template-columns: 64px minmax(0, 1fr);
    gap: 14px; align-items: stretch; padding: 14px 16px;
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    transition: border-color .15s;
}
.feed-item:hover { border-color: var(--border-strong); }
.feed-item.no-media { grid-template-columns: 64px minmax(0, 1fr); }
.feed-vote {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    border-right: 1px solid var(--border); padding-right: 14px; color: var(--vote);
}
.feed-vote .i { width: 18px; height: 18px; }
.feed-vote strong { font-size: 1.05rem; color: var(--text); line-height: 1.2; }
.feed-vote span { font-size: .64rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.feed-main { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.feed-top { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-size: .78rem; color: var(--muted); }
.feed-community {
    max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    padding: 2px 9px; border-radius: 999px; background: var(--accent-soft);
    color: var(--accent); font-size: .76rem; font-weight: 750;
}
.feed-updated { display: inline-flex; align-items: center; gap: 4px; }
.feed-updated .i { width: 13px; height: 13px; }
.feed-title { margin: 0; font-size: 1.18rem; line-height: 1.3; font-weight: 700; overflow-wrap: anywhere; }
.feed-title a { color: var(--text); }
.feed-title a:hover { color: var(--accent); }
/* The picture and the video are under the title and centred in the card —
   the same order as on Pikaby and Reddit. */
.feed-media {
    width: 100%; max-width: 720px; margin: 2px auto 0;
    border-radius: var(--radius-sm); overflow: hidden; background: var(--bg-soft);
}
.feed-media img { display: block; width: auto; height: auto; margin: 0 auto; }
.feed-media a { display: block; }
.feed-media .bb-media { margin: 0; border-radius: var(--radius-sm); }
.feed-media .bb-media-blocked { display: block; padding: 14px; font-size: .85rem; }

/* The slider of the pictures of a card. It is built with the radio inputs:
   the arrows and the dots are <label> elements, so it needs no JavaScript
   and the whole page can stay in the guest cache. */
.media-slider { position: relative; }
.media-slider .media-slide-radio {
    position: absolute; width: 1px; height: 1px; opacity: 0;
    pointer-events: none; margin: 0;
}
.media-slider .media-slides { position: relative; }
.media-slider .media-slide { display: none; position: relative; }
.media-slider .media-slide-link { display: block; line-height: 0; }
.media-slider img { display: block; max-width: 100%; height: auto; margin: 0 auto; }
.media-slider .media-arrow {
    position: absolute; top: 50%; z-index: 2;
    display: flex; align-items: center; justify-content: center;
    width: 34px; height: 46px; margin-top: -23px;
    border-radius: 8px; cursor: pointer; user-select: none;
    background: rgba(9, 14, 22, .5); color: #fff;
    font-size: 1.7rem; line-height: 1; opacity: .72;
    transition: opacity .15s ease, background .15s ease;
}
.media-slider .media-arrow:hover,
.media-slider .media-arrow:focus-visible { opacity: 1; background: rgba(9, 14, 22, .75); }
.media-slider .media-arrow-prev { left: 8px; }
.media-slider .media-arrow-next { right: 8px; }
.media-slider .media-dots {
    position: absolute; left: 0; right: 0; bottom: 8px; z-index: 2;
    display: flex; justify-content: center; gap: 6px;
}
.media-slider .media-dot {
    width: 8px; height: 8px; border-radius: 50%; cursor: pointer;
    background: rgba(255, 255, 255, .5);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .25);
}
.media-slider-feed {
    width: 100%; max-width: 720px; margin: 2px auto 0;
    border-radius: var(--radius-sm); overflow: hidden; background: var(--bg-soft);
}
.media-slider-blog { margin-top: 10px; background: var(--card-alt); }
.media-slider-blog .media-slide-link { background: var(--card-alt); border-bottom: 1px solid var(--border); }
.media-slider-blog img { width: 100%; height: 190px; object-fit: cover; }
.media-slider .media-slide-radio:nth-of-type(1):checked ~ .media-slides .media-slide:nth-child(1),
.media-slider .media-slide-radio:nth-of-type(2):checked ~ .media-slides .media-slide:nth-child(2),
.media-slider .media-slide-radio:nth-of-type(3):checked ~ .media-slides .media-slide:nth-child(3),
.media-slider .media-slide-radio:nth-of-type(4):checked ~ .media-slides .media-slide:nth-child(4),
.media-slider .media-slide-radio:nth-of-type(5):checked ~ .media-slides .media-slide:nth-child(5) { display: block; }
.media-slider .media-slide-radio:nth-of-type(1):checked ~ .media-dots .media-dot:nth-child(1),
.media-slider .media-slide-radio:nth-of-type(2):checked ~ .media-dots .media-dot:nth-child(2),
.media-slider .media-slide-radio:nth-of-type(3):checked ~ .media-dots .media-dot:nth-child(3),
.media-slider .media-slide-radio:nth-of-type(4):checked ~ .media-dots .media-dot:nth-child(4),
.media-slider .media-slide-radio:nth-of-type(5):checked ~ .media-dots .media-dot:nth-child(5) { background: #fff; }
/* A single column of the blog keeps the whole picture visible. */
.blog-grid.cols-1 .media-slider-blog .media-slide-link {
    display: flex; justify-content: center; align-items: center;
}
.blog-grid.cols-1 .media-slider-blog img {
    width: auto; max-width: 100%; height: auto; max-height: 460px; object-fit: contain;
}
.feed-excerpt {
    margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.5;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.feed-footer {
    display: flex; align-items: center; flex-wrap: wrap; gap: 12px;
    margin-top: auto; padding-top: 4px; font-size: .8rem; color: var(--muted);
}
.feed-author { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 600; }
.feed-author:hover { color: var(--accent); }
.feed-stat { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.feed-stat:hover { color: var(--accent); }
.feed-stat .i { width: 14px; height: 14px; }
.feed-footer .favorite-button,
.feed-footer .follow-button { padding: 4px 4px; opacity: .65; line-height: 1; }
.feed-footer .favorite-button .i,
.feed-footer .follow-button .i,
.feed-footer .tag-pop .i { width: 14px; height: 14px; }
.feed-footer .tag-pop { line-height: 1; }
.feed-footer .favorite-button:hover,
.feed-footer .favorite-button.is-active,
.feed-footer .follow-button:hover,
.feed-footer .follow-button.is-active { opacity: 1; }
/* The picture of the topic is under the title — the old column with the
   miniature is not used any more. */
.feed-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.feed-empty .cta-actions { justify-content: center; }
.feed-subscribe-hints { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.feed-subscribe-hints .btn { text-decoration: none; }
.feed-end {
    display: flex; align-items: center; gap: 8px; justify-content: center;
    padding: 6px 0 2px; color: var(--muted); font-size: .82rem;
}
.feed-end .i { width: 15px; height: 15px; color: var(--accent); }
.feed-end p { margin: 0; }

.file-label-sm { font-size: .82rem; }

/* ---------- Page head ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { margin-bottom: 2px; }
.page-head p { margin: 0; }
.page-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.empty .i { width: 34px; height: 34px; opacity: .5; }

/* ---------- Topic + posts ---------- */
.topic-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.topic-head-main { min-width: 0; flex: 1 1 460px; }
.topic-head-actions { flex: 0 0 auto; }
.topic-head h1 { margin: 0; }
.topic-head-path { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 0 0 2px; font-size: .85rem; color: var(--muted); }
.topic-head-path a { color: var(--muted); font-weight: 600; }
.topic-head-path a:hover { color: var(--accent); }
.topic-head-path span { opacity: .55; }
.topic-head-byline { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; color: var(--muted); font-size: .85rem; margin: 2px 0 0; }
.topic-head-byline a { color: var(--text); font-weight: 650; }
.topic-head-byline a:hover { color: var(--accent); }
.topic-head-sep { opacity: .5; }
.topic-head-meta { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: .87rem; margin: 6px 0 0; }
.topic-head-meta span, .topic-head-meta a { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); }
.topic-head-meta a:hover { color: var(--accent); }
.badge { padding: 2px 9px; border-radius: 20px; font-size: .76rem; font-weight: 700; }
.badge-pin { background: var(--accent-soft); color: var(--accent); }
.badge-lock { background: var(--bg-soft); color: var(--muted); }
.posts { display: flex; flex-direction: column; gap: 12px; }
.post {
    display: grid; grid-template-columns: 168px minmax(0, 1fr);
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); overflow: hidden;
}
/* The text of the message is the first element in the code, the grid keeps
   the author block on the left. */
.post-user { grid-column: 1; grid-row: 1; }
.post-body { grid-column: 2; grid-row: 1; }
.post-user { padding: 18px 14px; background: var(--card-alt); border-right: 1px solid var(--border); text-align: center; }
.post-user .avatar-96 { display: block; margin: 0 auto 10px; }
.post-username { font-weight: 700; display: block; word-break: break-word; }
/* The counters of the author: every line has its own air, so the block is
   read easily and does not stick to the message next to it. */
.post-user-stats { display: grid; grid-template-columns: auto auto; gap: 7px 10px; margin: 12px 0 0; font-size: .78rem; text-align: left; }
.post-user-stats dt { color: var(--muted); }
.post-user-stats dd { margin: 0; font-weight: 600; text-align: right; }
/* The text of the message never touches the block of the author: there is
   always a gap between the column of the author and the window of the
   message. */
.post-body { padding: 16px 24px 16px; min-width: 0; }
.post-head { display: flex; align-items: center; gap: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border); font-size: .84rem; color: var(--muted); }

/* The comments of a topic: the same cards as the post, but more compact —
   the discussion is easy to scan and the page stays short. */
.comments-head {
    display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
    flex-wrap: wrap; margin: 2px 2px -2px; padding-top: 6px;
}
.comments-head h2 { margin: 0; font-size: 1.12rem; }
.comments-head p { margin: 0; }
.comments-count {
    display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 24px;
    margin-left: 4px; padding: 0 8px; border-radius: 12px;
    background: var(--accent-soft); color: var(--accent); font-size: .82rem; font-weight: 750;
}
.post-comment { grid-template-columns: 126px minmax(0, 1fr); box-shadow: none; }
.post-comment .post-user { padding: 14px 10px; }
.post-comment .post-user .avatar-96 { width: 56px; height: 56px; margin: 0 auto 8px; font-size: 22px; }
.post-comment .post-user-stats { display: none; }
.post-comment .post-body { padding: 14px 20px 12px; }
.post-comment .post-content { padding: 12px 0 4px; font-size: .96rem; }
.post-comment .post-actions { margin-top: 8px; }
.post-edited { font-style: italic; }
.post-content { padding: 14px 0 6px; font-size: 1rem; overflow-wrap: anywhere; }
/* Every picture of a message is strictly under the previous one: two or
   more images never form a row, even on a wide screen. */
.post-images { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 0 0 12px; }
.post-images .post-image { max-width: 100%; }
.post-image { margin: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--card-alt); }
.post-image img { display: block; max-height: 420px; width: auto; }
.signature { margin-top: 14px; padding-top: 10px; border-top: 1px dashed var(--border); color: var(--muted); font-size: .87rem; }
.role-badge { display: inline-block; margin-top: 6px; padding: 2px 9px; border-radius: 20px; font-size: .72rem; font-weight: 700; background: var(--bg-soft); color: var(--muted); }
.role-badge.role-10 { background: #fdeaea; color: #a5301f; }
.role-badge.role-5 { background: var(--accent-soft); color: var(--accent-dark); }
[data-theme="dark"] .role-badge.role-10 { background: #3a1d1a; color: #f0a89d; }

.post-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.action {
    display: inline-flex; align-items: center; gap: 5px; padding: 6px 11px; border-radius: 20px;
    border: 1px solid var(--border); background: var(--card); color: var(--text); font: inherit; font-size: .84rem; cursor: pointer;
}
.action:hover { border-color: var(--accent); color: var(--accent); }
.action.action-icon { padding: 6px 9px; }
.post-actions .action .i,
.post-actions .favorite-button .i,
.post-actions .tag-pop .i { width: 16px; height: 16px; }
.action.is-liked { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.action.danger:hover { border-color: var(--danger); color: var(--danger); }
.reaction-count { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: .84rem; }

/* ---------- The button of the favourites ---------- */
.favorite-button { padding: 6px 9px; color: var(--muted); }
.favorite-button .i { width: 16px; height: 16px; }
.favorite-button:hover { color: var(--accent); }
.favorite-button.is-active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.favorite-button.is-active .i { fill: currentColor; }
.topic-stats .favorite-button { padding: 4px 7px; }
.topic-stats .favorite-button .i { width: 15px; height: 15px; }
.blog-meta .favorite-button { padding: 4px 7px; }
.blog-meta .favorite-button .i { width: 15px; height: 15px; }

/* ---------- The page of the participants ---------- */
.member-user { flex-direction: column; align-items: flex-start; gap: 6px; }
.member-user > a { width: 100%; }
.member-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--muted); font-size: .78rem; }
.member-meta > span { display: inline-flex; align-items: center; gap: 3px; }
.member-meta .i { width: 14px; height: 14px; }

/* ---------- The cards of the blogs ---------- */
.blog-card-blog .blog-body { display: block; }

/* BBCode */
.bb-text p { margin: 0 0 .6em; }
.bb-quote { margin: 10px 0; padding: 10px 14px; border-left: 3px solid var(--accent); background: var(--card-alt); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.bb-quote cite { display: block; font-weight: 700; font-style: normal; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
.bb-code { background: #241f18; color: #ece5d8; padding: 12px 14px; border-radius: var(--radius-sm); overflow-x: auto; font-size: .86rem; }
.bb-spoiler { margin: 8px 0; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px; }
.bb-spoiler summary { cursor: pointer; font-weight: 600; }
.bb-hr { border: 0; border-top: 1px solid var(--border); margin: 12px 0; }
.bb-link { text-decoration: underline; }
/* The mention @name — a link to the profile of the participant. */
.bb-mention { color: var(--accent); font-weight: 600; text-decoration: none; }
.bb-mention:hover { text-decoration: underline; }

/* Long reading: the body of a message gets a comfortable measure, airy line
   height and calm spacing. The cards around it stay compact; only the text
   the reader spends minutes with is relaxed. */
.post-content { font-size: 1.03rem; line-height: 1.7; }
.bb-text { line-height: 1.7; overflow-wrap: anywhere; }
.post-content .bb-text,
.post-comment .bb-text { max-width: 76ch; }
.bb-text p { margin: 0 0 .85em; }
.bb-text p:last-child { margin-bottom: 0; }
.bb-text h1, .bb-text h2, .bb-text h3 { margin: 1.1em 0 .45em; line-height: 1.3; }
.bb-text h1:first-child, .bb-text h2:first-child, .bb-text h3:first-child { margin-top: 0; }
.bb-text ul, .bb-text ol { margin: .55em 0 .9em; padding-left: 1.45em; }
.bb-text li + li { margin-top: .28em; }
.bb-text code { padding: 1px 5px; border-radius: 4px; background: var(--bg-soft); font-size: .9em; }
.bb-text .bb-code code { padding: 0; background: none; font-size: inherit; }
.bb-text a { text-decoration: underline; text-underline-offset: 2px; }
.bb-text img { border-radius: var(--radius-sm); }
.bb-text > :first-child { margin-top: 0; }
.bb-text > :last-child { margin-bottom: 0; }
.post-content a:focus-visible,
.post-content button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.post-comment .post-content { font-size: .99rem; }

/* Multimedia: the frame keeps its proportions and does not shift the page. */
.bb-media { margin: 12px auto; position: relative; width: 100%; max-width: 760px; padding-top: 56.25%; background: #14110d; border-radius: var(--radius-sm); overflow: hidden; }
.bb-media iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0; }
.bb-media-blocked {
    display: inline-block; margin: 8px 0; padding: 8px 12px; border-radius: var(--radius-sm);
    background: var(--bg-soft); color: var(--muted); font-size: .86rem;
}

/* ---------- Editor ---------- */
.editor { margin-top: 6px; }
.editor-toolbar { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.bb {
    min-width: 34px; height: 32px; border: 1px solid var(--border); background: var(--card-alt);
    border-radius: var(--radius-sm); cursor: pointer; font: inherit; font-size: .84rem; padding: 0 9px; color: var(--text);
}
.bb:hover { border-color: var(--accent); color: var(--accent); }
.editor textarea, .editor-toolbar + textarea, textarea {
    width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--card); color: var(--text); font: inherit; font-size: .96rem; resize: vertical; line-height: 1.6;
}
textarea:focus, input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.editor-upload { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.file-label {
    display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; color: var(--accent);
    border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); padding: 9px 14px; width: fit-content;
}
.file-label input[type="file"] { display: none; }
.file-preview { list-style: none; display: flex; gap: 8px; flex-wrap: wrap; padding: 0; margin: 6px 0 0; }
.file-preview li { font-size: .8rem; color: var(--muted); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px 8px; }
.editor-footer { margin-top: 12px; display: flex; gap: 8px; align-items: center; }

/* The visual editor: the formatted text lives right in the box — there is no
   separate preview, the editor itself shows the future message. */
.editor-frame {
    border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card);
    overflow: hidden;
}
.editor-frame:focus-within { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.editor-frame textarea {
    width: 100%; border: 0; border-radius: 0; background: var(--card); color: var(--text);
    font: inherit; font-size: .96rem; resize: vertical; line-height: 1.6;
    padding: 12px; display: block;
}
.editor-frame textarea:focus { outline: none; }
.editor-visual {
    min-height: 190px; padding: 14px 16px; outline: none;
    font-size: 1rem; line-height: 1.75; overflow-wrap: anywhere; word-break: break-word;
}
.editor-visual[data-empty="true"]::before {
    content: attr(data-placeholder); color: var(--muted); pointer-events: none;
}
.editor-visual.is-invalid { box-shadow: inset 0 0 0 2px var(--danger); }
.editor-visual .bb-quote {
    margin: 10px 0; padding: 8px 12px; border-left: 3px solid var(--border-strong);
    background: var(--card-alt); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.editor-visual .bb-quote cite {
    display: block; font-weight: 700; font-style: normal; font-size: .85rem;
    color: var(--muted); margin-bottom: 4px;
}
.editor-visual .bb-code {
    margin: 10px 0; padding: 10px 12px; background: var(--card-alt);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    white-space: pre-wrap; overflow-x: auto; font-size: .9rem;
}
/* The multimedia in the editor is a compact chip. The black box of the
   published message (the video keeps its proportions) must not swallow the
   whole editor: the text of the message must stay writable next to it. */
.editor-visual .bb-media {
    margin: 10px 0; position: static; width: auto; padding-top: 0;
    background: none; overflow: visible;
}
.editor-visual .bb-media-chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px;
    border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
    color: var(--muted); font-size: .84rem;
}
.editor-visual .bb-spoiler {
    margin: 10px 0; padding: 8px 10px; border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
}
.editor-visual .bb-spoiler-head {
    font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
    color: var(--muted); margin-bottom: 5px;
}
.editor-visual .bb-spoiler-body {
    border-left: 3px solid var(--border); padding-left: 10px;
}
.editor-visual hr { border: 0; border-top: 1px solid var(--border-strong); margin: 14px 0; }
.editor-error { color: var(--danger); }
.editor-error a { color: var(--danger); text-decoration: underline; text-underline-offset: 2px; }

/* The preview of the pictures of the message: the thumbnail and the name
   of the file (the name becomes the address of the picture). */
.file-preview {
    list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 12px; padding: 0; margin: 8px 0 0;
}
.file-preview li { font-size: .8rem; color: var(--muted); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px 8px; }
.file-preview-item {
    position: relative;
    display: flex; gap: 12px; align-items: flex-start; padding: 10px;
    border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card);
}
.file-preview-img {
    width: 128px; height: 128px; object-fit: cover; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--card-alt); flex: 0 0 auto;
}
.file-preview-remove {
    position: absolute; top: 5px; right: 5px; z-index: 2;
    display: inline-flex; align-items: center; justify-content: center;
    width: 24px; height: 24px; padding: 0; border-radius: 50%;
    border: 1px solid var(--border); background: var(--card); color: var(--danger);
    font: inherit; font-size: 16px; line-height: 1; cursor: pointer;
}
.file-preview-remove:hover { border-color: var(--danger); background: var(--danger); color: #fff; }
.file-preview-body { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; gap: 5px; }
.file-preview-label { display: flex; flex-direction: column; gap: 3px; }
.file-preview-label span { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.file-preview-label input {
    width: 100%; padding: 7px 9px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    background: var(--card); color: var(--text); font: inherit; font-size: .88rem;
}
.file-preview-label input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.file-preview-size { font-size: .76rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Multimedia panel of the editor */
.bb-media-toggle { display: inline-flex; align-items: center; justify-content: center; }
.bb-media-toggle .i { width: 16px; height: 16px; }
.media-panel {
    margin: 0 0 10px; padding: 12px 14px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); background: var(--card-alt);
}
.media-panel .field { margin-bottom: 8px; }
.media-panel code { font-size: .85em; }
.media-panel-actions { display: flex; gap: 8px; align-items: center; }
.media-error { color: var(--danger); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field-label { font-weight: 600; font-size: .88rem; }
.field input[type="text"], .field input[type="email"], .field input[type="password"],
.field input[type="number"], .field input[type="search"], .field select, .search-form input {
    padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--card); color: var(--text); font: inherit; width: 100%;
}
.field-help { font-size: .8rem; color: var(--muted); }
.field.checkbox { flex-direction: row; align-items: center; gap: 8px; }
.field.checkbox input { width: auto; }
.checkbox { display: inline-flex; align-items: center; gap: 6px; }
.field-wide { grid-column: 1 / -1; }
fieldset.fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; margin: 0 0 14px; }
fieldset.fieldset legend { font-weight: 700; padding: 0 6px; }
.password-wrap { position: relative; display: flex; align-items: center; gap: 6px; }
.honeypot { position: absolute; left: -9999px; opacity: 0; height: 0; overflow: hidden; }
.search-form { display: flex; gap: 8px; }
.search-form input { flex: 1; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }

/* ---------- Auth ---------- */
.auth-card { max-width: 460px; margin: 20px auto; }
.auth-alt { text-align: center; margin: 14px 0 0; color: var(--muted); font-size: .9rem; }

/* ---------- Profile / account ---------- */
.profile-head { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.avatar-128 { border-radius: 16px; }
.profile-stats { list-style: none; display: flex; gap: 18px; flex-wrap: wrap; margin: 12px 0 0; padding: 0; }
.profile-stats div { min-width: 70px; }
.profile-stats dt { color: var(--muted); font-size: .78rem; }
.profile-stats dd { margin: 0; font-weight: 700; font-size: 1.05rem; }
.account-grid { display: grid; grid-template-columns: 220px 1fr; gap: 22px; }
.account-avatar { text-align: center; }
.account-avatar .avatar-128 { margin: 0 auto 12px; display: block; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 4px 20px; }
.admin-actions { display: flex; gap: 10px; align-items: center; }

/* ---------- Sidebar widgets ---------- */
.widget { padding: 0; overflow: hidden; }
.widget-title { display: flex; align-items: center; gap: 7px; font-size: .98rem; padding: 13px 16px; margin: 0; border-bottom: 1px solid var(--border); background: var(--card-alt); }
.widget > .muted, .widget > p { padding: 12px 16px; margin: 0; }
.tabs {
    display: flex; border-bottom: 1px solid var(--border); background: var(--card-alt);
    overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
    flex: 1 0 auto; display: inline-flex; align-items: center; justify-content: center; gap: 5px;
    padding: 11px 8px; border: 0; background: none; font: inherit; font-size: .85rem; font-weight: 600;
    color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--accent); }
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); background: var(--card); }
.tab-panel { display: none; padding: 8px 0; }
.tab-panel.is-active { display: block; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 9px 16px; }
.list li + li { border-top: 1px solid var(--border); }
.list-title { font-weight: 600; font-size: .92rem; display: block; }
.list-meta { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .78rem; margin-top: 3px; }
.list-wide li { padding: 10px 0; }
.list-wide .list-title { font-size: .95rem; }
.online-list { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 16px; margin: 0; }
.widget-cta p { padding: 0 16px 10px; }
.cta-actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 0 4px; }
.widget-cta .cta-actions { padding: 0 16px 16px; }
.widget-all { padding: 8px 16px 12px; border-top: 1px solid var(--border); font-size: .82rem; font-weight: 650; }
.widget-note { padding: 12px 16px 4px !important; }
.community-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin: 0; padding: 14px 12px; background: var(--border); }
.community-stats > div { background: var(--card); padding: 8px 6px; text-align: center; border-radius: 4px; }
.community-stats dt { color: var(--muted); font-size: .72rem; }
.community-stats dd { margin: 2px 0 0; font-size: 1.06rem; font-weight: 750; }
.community-newest { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; padding: 10px 16px 14px; border-top: 1px solid var(--border); font-size: .82rem; }
.community-newest a { font-weight: 650; }
.side-links { display: flex; flex-direction: column; padding: 6px 0; }
.side-links a {
    display: flex; align-items: center; gap: 8px; padding: 9px 16px;
    color: var(--text); font-size: .88rem; font-weight: 600;
}
.side-links a:hover { background: var(--accent-soft); color: var(--accent); }
.side-links .i { width: 15px; height: 15px; color: var(--muted); }
.side-links a:hover .i { color: var(--accent); }

/* ---------- Related / redirect / error ---------- */
/* The block with three tabs: the tabs go from edge to edge of the card. */
.related { padding: 0; overflow: hidden; }
.related .tab-panel { padding: 4px 0 6px; }
.related .list { padding: 6px 16px 10px; }
.topic-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.topic-col h3 { font-size: .92rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.topic-col .list li { padding: 8px 0; }
.post-nav { justify-content: space-between; }
.redirect-card, .error-page { text-align: center; }
.redirect-host { font-size: 1.2rem; font-weight: 700; margin: 6px 0; }
.redirect-url { word-break: break-all; color: var(--muted); font-size: .86rem; background: var(--card-alt); padding: 8px 12px; border-radius: var(--radius-sm); display: inline-block; }
.redirect-card .cta-actions, .error-page .cta-actions { justify-content: center; margin-top: 14px; }
.error-code { font-size: 2.6rem; font-weight: 800; color: var(--accent); display: block; }

/* ---------- Admin ---------- */
.admin-nav { display: flex; flex-wrap: wrap; gap: 6px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; box-shadow: var(--shadow); }
.admin-nav-item { padding: 8px 14px; border-radius: var(--radius-sm); font-weight: 600; font-size: .9rem; color: var(--muted); }
.admin-nav-item:hover { background: var(--accent-soft); color: var(--accent); }
.admin-nav-item.is-active { background: var(--accent); color: var(--on-accent); }
.admin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--gap); }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat-card span { display: block; color: var(--muted); font-size: .82rem; }
.stat-card strong { font-size: 1.4rem; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.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: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.table td input[type="text"], .table td input[type="number"], .table td select { padding: 7px 9px; font-size: .87rem; }
.row-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.row-form input[type="text"] { min-width: 150px; }
.input-sm { width: 74px; }
.new-row { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); display: flex; gap: 8px; flex-wrap: wrap; }
.log-list { list-style: none; margin: 0; padding: 0; font-size: .87rem; }
.log-list li { padding: 8px 0; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }

/* ---------- The batch jobs of the AI module ---------- */
.ai-batch-card .field-wide { grid-column: 1 / -1; }
.ai-last-job {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    margin-top: 14px; padding: 10px 12px; border-radius: var(--radius-sm);
    background: var(--bg-soft); border: 1px solid var(--border); font-size: .88rem;
}
.ai-last-job-title { font-weight: 700; }
.ai-status {
    display: inline-block; padding: 1px 9px; border-radius: 20px;
    font-size: .74rem; font-weight: 700; background: var(--accent-soft); color: var(--accent);
}
.ai-status-done { background: #e4f5e8; color: #24703a; }
.ai-status-cancelled { background: #fdeaea; color: #a5301f; }
[data-theme="dark"] .ai-status-done { background: #1d3a27; color: #8fdb9f; }
[data-theme="dark"] .ai-status-cancelled { background: #3a1d1a; color: #f0a89d; }
.ai-progress {
    margin-top: 14px; padding: 12px; border-radius: var(--radius-sm);
    background: var(--bg-soft); border: 1px solid var(--border);
}
.ai-progress[hidden] { display: none; }
.ai-progress-bar {
    height: 10px; border-radius: 999px; overflow: hidden;
    background: var(--border); margin-bottom: 8px;
}
.ai-progress-bar span {
    display: block; width: 0; height: 100%;
    background: var(--accent); transition: width .25s ease;
}
.ai-progress-text { margin: 0 0 6px; font-weight: 650; font-size: .9rem; }
.ai-progress-last, .ai-progress-errors { display: flex; flex-direction: column; gap: 3px; }
.ai-last-line { font-size: .86rem; overflow-wrap: anywhere; }
.ai-progress-errors { margin-top: 6px; }
.ai-error-line {
    font-size: .84rem; color: var(--danger);
    overflow-wrap: anywhere;
}
.ai-progress .admin-actions { margin-top: 10px; }

/* ---------- Search and replace ---------- */
.search-replace-table td { vertical-align: top; }
.search-replace-line {
    display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap;
    padding: 2px 0; font-size: .84rem; overflow-wrap: anywhere;
}
.search-replace-line code { white-space: pre-wrap; word-break: break-word; }

/* ---------- Spam ---------- */
.spam-list { list-style: none; margin: 0; padding: 0; }
.spam-item { padding: 12px 0; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.spam-item:last-child { border-bottom: 0; }
.spam-text { font-size: .9rem; overflow-wrap: anywhere; }
.spam-title { font-weight: 650; }
.spam-meta { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; color: var(--muted); font-size: .8rem; }
.spam-reason { display: inline-block; padding: 1px 9px; border-radius: 20px; font-size: .74rem; font-weight: 700; background: #fdeaea; color: #a5301f; }
.spam-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
/* ---------- Moderation ---------- */
.cell-check { width: 34px; }
.cell-actions { white-space: nowrap; }
.cell-actions .inline-form { display: inline-flex; }
.check-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.plugin-card .plugin-head { display: flex; align-items: center; justify-content: space-between; }
.switch { font-size: 1.02rem; font-weight: 700; }

/* ---------- Footer ---------- */
.site-footer { background: var(--card); color: var(--muted); border-top: 1px solid var(--border); margin-top: auto; }
.footer-inner { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 24px; padding: 28px 20px 18px; }
.footer-col { display: flex; flex-direction: column; gap: 6px; font-size: .88rem; }
.footer-col strong { color: var(--text); font-size: 1.04rem; }
.footer-col p { margin: 0; color: var(--muted); max-width: 480px; }
.footer-title { font-weight: 750; color: var(--text); margin-bottom: 2px; }
.footer-col a { color: var(--muted); }
.footer-col a:hover { color: var(--accent); text-decoration: none; }
.footer-col .link-button { color: var(--muted); }
.footer-col .link-button:hover { color: var(--accent); }
.footer-bottom { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 20px 22px; border-top: 1px solid var(--border); font-size: .82rem; color: var(--muted); }
.footer-stats { color: var(--muted); font-size: .78rem; }
.to-top { color: var(--muted); }
.to-top:hover { color: var(--accent); }

/* ---------- Avatars ---------- */
.avatar { display: inline-block; border-radius: 50%; overflow: hidden; flex: 0 0 auto; line-height: 0; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-24 { width: 24px; height: 24px; }
.avatar-28 { width: 28px; height: 28px; }
.avatar-32 { width: 32px; height: 32px; }
.avatar-40 { width: 40px; height: 40px; }
.avatar-48 { width: 48px; height: 48px; }
.avatar-64 { width: 64px; height: 64px; }
.avatar-96 { width: 96px; height: 96px; }
.avatar-128 { width: 128px; height: 128px; }
/* Placeholder drawn inline as SVG: no request, no layout shift. */
.avatar-svg { display: inline-block; background: var(--accent-soft); user-select: none; }
.avatar-svg svg { width: 100%; height: 100%; display: block; }

/* ---------- Lightbox ---------- */
dialog.lightbox { border: 0; padding: 0; background: rgba(9, 14, 22, .92); max-width: 96vw; max-height: 96vh; }
dialog.lightbox::backdrop { background: rgba(9, 14, 22, .8); }
dialog.lightbox img { max-width: 94vw; max-height: 88vh; display: block; margin: 0 auto; }
dialog.lightbox .lightbox-close { position: absolute; top: 8px; right: 12px; background: none; border: 0; color: #fff; font-size: 1.6rem; cursor: pointer; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
    .layout.with-sidebar .layout-inner { grid-template-columns: minmax(0, 1fr); }
    .sidebar { order: 2; }
    .forum-node { grid-template-columns: 40px minmax(0, 1fr) 120px; }
    .forum-last { display: none; }
    .topic-row { grid-template-columns: 40px minmax(0, 1fr) 90px; }
    .topic-last { display: none; }
    .two-col { grid-template-columns: 1fr; }
    .footer-inner { grid-template-columns: 1fr 1fr; }
    /* The search becomes narrower, so the header keeps fitting on the screen. */
    .header-search { min-width: 150px; }
    .main-nav a { padding: 8px 9px; }
    /* The picture of the feed is under the title, so the card keeps two
       columns on the tablet too. */
    .feed-item, .feed-item.no-media { grid-template-columns: 54px minmax(0, 1fr); }
    .feed-vote { padding-right: 10px; }
    .feed-media { max-width: 100%; }
}
@media (max-width: 760px) {
    .header-inner { gap: 10px; }
    /* The menu of the mobile browser holds the search: it opens together with
       the menu, so the search is always at hand. */
    .main-nav {
        display: none; position: absolute; top: 100%; left: 0; right: 0; background: var(--card);
        border-bottom: 1px solid var(--border);
        flex-direction: column; padding: 10px 16px 16px; gap: 2px; box-shadow: var(--shadow-lg);
    }
    .main-nav.is-open { display: flex; }
    .header-search { order: 3; width: 100%; min-width: 0; margin: 8px 0 0; }
    .header-inner { flex-wrap: wrap; height: auto; padding: 10px 0; }
    .nav-toggle { display: inline-flex; }
    .user-name { display: none; }
    .post { grid-template-columns: 1fr; }
    .post-user { display: flex; align-items: center; gap: 12px; text-align: left; border-right: 0; border-bottom: 1px solid var(--border); padding: 12px 16px; grid-column: 1; grid-row: 1; }
    .post-body { grid-column: 1; grid-row: 2; }
    .post-user .avatar-96 { width: 48px; height: 48px; margin: 0; font-size: 22px; }
    .post-user-stats { display: none; }
    .role-badge { margin: 0; }
    .footer-inner { grid-template-columns: 1fr; }
    .account-grid { grid-template-columns: 1fr; }
    .topic-stats { display: none; }
    .topic-row { grid-template-columns: 40px minmax(0, 1fr); }
    .hero-stats { gap: 14px; }
    /* The counters of a forum move under its description: they never cover
       the text of the section on a narrow screen. */
    .forum-node { grid-template-columns: 40px minmax(0, 1fr); }
    .forum-icon { grid-column: 1; grid-row: 1 / span 2; }
    .forum-main { grid-column: 2; grid-row: 1; }
    .forum-counts { grid-column: 2; grid-row: 2; padding-top: 5px; flex-wrap: wrap; }
    .topic-cols { grid-template-columns: 1fr; }
    .blog-grid.cols-2 { grid-template-columns: 1fr; }
    .blog-grid.cols-1 .blog-card { flex-direction: column; }
    .blog-grid.cols-1 .group-card { flex-direction: row; }
    .group-icon-sm { width: 56px; height: 56px; }
    .blog-grid.cols-1 .blog-title { padding: 14px 16px 0; font-size: 1.05rem; }
    .blog-grid.cols-1 .blog-media { flex: none; }
    .blog-grid.cols-1 .blog-media img { height: 190px; }
    .blog-grid.cols-1 .blog-embed { flex: none; padding-top: 56.25%; }
    .post-nav { justify-content: stretch; }
    .post-nav .page-link { flex: 1; justify-content: center; }
    .group-head-actions { width: 100%; }
    .members-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
    .reward-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
    /* The editor becomes one column: the preview goes under the text. */
    .editor-body { grid-template-columns: minmax(0, 1fr); }
    .notif-panel { position: fixed; right: 8px; top: 58px; width: calc(100vw - 16px); }

    /* ---------- Feed on a phone ----------
       The header stays sticky, so the tab bar does not: two sticky bars would
       cover the screen. The rating moves under the card as a compact row:
       no empty side column. */
    .feed-head { align-items: flex-start; }
    .feed-head h1 { font-size: 1.32rem; }
    .feed-head-actions { width: 100%; }
    .feed-head-actions .btn { flex: 1 1 auto; justify-content: center; }
    /* The header stays sticky, so the feed tabs scroll with the page: two
       sticky bars on a phone would cover too much of the screen. */
    .feed-topbar { position: static; flex-wrap: wrap; padding: 6px; }
    .feed-tabs { flex: 1 1 auto; }
    .feed-tab { padding: 7px 11px; font-size: .86rem; }
    .feed-topbar-side { margin-left: auto; }
    .feed-total { display: none; }
    .feed-item, .feed-item.no-media {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: "main" "vote";
        gap: 10px; padding: 12px;
    }
    .feed-main { grid-area: main; }
    .feed-vote {
        grid-area: vote; flex-direction: row; align-items: center; justify-content: flex-start;
        gap: 5px; padding: 7px 0 0; border-right: 0; border-top: 1px solid var(--border);
    }
    .feed-vote strong { font-size: .9rem; }
    .feed-vote span { display: none; }
    .feed-title { font-size: 1.06rem; }
    .feed-excerpt { font-size: .86rem; }
    .feed-footer { gap: 10px; }
    /* The comment keeps the compact author row without the shifted avatar. */
    .post-comment .post-user { padding: 10px 12px; }
    .post-comment .post-user .avatar-96 { margin: 0; }
}
@media print {
    .site-header, .site-footer, .sidebar, .post-actions, .editor { display: none; }
}

/* ---------- Comment sorting (without JavaScript) ---------- */
.comment-sort { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.comment-sort-link {
    display: inline-flex; align-items: center; padding: 5px 12px; border-radius: 20px;
    border: 1px solid var(--border); background: var(--card); color: var(--muted);
    font-size: .82rem; font-weight: 600; white-space: nowrap;
}
.comment-sort-link:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.comment-sort-link.is-active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* The chosen addressee of a reply: compact, but the text stays writable. */
.reply-target {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
    margin: 0 0 12px; padding: 9px 12px; border-radius: var(--radius-sm);
    background: var(--accent-soft); color: var(--text); font-size: .88rem;
}
.reply-target .i { width: 16px; height: 16px; color: var(--accent); flex: 0 0 auto; }
.reply-target a { font-weight: 600; }

/* ---------- Favourites: two independent columns ---------- */
.favorites-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); align-items: start; }
.favorites-column { min-width: 0; }
.favorites-column .card-head h2 { display: flex; align-items: center; gap: 8px; }
.favorites-column .blog-grid.cols-1 { grid-template-columns: minmax(0, 1fr); }
.favorite-comment-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.favorite-comment {
    padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--card-alt); display: flex; flex-direction: column; gap: 7px;
}
.favorite-comment-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--muted); font-size: .8rem; }
.favorite-comment-author { font-weight: 650; color: var(--text); }
.favorite-comment-topic { display: inline-flex; align-items: center; gap: 5px; font-size: .86rem; font-weight: 600; overflow-wrap: anywhere; }
.favorite-comment-topic .i { width: 14px; height: 14px; color: var(--muted); flex: 0 0 auto; }
.favorite-comment-text { font-size: .9rem; line-height: 1.45; overflow-wrap: anywhere; }
.favorite-comment-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

/* ---------- Complaints ---------- */
.report-list { list-style: none; margin: 0; padding: 0; }
.report-item { padding: 14px 0; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.report-item:last-child { border-bottom: 0; }
.report-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--muted); font-size: .8rem; }
.report-head a { font-weight: 650; }
.report-reason { font-size: .92rem; overflow-wrap: anywhere; }
.report-target { padding: 9px 12px; border-radius: var(--radius-sm); background: var(--card-alt); display: flex; flex-direction: column; gap: 6px; }
.report-target-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: .82rem; }
.report-target-link { font-weight: 650; }
.report-target-text { font-size: .88rem; color: var(--muted); overflow-wrap: anywhere; }
.report-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.report-actions .inline-form, .report-ban-form { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 5px; margin: 0; }
.report-actions select, .report-actions input[type="text"] { padding: 5px 8px; font-size: .82rem; max-width: 170px; }
.report-actions input[type="text"] { min-width: 120px; }

/* ---------- Timed bans in the admin panel ---------- */
.ban-form { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.ban-form select { max-width: 120px; }
.ban-form input[type="text"] { min-width: 110px; max-width: 170px; padding: 6px 8px; font-size: .84rem; }
.admin-users-table td { vertical-align: top; }
.badge-warn { background: #fff3d6; color: #8a5a00; }
.badge-ok { background: #e2f5e6; color: #1c6b30; }
.badge-muted { background: var(--bg-soft); color: var(--muted); }
[data-theme="dark"] .badge-warn { background: #3b2d12; color: #f0c878; }
[data-theme="dark"] .badge-ok { background: #173522; color: #96d9a8; }

/* ---------- Notifications read on open ---------- */
.notif-page-item.is-just-read { opacity: .85; }
.notif-read-now {
    display: inline-block; margin: 0 4px 8px; padding: 1px 9px; border-radius: 20px;
    background: #e2f5e6; color: #1c6b30; font-size: .72rem; font-weight: 700;
}
[data-theme="dark"] .notif-read-now { background: #173522; color: #96d9a8; }

@media (max-width: 860px) {
    .favorites-grid { grid-template-columns: minmax(0, 1fr); }
}
.report-target-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-weight: 650; }
.report-card .report-target { margin-bottom: 12px; }
.report-form .admin-actions { margin-top: 10px; }
.admin-users-table .cell-actions { white-space: normal; }
.admin-users-table .ban-form { max-width: 260px; }

/* ---------- The answers under a comment ---------- */
/* One level only: every answer is a compact social-network line that sits
   right under its parent. The spoiler is a native <details>, so no script
   is needed to open the rest. */
.comment-replies {
    margin: -4px 0 4px 140px;
    padding: 4px 0 0 14px;
    border-left: 2px solid var(--border);
    display: flex; flex-direction: column; gap: 6px;
}
.replies-head {
    display: flex; align-items: center; gap: 6px;
    color: var(--accent); font-size: .8rem; font-weight: 750;
}
.replies-head .i { width: 15px; height: 15px; }
.replies-count {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 20px; height: 18px; padding: 0 6px; border-radius: 9px;
    background: var(--accent-soft); color: var(--accent); font-size: .72rem;
}
.replies-list { display: flex; flex-direction: column; gap: 6px; }
.reply-item {
    display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 9px;
    padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--card);
}
.reply-item-avatar img, .reply-item-avatar .avatar { display: block; }
.reply-item-body { min-width: 0; }
.reply-item-head { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; font-size: .78rem; color: var(--muted); }
.reply-item-author { font-weight: 700; color: var(--text); }
.reply-item-author:hover { color: var(--accent); }
.reply-item-edited { font-style: italic; }
.reply-item-images { display: flex; flex-wrap: wrap; gap: 6px; margin: 7px 0 0; }
.reply-item-images img { display: block; max-width: 220px; max-height: 180px; width: auto; height: auto; border-radius: 6px; }
.reply-item-text { margin-top: 5px; font-size: .9rem; line-height: 1.45; overflow-wrap: anywhere; }
.reply-item-text p { margin: 0 0 .4em; }
.reply-item-text p:last-child { margin-bottom: 0; }
.reply-item-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; color: var(--muted); font-size: .78rem; }
.reply-like {
    display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px;
    border: 0; background: none; color: var(--muted); font: inherit; cursor: pointer;
}
.reply-like:hover, .reply-like.is-liked { color: var(--accent); }
.reply-like.is-liked .i { fill: currentColor; }
.reply-like .i { width: 14px; height: 14px; }
.reply-link { border: 0; background: none; padding: 0; color: var(--muted); font: inherit; cursor: pointer; }
.reply-link:hover { color: var(--accent); }
.reply-link.danger:hover { color: var(--danger); }
.replies-more summary {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 0; color: var(--accent); font-size: .8rem; font-weight: 650;
    cursor: pointer; list-style: none;
}
.replies-more summary::-webkit-details-marker { display: none; }
.replies-more summary::before { content: "▸"; font-size: .75rem; }
.replies-more[open] summary::before { content: "▾"; }
.replies-more[open] summary { margin-bottom: 6px; }

/* The empty state of the "С картинками" order. */
.comments-empty {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 28px 16px; text-align: center; color: var(--muted);
}
.comments-empty .i { width: 40px; height: 40px; opacity: .45; }
.comments-empty p { margin: 0; }
.comments-empty p:first-of-type { color: var(--text); font-weight: 650; }

/* ---------- Steps of the new-topic form ---------- */
.form-step {
    margin: 0 0 18px; padding: 14px 16px 4px;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--card-alt);
}
.form-step-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.form-step-head strong { display: block; font-size: 1rem; color: var(--text); }
.form-step-head span { display: block; color: var(--muted); font-size: .85rem; margin-top: 2px; }
.form-step-num {
    display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto;
    padding: 5px 11px; border-radius: 999px;
    background: var(--accent-soft); color: var(--accent);
    font-size: .8rem; font-weight: 800; white-space: nowrap;
}
.form-step-num .i { width: 15px; height: 15px; }

/* ---------- Preview of a new topic ---------- */
.preview-modal { position: fixed; inset: 0; z-index: 120; display: flex; align-items: center; justify-content: center; padding: 16px; }
.preview-modal[hidden] { display: none; }
.preview-modal-backdrop { position: absolute; inset: 0; background: rgba(20, 17, 13, .55); }
.preview-modal-window {
    position: relative; z-index: 1; display: flex; flex-direction: column;
    width: min(860px, 100%); max-height: min(88vh, 900px);
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: 0 24px 70px rgba(0, 0, 0, .32); overflow: hidden;
}
.preview-modal-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.preview-modal-head h2 { margin: 0; font-size: 1.1rem; display: inline-flex; align-items: center; gap: 8px; }
.preview-modal-head h2 .i { width: 18px; height: 18px; color: var(--accent); }
.preview-modal-body { padding: 18px; overflow-y: auto; }
.preview-forum { margin: 0 0 6px; }
.preview-topic-title { margin: 0 0 12px; font-size: 1.4rem; line-height: 1.3; overflow-wrap: anywhere; }
.preview-topic-text { overflow-wrap: anywhere; }
.preview-topic-text .post-images { align-items: flex-start; }
.preview-error { margin: 12px 0 0; color: var(--danger); }
.preview-modal-actions {
    display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 10px;
    padding: 14px 18px; border-top: 1px solid var(--border); background: var(--card-alt);
}
.preview-modal-head .icon-button { font-size: 20px; line-height: 1; }

@media (max-width: 760px) {
    /* The answers lose the big left indent on a phone and use the full width. */
    .comment-replies { margin-left: 0; padding-left: 10px; }
    .reply-item { padding: 7px 8px; }
    .reply-item-images img { max-width: 100%; }
}

/* ---------- Personal messages ----------
   The inbox, the thread and the small poll of the open conversation. */
.pm-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.pm-item { border-bottom: 1px solid var(--border); }
.pm-item:last-child { border-bottom: 0; }
.pm-item-main { display: flex; gap: 10px; align-items: center; padding: 10px 6px; color: var(--text); border-radius: var(--radius-sm); }
.pm-item-main:hover { background: var(--accent-soft); }
.pm-item-body { flex: 1; min-width: 0; }
.pm-item-head { display: flex; align-items: center; gap: 8px; }
.pm-item-name { font-weight: 700; }
.pm-item-time { margin-left: auto; font-size: .76rem; color: var(--muted); white-space: nowrap; }
.pm-item-preview { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: .86rem; }
.pm-item.is-unread .pm-item-name { color: var(--accent); }
.pm-item.is-unread .pm-item-preview { color: var(--text); font-weight: 600; }

.pm-messages { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 10px; }
.pm-message { display: flex; gap: 8px; align-items: flex-end; max-width: 82%; }
.pm-message.is-mine { margin-left: auto; flex-direction: row-reverse; }
.pm-bubble { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 14px; padding: 8px 12px; min-width: 0; }
.pm-message.is-mine .pm-bubble { background: var(--accent-soft); border-color: transparent; }
.pm-bubble-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.pm-bubble-head time { font-size: .72rem; color: var(--muted); }
.pm-bubble-text { overflow-wrap: anywhere; }
.pm-bubble-text > :first-child { margin-top: 0; }
.pm-bubble-text > :last-child { margin-bottom: 0; }
.pm-message.is-new .pm-bubble { animation: pm-fade .5s ease; }
@keyframes pm-fade { from { opacity: .35; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.pm-reply { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 12px; }
.pm-thread.is-disabled .pm-reply { opacity: .6; }
.pm-admin-thread .pm-message { max-width: 100%; }
.pm-admin-thread .pm-message.is-deleted { opacity: .55; }

@media (max-width: 640px) {
    .pm-message { max-width: 100%; }
    .pm-item-time { display: none; }
}

/* ============================================================
   Polish of the messages, the header, the editor and the preview.
   The rules below refine the blocks above: the personal messages are
   compact and readable on a phone, the header never pushes the hamburger
   off the screen, the preview modal and the attached pictures stay inside
   the viewport, and a favourite reports its state with a small toast.
   ============================================================ */

/* ---------- The sizes of the avatars used by the messages ---------- */
.avatar-36 { width: 36px; height: 36px; }
.avatar-44 { width: 44px; height: 44px; }
.avatar-20 { width: 20px; height: 20px; }
/* A placeholder avatar is an inline SVG: it fills the square of its tile and
   never grows with the text of the page (the huge icon of the old thread). */
.avatar-svg { flex: 0 0 auto; line-height: 0; }
.avatar-svg svg { display: block; width: 100%; height: 100%; }

/* ---------- Page head with an avatar (the thread) ---------- */
.page-head h1 { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; min-width: 0; }
.page-head h1 > .avatar,
.page-head h1 > .avatar-svg { flex: 0 0 auto; }
.page-head h1 a { overflow-wrap: anywhere; }
.page-head .page-head-actions { flex-wrap: wrap; }

/* ---------- The header on a phone ----------
   The row breaks instead of pushing the menu button off the screen: the
   brand, the create button, the bell, the messages, the menu of the user and
   the hamburger always fit. */
.header-messages.has-unread { background: var(--accent-soft); color: var(--accent); }

/* A tablet breaks the row instead of overflowing it: the many sections of a
   big forum never push the user area or the hamburger out of the screen. */
@media (max-width: 1000px) and (min-width: 761px) {
    .header-inner { flex-wrap: wrap; height: auto; padding: 8px 0; row-gap: 4px; }
    .brand { flex: 0 0 auto; }
    .main-nav { flex-wrap: wrap; }
    .user-area { margin-left: auto; }
    .header-create span { display: none; }
    .header-create { padding: 7px 10px; }
}

@media (max-width: 760px) {
    .container { padding: 0 12px; }
    .header-inner {
        flex-wrap: wrap; height: auto; min-height: 56px;
        padding: 8px 0; gap: 8px; row-gap: 6px;
    }
    .brand { flex: 0 1 auto; min-width: 0; gap: 8px; }
    .brand-name {
        max-width: 132px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }
    .user-area {
        flex: 1 1 auto; flex-wrap: wrap; justify-content: flex-end;
        min-width: 0; gap: 6px; margin-left: auto;
    }
    /* The create button stays, but only its icon: the text is in the menu. */
    .header-create { padding: 7px 10px; gap: 0; }
    .header-create span { display: none; }
    .header-messages, .notif-toggle { width: 34px; height: 34px; }
    .user-button { max-width: 100%; padding: 3px 7px 3px 3px; }
    .user-points { display: none; }
    .nav-toggle {
        display: inline-flex; flex: 0 0 auto; width: 34px; height: 34px;
        align-items: center; justify-content: center; padding: 0;
        border-radius: 50%; background: var(--bg-soft);
    }
    .nav-toggle:hover { background: var(--accent-soft); color: var(--accent); }
    .main-nav {
        top: calc(100% + 1px); max-height: calc(100dvh - 80px); overflow-y: auto;
        -webkit-overflow-scrolling: touch; z-index: 55;
    }
    .main-nav a { display: flex; width: 100%; }
    .notif-panel { top: 62px; }
    .header-search { margin-top: 10px; }
    /* On a phone and a tablet the user menu is anchored to the viewport, so
       its lower items (gifts, the admin panel, logout) stay reachable even
       when the header row has wrapped and grown taller. */
    .dropdown-menu {
        position: fixed; left: 10px; right: 10px; top: auto; bottom: 10px;
        width: auto; min-width: 0; max-height: calc(100dvh - 20px);
        overflow-y: auto; z-index: 60;
    }
}

@media (max-width: 420px) {
    .brand-name { display: none; }
    .brand-mark { width: 30px; height: 30px; border-radius: 8px; }
    .header-inner { gap: 6px; }
}

/* ---------- Personal messages: compact, readable, adaptive ---------- */
.pm-page-head h1 { margin-bottom: 2px; }
/* The title of the thread: the avatar and the name stay on one line and the
   long username wraps instead of stretching the page. */
.pm-thread-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.pm-thread-title .avatar-36 { flex: 0 0 auto; }
.pm-thread-title-text { min-width: 0; overflow-wrap: anywhere; }
.pm-thread .card-head { flex-wrap: wrap; gap: 6px 12px; }
.pm-list { gap: 2px; }
.pm-item-main { min-width: 0; }
.pm-item-main .avatar { flex: 0 0 auto; }
.pm-item-body { min-width: 0; }
.pm-item-head { flex-wrap: wrap; gap: 6px; min-width: 0; }
.pm-item-name {
    min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pm-item-time { flex: 0 0 auto; }
.pm-item-preview { min-width: 0; }
.pm-item-delete { margin-left: 8px; flex: 0 0 auto; }
.pm-messages { min-width: 0; }
/* The list stays in the page even when it is empty (the poll appends the
   first message into it), but an empty list must not add a gap. */
.pm-messages.is-empty { display: none; }
.pm-thread .pm-empty { margin: 0 0 12px; }
.pm-message { min-width: 0; max-width: min(82%, 720px); }
.pm-message > .avatar,
.pm-message > .avatar-svg,
.pm-message > .pm-avatar { flex: 0 0 auto; line-height: 0; }
.pm-bubble { min-width: 0; max-width: 100%; }
.pm-bubble-head { flex-wrap: wrap; gap: 4px 8px; min-width: 0; }
.pm-bubble-head strong { min-width: 0; overflow-wrap: anywhere; }
.pm-bubble-text { min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
.pm-bubble-text .bb-quote,
.pm-bubble-text .bb-code,
.pm-bubble-text pre {
    max-width: 100%; overflow-x: auto; overflow-wrap: anywhere;
}
.pm-bubble-text .bb-media { max-width: 100%; margin: 8px 0; }
.pm-bubble-text img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }
.pm-bubble-text iframe { max-width: 100%; }
.pm-bubble-text ul,
.pm-bubble-text ol { padding-left: 1.25em; }
.pm-reply { min-width: 0; }
.pm-reply .editor-toolbar { min-width: 0; }
.pm-delete-form { margin: 0; }

@media (max-width: 640px) {
    .pm-page-head { padding: 14px; }
    .pm-page-head h1 { font-size: 1.16rem; gap: 8px; }
    .pm-page-head .page-head-actions { width: 100%; }
    .pm-page-head .page-head-actions .btn,
    .pm-page-head .page-head-actions form { flex: 1 1 auto; }
    .pm-page-head .page-head-actions form .btn { width: 100%; justify-content: center; }
    .pm-thread { padding: 12px; }
    .pm-thread .card-head { margin-bottom: 8px; }
    .pm-messages { gap: 8px; }
    .pm-message { max-width: 100%; align-items: flex-end; }
    .pm-message > .avatar-36 { width: 28px; height: 28px; }
    .pm-avatar .avatar-36 { width: 28px; height: 28px; }
    .pm-bubble { padding: 7px 10px; border-radius: 12px; }
    .pm-bubble-head { margin-bottom: 2px; }
    .pm-bubble-head strong { font-size: .84rem; }
    .pm-bubble-head time { font-size: .68rem; }
    .pm-item-main { padding: 9px 4px; }
    .pm-item-main .avatar-44 { width: 38px; height: 38px; }
    .pm-item-name { max-width: 100%; }
    .pm-item-preview { font-size: .82rem; }
    .pm-reply { margin-top: 10px; padding-top: 10px; }
    .pm-reply .editor-footer .btn { flex: 1 1 auto; justify-content: center; }
    .pm-thread .pagination { margin-top: 10px; }
}

/* ---------- The favourite: a small toast instead of silence ---------- */
.toast-stack {
    position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
    z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px;
    width: max-content; max-width: calc(100vw - 24px); pointer-events: none;
}
.toast {
    max-width: 100%; padding: 10px 16px; border-radius: 999px;
    background: var(--accent); color: var(--on-accent);
    font-size: .88rem; font-weight: 650; line-height: 1.35; text-align: center;
    box-shadow: var(--shadow-lg); animation: toast-in .18s ease;
    overflow-wrap: anywhere;
}
.toast.is-out { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- The link to the rules of the publication ---------- */
.flash-help {
    margin-left: 8px; font-weight: 700; color: inherit;
    text-decoration: underline; text-underline-offset: 2px; white-space: nowrap;
}
.flash-help:hover { color: inherit; }
.help-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; }
.help-list > li { line-height: 1.6; }
.help-list ul { margin: 6px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.help-list code { padding: 1px 5px; border-radius: 4px; background: var(--bg-soft); }

/* ---------- The pictures attached to a message ---------- */
.file-preview {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    align-items: start;
}
.file-preview-item { min-width: 0; }
.file-preview-img { width: 96px; height: 96px; }
.file-preview-body { min-width: 0; }
.file-preview-size { white-space: normal; overflow-wrap: anywhere; }
.editor-footer { flex-wrap: wrap; }
.editor-upload { min-width: 0; }

@media (max-width: 640px) {
    .file-preview { grid-template-columns: minmax(0, 1fr); gap: 8px; }
    .file-preview-item { gap: 10px; padding: 9px; }
    .file-preview-img { width: 76px; height: 76px; }
    .file-label { width: 100%; justify-content: center; }
    .editor-footer .btn { flex: 1 1 auto; justify-content: center; }
    .bb { min-width: 32px; height: 30px; padding: 0 8px; }
}

/* ---------- The preview of a new topic: never wider than the screen ---------- */
.preview-modal-body { overflow-x: hidden; -webkit-overflow-scrolling: touch; flex: 1 1 auto; min-height: 0; }
.preview-topic-text { max-width: 100%; }
.preview-topic-text img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }
.preview-topic-text iframe { max-width: 100%; }
.preview-topic-text .bb-media { max-width: 100%; }
.preview-topic-text .bb-code { max-width: 100%; overflow-x: auto; }
.preview-images {
    display: grid; gap: 8px; margin: 0 0 12px;
    grid-template-columns: 1fr;
}
.preview-images img {
    display: block; width: auto; max-width: 100%; max-height: 340px;
    height: auto; margin: 0 auto; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--card-alt);
}
.preview-modal-actions { flex-wrap: wrap; }

@media (max-width: 760px) {
    /* The anchors never hide behind the taller two-row mobile header. */
    .post, #comments, .comments-head { scroll-margin-top: 110px; }
    .preview-modal { padding: 0; }
    .preview-modal-window {
        width: 100%; max-width: none; height: 100%; max-height: 100dvh;
        border: 0; border-radius: 0;
    }
    .preview-modal-head {
        position: sticky; top: 0; z-index: 2; background: var(--card);
        padding: 12px 14px;
    }
    .preview-modal-head h2 { font-size: 1rem; }
    .preview-modal-body { padding: 12px 14px; }
    .preview-modal-actions { padding: 10px 14px; gap: 8px; }
    .preview-modal-actions .btn { flex: 1 1 auto; justify-content: center; }
    .preview-topic-title { font-size: 1.2rem; }
}


/* ---------- Advertising ----------
   The block is deliberately quiet: a small label, a rounded card and a
   picture that never overflows the column. The impression pixel is invisible. */
.ad-block {
    position: relative; margin: 14px 0; padding: 10px; border: 1px solid var(--border);
    border-radius: var(--radius); background: var(--card); overflow: hidden;
}
.ad-block .ad-label {
    display: inline-block; margin-bottom: 6px; padding: 1px 7px; border-radius: 10px;
    background: var(--bg-soft); color: var(--muted); font-size: .68rem;
    letter-spacing: .04em; text-transform: uppercase;
}
.ad-link { display: block; color: var(--text); }
.ad-link img, .ad-html img {
    display: block; width: 100%; height: auto; max-width: 100%; border-radius: var(--radius-sm);
}
.ad-title { display: block; margin-top: 7px; font-weight: 700; overflow-wrap: anywhere; }
.ad-html { overflow-wrap: anywhere; }
.ad-html > :first-child { margin-top: 0; }
.ad-html > :last-child { margin-bottom: 0; }
.ad-impression { position: absolute; left: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.sidebar .ad-block { margin-top: 0; }
