/* ==========================================================================
   Vexar.gr
   Dark only. Neutral near-black surfaces, one purple accent, the system font.
   Layout: top bar · side nav (full ≥1240px, icon rail 760–1239px, bottom tab bar <760px)
           · page (main column + right sidebar ≥1080px).
   Text colours meet WCAG AA on --bg / --surface.
   ========================================================================== */

:root {
    color-scheme: dark;

    --bg:            #0c0c0e;
    --bg-soft:       #121215;   /* inputs, code */
    --surface:       #17171a;   /* cards, menus */
    --surface-2:     #222226;   /* chips, buttons, hover */
    --surface-3:     #2e2e33;   /* hover on surface-2 */
    --border:        #26262b;
    --border-strong: #3a3a41;

    --text:          #dedee3;
    --text-strong:   #f7f7f8;
    --muted:         #9d9da7;
    --soft-text:     #babac3;   /* excerpts */

    --primary:       #8b47f5;
    --primary-hover: #7733e6;
    --primary-ink:   #ffffff;   /* text on primary buttons */
    --primary-soft:  rgba(139, 71, 245, .16);
    --link:          #b794ff;
    --link-hover:    #d3bfff;

    --like:          #c4a5ff;
    --dislike:       #8fb0ff;

    --success:       #4fc27a;
    --success-soft:  rgba(79, 194, 122, .12);
    --danger:        #f2555a;
    --danger-soft:   rgba(242, 85, 90, .12);
    --warning:       #f0b232;
    --warning-soft:  rgba(240, 178, 50, .12);
    --info:          #7cb0ff;
    --info-soft:     rgba(124, 176, 255, .12);

    --radius:        16px;
    --radius-md:     12px;
    --radius-sm:     8px;
    --shadow:        0 12px 32px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .4);

    /* Each system's own UI font. Not "system-ui": on some Linux setups it resolves to a CJK font with no bold. */
    --font:          -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
    --mono:          ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, "Liberation Mono", monospace;

    --topbar-h:      56px;
    --nav-w:         240px;
    --rail-w:        316px;
    --gutter:        16px;
}

/* ---------------------------------------------------------------- base */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 12px); }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 400 15px/1.5 var(--font);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    -webkit-tap-highlight-color: rgba(255, 255, 255, .06);
}

h1, h2, h3, h4, h5, h6 { color: var(--text-strong); line-height: 1.25; margin: 0 0 .5em; font-weight: 700; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3, .h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; text-underline-offset: 3px; }

:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

img, video { max-width: 100%; height: auto; display: block; }
svg { flex: none; }
.icon { width: 20px; height: 20px; }

code, pre, kbd, .mono { font-family: var(--mono); font-size: .9em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.5em 0; }
mark { background: rgba(240, 178, 50, .28); color: var(--text-strong); border-radius: 3px; padding: 0 1px; }
::selection { background: rgba(139, 71, 245, .45); color: #fff; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.lead { font-size: 1.05rem; }
.danger { color: var(--danger); }
.nowrap { white-space: nowrap; }

.sr-only {
    position: absolute !important; 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: 8px; z-index: 300;
    background: var(--primary); color: #fff; padding: 8px 14px; border-radius: var(--radius-sm);
}
.skip-link:focus { left: 8px; }

/* ---------------------------------------------------------------- buttons */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 38px; padding: 0 16px;
    border: 0; border-radius: 999px;
    background: var(--primary); color: var(--primary-ink);
    font: 600 14px/1 var(--font); white-space: nowrap;
    text-decoration: none; cursor: pointer;
    transition: background-color .12s, color .12s;
}
.btn:hover { background: var(--primary-hover); color: var(--primary-ink); text-decoration: none; }
.btn .icon { width: 18px; height: 18px; }
.btn-ghost { background: var(--surface-2); color: var(--text-strong); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text-strong); }
.btn-danger { background: transparent; color: var(--danger); box-shadow: inset 0 0 0 1px rgba(242, 85, 90, .45); }
.btn-danger:hover { background: var(--danger-soft); color: #ffb3b5; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-sm .icon { width: 16px; height: 16px; }
.btn-block { width: 100%; }
.btn:disabled, .btn[aria-disabled=true] { opacity: .45; cursor: not-allowed; }

.btn-link {
    background: none; border: 0; padding: 0; cursor: pointer;
    color: var(--link); font: inherit; text-decoration: none;
}
.btn-link:hover { color: var(--link-hover); text-decoration: underline; text-underline-offset: 3px; }
.btn-link.danger { color: var(--danger); }

.icon-btn {
    display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none;
    border: 0; border-radius: 50%; background: transparent; color: var(--text); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text-strong); }
.icon-btn .icon { width: 22px; height: 22px; }

.inline-form { display: inline; margin: 0; }

/* small round "action" buttons under posts and comments */
.action {
    position: relative; display: inline-flex; align-items: center; gap: 6px;
    height: 32px; padding: 0 12px; border: 0; border-radius: 999px;
    background: var(--surface-2); color: var(--text);
    font: 600 13px/1 var(--font); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.action:hover { background: var(--surface-3); color: var(--text-strong); text-decoration: none; }
.action .icon { width: 18px; height: 18px; }
.action-danger { background: transparent; color: var(--muted); }
.action-danger:hover { background: var(--danger-soft); color: var(--danger); }
.action-note { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; padding: 0 6px; }
.action-note .icon { width: 17px; height: 17px; }

/* ---------------------------------------------------------------- forms */

.form label { display: block; font-weight: 600; font-size: 14px; margin: 16px 0 6px; color: var(--text-strong); }
.form label:first-child, .form .muted + label, .form input[type=hidden] + label { margin-top: 0; }

input[type=text], input[type=email], input[type=password], input[type=search],
input[type=number], input[type=datetime-local], input[type=url], textarea, select {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg-soft);
    color: var(--text-strong);
    border: 1px solid #34343c;
    border-radius: 10px;
    font: inherit; font-size: 15px; line-height: 1.45;
    transition: border-color .12s, box-shadow .12s;
}
input[type=search] { -webkit-appearance: none; appearance: none; }
input[type=search]::-webkit-search-cancel-button { filter: invert(.7); }
textarea { resize: vertical; min-height: 6rem; }
input::placeholder, textarea::placeholder { color: #75757f; }
input:hover, textarea:hover, select:hover { border-color: var(--border-strong); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--link); box-shadow: 0 0 0 3px rgba(183, 148, 255, .22); }
input[type=datetime-local]::-webkit-calendar-picker-indicator { filter: invert(.8); }
input[type=checkbox], input[type=radio] { accent-color: var(--primary); width: 16px; height: 16px; vertical-align: -3px; }
input:disabled { opacity: .55; cursor: not-allowed; }

.input-lg { font-size: 1.2rem !important; font-weight: 600; }
.input-xs { width: 4.2em !important; padding: 3px 6px !important; font-size: 13px !important; }

.input-prefix { display: flex; align-items: stretch; }
.input-prefix span {
    display: flex; align-items: center; padding: 0 10px; font-size: 14px; color: var(--muted);
    background: var(--surface-2); border: 1px solid #34343c; border-right: 0;
    border-radius: 10px 0 0 10px; white-space: nowrap;
}
.input-prefix input { border-radius: 0 10px 10px 0; min-width: 0; }

.password-field { position: relative; }
.password-field input { padding-right: 64px; }
.password-field .btn-link { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 13px; font-weight: 600; }

.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.field-error { color: var(--danger); font-size: 13.5px; margin: 6px 0 0; }
.form input.invalid, .form textarea.invalid { border-color: var(--danger); }

.checkbox { display: flex !important; align-items: center; gap: 10px; font-weight: 400 !important; cursor: pointer; }
.form-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.form .btn-block { margin-top: 22px; }

.strength { height: 4px; background: var(--surface-3); border-radius: 4px; margin-top: 8px; overflow: hidden; }
.strength span { display: block; height: 100%; width: 0; background: var(--danger); transition: width .2s, background .2s; }

.search-form { display: flex; gap: 8px; align-items: center; }
.search-form input { width: 220px; padding: 6px 10px; font-size: 14px; }

.inline-field { display: flex; gap: 8px; align-items: stretch; }
.inline-field > input, .inline-field > .input-prefix { flex: 1; min-width: 0; }
.inline-field > .btn { flex: none; height: auto; min-height: 38px; }
.inline-field .code-input { max-width: 12rem; }

.code-input { font-family: var(--mono) !important; font-size: 1.35rem !important; letter-spacing: .25em; text-align: center; }

/* ---------------------------------------------------------------- cards, tags, flashes */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; font-size: 1.05rem; }

.tag {
    display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px;
    font-size: 11.5px; font-weight: 600; line-height: 1.6;
    background: var(--surface-3); color: var(--text); vertical-align: 1px; white-space: nowrap;
}
.tag-published { background: var(--success-soft); color: var(--success); }
.tag-draft     { background: var(--surface-3); color: var(--muted); }
.tag-scheduled { background: var(--info-soft); color: var(--info); }
.tag-danger    { background: var(--danger-soft); color: var(--danger); }
.tag-admin, .tag-author { background: var(--primary-soft); color: var(--like); }
.tag-user      { background: var(--surface-3); color: var(--text); }

.flash-wrap { padding-bottom: 0; }
.flashes { display: flex; flex-direction: column; gap: 8px; }
.flash {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 10px 12px; margin-bottom: 12px; border-radius: var(--radius-md);
    border: 1px solid; font-size: 14px; line-height: 1.45;
}
.flashes .flash { margin-bottom: 0; }
.flash-icon { width: 20px; height: 20px; margin-top: 0; }
.flash-text { flex: 1; min-width: 0; padding-top: 1px; overflow-wrap: anywhere; }
.flash-close {
    display: grid; place-items: center; width: 26px; height: 26px; margin: -2px -4px -2px 0; flex: none;
    border: 0; border-radius: 50%; background: transparent; color: inherit; opacity: .7; cursor: pointer;
}
.flash-close:hover { opacity: 1; background: rgba(255, 255, 255, .08); }
.flash-close .icon { width: 16px; height: 16px; }
.flash-success { background: var(--success-soft); border-color: rgba(79, 194, 122, .35); color: #c6efd4; }
.flash-success .flash-icon { color: var(--success); }
.flash-error   { background: var(--danger-soft);  border-color: rgba(242, 85, 90, .4); color: #ffc9ca; }
.flash-error .flash-icon { color: var(--danger); }
.flash-info    { background: var(--primary-soft); border-color: rgba(139, 71, 245, .4); color: #e2d6ff; }
.flash-info .flash-icon { color: var(--link); }
.flash-warning { background: var(--warning-soft); border-color: rgba(240, 178, 50, .4);  color: #fbe2ad; }
.flash-warning .flash-icon { color: var(--warning); }

.verify-prompt { display: flex; gap: 12px; align-items: flex-start; }
.verify-prompt p { margin: 0 0 10px; }
.verify-prompt strong { overflow-wrap: anywhere; }
.verify-icon { width: 24px; height: 24px; color: var(--warning); margin-top: 1px; }

.empty-state { text-align: center; padding: 48px 16px; color: var(--text); }
.empty-state p { margin: 0 0 4px; }
.empty-state.compact { padding: 20px 8px; }
.empty-icon {
    display: block; margin: 0 auto 14px; width: 64px; height: 64px; padding: 16px;
    border-radius: 50%; background: var(--surface-2); color: var(--muted);
}
.empty-actions { margin-top: 16px !important; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

.note {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 12px; padding: 8px 12px;
    font-size: 13.5px; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
}
.note .icon { width: 16px; height: 16px; }

/* ---------------------------------------------------------------- avatars */

.avatar {
    display: inline-grid; place-items: center; flex: none;
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--surface-3); color: #fff;
    font: 600 14px/1 var(--font); user-select: none;
}
.avatar-xs { width: 22px; height: 22px; font-size: 11px; }
.avatar-sm { width: 28px; height: 28px; font-size: 13px; }
.avatar-md { width: 40px; height: 40px; font-size: 17px; }
.avatar-lg { width: 64px; height: 64px; font-size: 27px; }
.avatar-xl { width: 96px; height: 96px; font-size: 40px; }

/* one colour per person (avatar_hue()), also used for their banner */
.av-0 { background-color: #c2410c; }
.av-1 { background-color: #b91c1c; }
.av-2 { background-color: #be185d; }
.av-3 { background-color: #7e22ce; }
.av-4 { background-color: #4338ca; }
.av-5 { background-color: #0369a1; }
.av-6 { background-color: #0f766e; }
.av-7 { background-color: #15803d; }
.av-8 { background-color: #a16207; }
.av-9 { background-color: #475569; }

/* ==========================================================================
   Shell: top bar, side nav, tab bar
   ========================================================================== */

.topbar {
    position: sticky; top: 0; z-index: 60;
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 16px;
    height: var(--topbar-h); padding: 0 16px;
    background: var(--bg); border-bottom: 1px solid var(--border);
}

.brand {
    display: inline-flex; align-items: center; gap: 8px;
    color: var(--text-strong); text-decoration: none;
    font-weight: 800; font-size: 21px; letter-spacing: -.02em; line-height: 1;
}
.brand:hover { color: var(--text-strong); text-decoration: none; }
.logo-mark { display: block; }
.brand-name { padding-bottom: 2px; }
.brand small { color: var(--muted); font-weight: 500; font-size: 13px; letter-spacing: 0; margin-left: 2px; }

.topbar-search { position: relative; justify-self: center; width: 100%; max-width: 560px; }
.topbar-search input {
    height: 40px; padding: 0 40px 0 42px; border-radius: 999px;
    background: var(--surface-2); border-color: transparent; font-size: 15px;
}
.topbar-search input:hover { border-color: var(--border-strong); }
.topbar-search input:focus { background: var(--bg-soft); }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-key {
    position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
    min-width: 20px; padding: 1px 6px; border: 1px solid var(--border-strong); border-radius: 5px;
    color: var(--muted); font-size: 12px; text-align: center; pointer-events: none;
}
.topbar-search input:focus ~ .search-key, .topbar-search input:not(:placeholder-shown) ~ .search-key { display: none; }

.topbar-actions { display: flex; align-items: center; gap: 8px; justify-self: end; }
.search-link { display: none; }

/* account menu: a <details>, so it works without JS; app.js closes it on outside clicks */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.account-btn {
    position: relative; display: flex; align-items: center; gap: 4px;
    padding: 4px 6px 4px 4px; border-radius: 999px;
}
.account-btn:hover, .menu[open] .account-btn { background: var(--surface-2); }
.account-btn .chev { width: 16px; height: 16px; color: var(--muted); transition: transform .15s; }
.menu[open] .chev { transform: rotate(180deg); }
.account-btn .dot {
    position: absolute; left: 25px; top: 3px; width: 10px; height: 10px; border-radius: 50%;
    background: var(--primary); box-shadow: 0 0 0 2px var(--bg);
}
.menu-panel {
    position: absolute; right: 0; top: calc(100% + 8px); z-index: 80; width: 270px;
    padding: 6px; background: var(--surface); border: 1px solid var(--border-strong);
    border-radius: 14px; box-shadow: var(--shadow);
}
.menu-panel hr { margin: 6px 4px; }
.menu-panel form { margin: 0; }
.menu-head {
    display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px;
    color: var(--text); text-decoration: none; margin-bottom: 4px;
}
.menu-head:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.menu-head strong { display: block; color: var(--text-strong); overflow-wrap: anywhere; }
.menu-head .small { display: block; }
.menu-item {
    display: flex; align-items: center; gap: 12px; width: 100%;
    padding: 9px 10px; border: 0; border-radius: 8px; background: none;
    color: var(--text); font: 500 14px/1.3 var(--font); text-align: left; text-decoration: none; cursor: pointer;
}
.menu-item:hover { background: var(--surface-2); color: var(--text-strong); text-decoration: none; }
.menu-item .icon { color: var(--muted); }

.badge {
    display: inline-grid; place-items: center; min-width: 19px; height: 19px; padding: 0 6px; margin-left: auto;
    border-radius: 999px; background: var(--primary); color: #fff; font-size: 11px; font-weight: 700; line-height: 1;
}

.shell { display: flex; align-items: flex-start; min-height: calc(100vh - var(--topbar-h)); }

.sidenav {
    position: sticky; top: var(--topbar-h); flex: none;
    width: var(--nav-w); height: calc(100vh - var(--topbar-h)); overflow-y: auto;
    padding: 12px 12px 24px; border-right: 1px solid var(--border);
    display: flex; flex-direction: column; gap: 12px;
    scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent;
}
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group + .nav-group, .nav-join { padding-top: 12px; border-top: 1px solid var(--border); }
.nav-heading { margin: 0; padding: 4px 12px 6px; color: var(--muted); font-size: 12px; font-weight: 600; }
.nav-item {
    position: relative; display: flex; align-items: center; gap: 14px;
    height: 42px; padding: 0 12px; border-radius: 10px;
    color: var(--text); font-size: 14.5px; font-weight: 500; text-decoration: none;
}
.nav-item:hover { background: var(--surface-2); color: var(--text-strong); text-decoration: none; }
.nav-item.active { background: var(--surface-2); color: var(--text-strong); font-weight: 600; }
.nav-item.active .icon { color: var(--like); }
.nav-item .icon { width: 22px; height: 22px; }
.nav-join { padding: 14px 8px 0; font-size: 13.5px; color: var(--muted); }
.nav-join p { margin: 0 4px 12px; }
.nav-join .btn + .btn { margin-top: 8px; }

.main { flex: 1; min-width: 0; padding-bottom: 24px; }

.site-foot {
    display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: center;
    max-width: 1100px; margin: 32px auto 0; padding: 16px 24px; color: var(--muted); font-size: 13px;
}
.site-foot a { color: var(--muted); }
.site-foot a:hover { color: var(--text); }

.tabbar { display: none; }

/* ==========================================================================
   Pages
   ========================================================================== */

.page { max-width: 1100px; margin: 0 auto; padding: 20px 24px 0; }
.page-narrow { max-width: 740px; }
.page-auth { max-width: 460px; padding-top: 40px; }

.with-rail { display: grid; grid-template-columns: minmax(0, 1fr) var(--rail-w); gap: 24px; align-items: start; }
.page-main { min-width: 0; }
.page-rail { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.page-rail .card + .card { margin-top: 0; }

.page-head { margin-bottom: 16px; }
.page-head h1 { margin: 0 0 4px; }
.page-head p { margin: 0; }
.page-head-back { display: flex; align-items: center; gap: 12px; }
.back-btn { background: var(--surface-2); }
.back-btn:hover { background: var(--surface-3); }

/* the in-page search on /posts (phones: the top bar has no search box there) */
.page-search { display: none; position: relative; gap: 8px; margin-bottom: 14px; }
.page-search input { height: 40px; border-radius: 999px; padding-left: 40px; }
.page-search .search-icon { left: 13px; }
.page-search .btn { height: 40px; }

/* chips (sorting) */
.chips { display: flex; gap: 8px; margin: 0 0 12px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
    display: inline-flex; align-items: center; flex: none; height: 32px; padding: 0 12px;
    border-radius: 8px; background: var(--surface-2); color: var(--text);
    font-size: 14px; font-weight: 500; text-decoration: none; white-space: nowrap;
}
.chip:hover { background: var(--surface-3); color: var(--text-strong); text-decoration: none; }
.chip.active { background: var(--text-strong); color: var(--bg); }
.chip { gap: 6px; }
.chip .icon { width: 16px; height: 16px; }
.chip-count { font-size: 12.5px; opacity: .65; }

/* "Pinned" label on pinned posts (feed byline, post page, /posts rows) */
.pinned-badge {
    display: inline-flex; align-items: center; gap: 4px;
    color: var(--like); font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.pinned-badge .icon { width: 15px; height: 15px; }
.byline .pinned-badge { margin-left: auto; }
.row-meta .pinned-badge { margin-left: 8px; vertical-align: -2px; }
.pin-option { margin-top: 18px !important; }
.pin-option span { display: inline-flex; align-items: center; gap: 6px; }
.pin-option .icon { width: 16px; height: 16px; color: var(--like); }
.chips-sm { margin: 0; }
.chips-sm .chip { height: 28px; font-size: 13px; padding: 0 10px; }

/* ---------------------------------------------------------------- home: channel header */

.channel { padding-bottom: 4px; }
.channel-banner {
    height: clamp(96px, 15vw, 180px); border-radius: var(--radius); overflow: hidden; background: #1d1336;
}
.channel-banner img { width: 100%; height: 100%; object-fit: cover; }
.channel-head { display: flex; align-items: center; gap: 20px; padding: 18px 0 8px; }
.channel-avatar { flex: none; }
.channel-info { min-width: 0; }
.channel-info h1 { font-size: 32px; font-weight: 800; letter-spacing: -.01em; margin: 0 0 4px; }
.channel-meta { margin: 0; color: var(--muted); font-size: 14px; }
.channel-meta span + span::before { content: "·"; margin: 0 7px; }
.channel-host { color: var(--text); font-weight: 600; }
.channel-tagline { margin: 6px 0 0; color: var(--text); max-width: 62ch; }
.channel-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

/* ---------------------------------------------------------------- home: feed */

.feed { display: flex; flex-direction: column; }
.feed-post { position: relative; padding: 12px 16px 14px; border-radius: var(--radius); }
.feed-post + .feed-post { margin-top: 1px; }
.feed-post + .feed-post::before {
    content: ""; position: absolute; top: -1px; left: 16px; right: 16px; height: 1px; background: var(--border);
}
.feed-post:hover { background: #131316; }
.feed-post:hover::before, .feed-post:hover + .feed-post::before { opacity: 0; }

.byline { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 13px; color: var(--muted); }
.byline-who { display: inline-flex; align-items: center; gap: 7px; color: var(--text); text-decoration: none; }
.byline-who strong { font-weight: 600; }
.byline-who:hover { color: var(--text-strong); text-decoration: none; }
.byline-who:hover strong { text-decoration: underline; text-underline-offset: 3px; }
.sep { color: var(--muted); }

.feed-title { margin: 8px 0 4px; font-size: 18px; font-weight: 600; line-height: 1.35; }
.feed-title a { color: var(--text-strong); text-decoration: none; }
.feed-title a:hover { text-decoration: none; }
.feed-post:hover .feed-title a { color: #fff; }
.feed-excerpt {
    margin: 0; color: var(--soft-text); font-size: 14.5px; line-height: 1.5;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

/* the title link covers the whole card; real links and buttons sit above it */
.stretched::after { content: ""; position: absolute; inset: 0; z-index: 0; border-radius: inherit; }
.feed-post .byline-who, .feed-post .mosaic, .feed-post .feed-video, .feed-post .post-actions > *,
.post-row .row-thumb { position: relative; z-index: 1; }

.feed-video { margin-top: 10px; border-radius: 14px; overflow: hidden; background: #000; border: 1px solid var(--border); }
.feed-video video { width: 100%; max-height: 520px; }

.post-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* ---------------------------------------------------------------- photos: feed mosaic, post gallery, wall */

.mosaic, .gallery {
    display: grid; gap: 3px; margin-top: 12px;
    border-radius: 14px; overflow: hidden; border: 1px solid var(--border); background: var(--border);
}
.tile { position: relative; display: block; overflow: hidden; background: var(--surface-2); min-height: 0; }
.tile img { width: 100%; height: 100%; object-fit: cover; }
.tile:hover img { filter: brightness(1.06); }

/* one photo: shown whole, with a blurred copy filling the sides (like Reddit) */
.mosaic-1 .tile, .gallery-1 .tile { display: flex; justify-content: center; background: #000; }
.mosaic-1 .tile img:not(.tile-blur), .gallery-1 .tile img:not(.tile-blur) {
    position: relative; width: auto; height: auto; max-width: 100%; max-height: 540px; object-fit: contain;
}
.gallery-1 .tile img:not(.tile-blur) { max-height: 78vh; }
.tile-blur { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: blur(28px) brightness(.45); transform: scale(1.15); }
.tile:hover .tile-blur { filter: blur(28px) brightness(.45); }

.mosaic-2 { grid-template-columns: 1fr 1fr; height: 320px; }
.mosaic-3 { grid-template-columns: 1.4fr 1fr; grid-template-rows: 1fr 1fr; height: 380px; }
.mosaic-3 .tile:first-child { grid-row: span 2; }
.mosaic-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; height: 420px; }
.tile-more {
    position: absolute; inset: 0; display: grid; place-items: center;
    background: rgba(0, 0, 0, .55); color: #fff; font-size: 30px; font-weight: 700;
}

.gallery { margin-top: 20px; }
.gallery-2 { grid-template-columns: 1fr 1fr; }
.gallery-2 .tile { aspect-ratio: 4 / 5; }
.gallery-3 { grid-template-columns: 1.4fr 1fr; grid-template-rows: 1fr 1fr; height: 460px; }
.gallery-3 .tile:first-child { grid-row: span 2; }
.gallery-4 { grid-template-columns: 1fr 1fr; }
.gallery-4 .tile { aspect-ratio: 1; }
.gallery-5 { grid-template-columns: repeat(3, 1fr); }
.gallery-5 .tile { aspect-ratio: 1; }
.gallery-5 .tile:first-child { grid-column: 1 / -1; aspect-ratio: 16 / 9; }
.tile-caption {
    position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 10px 7px; z-index: 1;
    background: linear-gradient(transparent, rgba(0, 0, 0, .72)); color: #fff; font-size: 12.5px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.photo-wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 4px; }
.photo-wall .tile { aspect-ratio: 1; border-radius: 6px; }
.photo-wall .tile-caption { opacity: 0; transition: opacity .15s; }
.photo-wall .tile:hover .tile-caption, .photo-wall .tile:focus-visible .tile-caption { opacity: 1; }

/* ---------------------------------------------------------------- /posts: compact rows */

.post-rows { display: flex; flex-direction: column; gap: 4px; }
.post-row { position: relative; display: flex; gap: 16px; padding: 8px; border-radius: var(--radius); }
.post-row:hover { background: #131316; }
.row-thumb {
    position: relative; flex: none; width: 240px; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden;
    background: var(--surface-2); display: grid; place-items: center;
}
.row-thumb img { width: 100%; height: 100%; object-fit: cover; }
/* text-only posts: a tiny preview of the page instead of a picture */
.thumb-text {
    position: absolute; inset: 0; display: block; padding: 12px 14px; overflow: hidden; text-align: left;
    background: var(--surface-2); color: #8e8e98; font-size: 11px; line-height: 1.45;
    -webkit-mask-image: linear-gradient(#000 55%, transparent); mask-image: linear-gradient(#000 55%, transparent);
}
.thumb-text strong { display: block; margin-bottom: 4px; color: var(--text); font-size: 12.5px; line-height: 1.3; }
.thumb-badge {
    position: absolute; right: 6px; bottom: 6px; display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 6px; border-radius: 6px; background: rgba(0, 0, 0, .78); color: #fff; font-size: 12px; font-weight: 600;
}
.thumb-badge .icon { width: 14px; height: 14px; }
.row-body { min-width: 0; padding-top: 2px; }
.row-title { margin: 0 0 4px; font-size: 17px; font-weight: 600; line-height: 1.35; }
.row-title a { color: var(--text-strong); text-decoration: none; }
.row-title a:hover { text-decoration: none; }
.row-meta { margin: 0 0 6px; color: var(--muted); font-size: 13px; }
.row-excerpt {
    margin: 0; color: var(--soft-text); font-size: 14px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* ---------------------------------------------------------------- pagination */

.pagination { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 24px 0 8px; flex-wrap: wrap; }
.page-numbers { display: flex; align-items: center; gap: 4px; }
.page-step, .page-num {
    display: inline-grid; place-items: center; height: 36px; border-radius: 999px;
    color: var(--text); font-size: 14px; font-weight: 600; text-decoration: none;
}
.page-step { padding: 0 14px; background: var(--surface-2); }
.page-num { min-width: 36px; padding: 0 8px; }
a.page-step:hover, a.page-num:hover { background: var(--surface-3); color: var(--text-strong); text-decoration: none; }
.page-step[aria-disabled=true] { opacity: .4; }
.page-num.current { background: var(--text-strong); color: var(--bg); }
.page-gap { color: var(--muted); padding: 0 2px; }

/* ---------------------------------------------------------------- single post */

.post-full { padding: 4px 0 8px; }
.post-top { display: flex; align-items: center; gap: 12px; }
.post-top .byline { flex: 1; min-width: 0; font-size: 13.5px; }
.post-top .byline-who strong { font-size: 14px; }
.post-title { margin: 16px 0 12px; font-size: 28px; font-weight: 700; line-height: 1.25; letter-spacing: -.005em; }

.prose { font-size: 16px; line-height: 1.7; color: #d8d8de; overflow-wrap: anywhere; }
.prose > * { margin: 0; }
.prose > * + * { margin-top: 1em; }
.prose > h1, .prose > h2, .prose > h3, .prose > h4 { margin-top: 1.6em; margin-bottom: -.3em; }
.prose h2 { font-size: 1.3rem; }
.prose h3 { font-size: 1.12rem; }
.prose strong { color: var(--text-strong); }
.prose a { text-decoration: underline; text-decoration-color: rgba(183, 148, 255, .45); text-underline-offset: 3px; }
.prose a:hover { text-decoration-color: currentColor; }
.prose ul, .prose ol { padding-left: 1.5em; }
.prose li + li { margin-top: .3em; }
.prose li::marker { color: var(--muted); }
.prose blockquote {
    margin-left: 0; margin-right: 0; padding: 2px 0 2px 16px;
    border-left: 3px solid var(--border-strong); color: var(--soft-text);
}
.prose code { background: var(--surface-2); padding: .12em .4em; border-radius: 5px; color: #ece6ff; }
.prose pre { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; overflow-x: auto; line-height: 1.55; }
.prose pre code { background: none; padding: 0; color: #e7e7ec; }
.prose img { border-radius: 12px; margin: .5em 0; }
.prose hr { margin: 2em 0; }

.post-videos { margin-top: 20px; display: grid; gap: 16px; }
.video-figure { margin: 0; }
.video-figure video { width: 100%; border-radius: 14px; background: #000; }
figcaption { color: var(--muted); font-size: 13.5px; margin-top: 8px; }

/* ---------------------------------------------------------------- comments */

.comments { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border); }

.compose {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 12px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface);
}
.compose:focus-within { border-color: #4a4a53; }
.compose-main { flex: 1; min-width: 0; }
.compose textarea {
    min-height: 44px; padding: 8px 2px; border: 0; background: transparent; resize: none; box-shadow: none !important;
    font-size: 15px;
}
.compose textarea:focus { min-height: 88px; }
.compose-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.compose-note { display: block; }
.compose-guest { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.compose-guest p { margin: 0; }
.compose-buttons { display: flex; gap: 8px; }

.comments-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 22px 0 6px; }
.comments-bar h2 { margin: 0; font-size: 16px; }
.comments-empty { display: flex; align-items: center; gap: 8px; padding: 12px 0; }

.comment-list { list-style: none; margin: 0; padding: 0; }
.comment { display: flex; gap: 12px; padding: 12px 8px; border-radius: 12px; }
.comment:target { background: var(--primary-soft); }
.comment-avatar { flex: none; text-decoration: none; padding-top: 1px; }
.comment-main { flex: 1; min-width: 0; }
.comment-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 13px; color: var(--muted); }
.comment-author { display: inline-flex; align-items: baseline; gap: 6px; min-width: 0; color: var(--text-strong); text-decoration: none; }
.comment-author strong { font-size: 13.5px; font-weight: 600; overflow-wrap: anywhere; }
.comment-author .small { font-size: 12.5px; }
a.comment-author:hover { text-decoration: none; }
a.comment-author:hover strong { text-decoration: underline; text-underline-offset: 3px; }
.comment-body { margin: 3px 0 8px; color: var(--text); font-size: 15px; line-height: 1.55; overflow-wrap: anywhere; }
.comment-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.votes { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0; }
.vote-group { display: inline-flex; align-items: center; height: 30px; border-radius: 999px; background: var(--surface-2); }
.vote-btn {
    display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 10px;
    border: 0; border-radius: 999px; background: transparent; color: var(--muted);
    font: 600 13px/1 var(--font); font-variant-numeric: tabular-nums;
}
.vote-btn .icon { width: 17px; height: 17px; }
.vote-btn + .vote-btn { position: relative; }
.vote-btn + .vote-btn::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 1px; background: var(--border-strong); }
button.vote-btn { cursor: pointer; }
button.vote-btn:hover { background: var(--surface-3); color: var(--text-strong); }
button.vote-btn:hover::before, button.vote-btn:hover + .vote-btn::before { opacity: 0; }
.vote-up.active   { color: var(--like); }
.vote-down.active { color: var(--dislike); }
.vote-btn.active .icon { fill: currentColor; }
.votes.busy { opacity: .6; }
.vote-msg { color: var(--danger); }

/* ---------------------------------------------------------------- sidebar cards */

.rail-card { padding: 0; overflow: hidden; }
.rail-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 14px 16px 6px; }
.rail-head h2 { margin: 0; font-size: 14px; font-weight: 700; }
.rail-body { padding: 6px 16px 16px; }

.about-banner { height: 64px; overflow: hidden; background: #1d1336; }
.about-banner img { width: 100%; height: 100%; object-fit: cover; }
.about-card .rail-body { padding-top: 0; }
.about-id { display: block; margin-top: -22px; color: var(--text-strong); text-decoration: none; }
.about-id:hover { text-decoration: none; color: var(--text-strong); }
.about-avatar { display: block; margin-bottom: 8px; border-radius: 50%; box-shadow: 0 0 0 3px var(--surface); background: var(--surface); }
.about-id strong { display: block; font-size: 16px; line-height: 1.3; }
.about-id .small { display: block; }
.about-tagline { margin: 10px 0 0; font-size: 14px; }
.about-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 10px; }
.about-stats div { display: flex; flex-direction: column-reverse; }
.about-stats dt { color: var(--muted); font-size: 12.5px; }
.about-stats dd { margin: 0; color: var(--text-strong); font-weight: 700; font-size: 16px; }
.about-since { display: flex; align-items: center; gap: 6px; margin: 0 0 14px; }
.about-since .icon { width: 16px; height: 16px; }

.rail-photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 6px 16px 16px; }
.rail-photos a { display: block; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.rail-photos img { width: 100%; height: 100%; object-fit: cover; }
.rail-photos a:hover img { filter: brightness(1.1); }

.rail-comments, .rail-posts, .rail-notes { list-style: none; margin: 0; padding: 0 8px 10px; }
.rail-comment, .rail-posts a {
    display: flex; gap: 10px; padding: 8px; border-radius: 10px; color: var(--text); text-decoration: none;
}
.rail-comment:hover, .rail-posts a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.rail-comment .avatar { margin-top: 1px; }
.rail-comment > span:last-child, .rail-post-text { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.rail-comment-who { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-comment-who strong { color: var(--text); font-weight: 600; }
.rail-comment-text {
    font-size: 14px; color: var(--text);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.rail-thumb {
    flex: none; width: 92px; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden;
    background: var(--surface-2); display: grid; place-items: center; color: var(--muted);
}
.rail-thumb img { width: 100%; height: 100%; object-fit: cover; }
.rail-post-title {
    font-size: 14px; font-weight: 600; color: var(--text-strong); line-height: 1.35;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.rail-notes { padding: 4px 16px 14px; }
.rail-notes li { display: flex; gap: 10px; margin: 8px 0; font-size: 14px; }
.rail-notes .icon { color: var(--muted); margin-top: 1px; }

.stat-pairs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
.stat-pairs div { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.stat-pairs dt { color: var(--muted); font-size: 12.5px; }
.stat-pairs dd { margin: 0; color: var(--text-strong); font-weight: 700; font-size: 18px; }
.stat-foot { margin: 12px 0 0; }
.karma-big { display: flex; align-items: baseline; gap: 8px; margin: 0 0 12px; }
.karma-big .stat-value { font-size: 34px; font-weight: 800; line-height: 1; color: var(--text-strong); }
.karma.positive { color: var(--success) !important; }
.karma.negative { color: var(--danger) !important; }

/* ---------------------------------------------------------------- profiles */

.user-head { margin-bottom: 4px; }
.user-banner {
    height: 120px; border-radius: var(--radius);
    background-image: linear-gradient(rgba(12, 12, 14, .15), rgba(12, 12, 14, .55));
}
.user-id { display: flex; align-items: flex-end; gap: 16px; margin-top: -40px; padding: 0 16px; flex-wrap: wrap; }
.user-id .avatar-xl { box-shadow: 0 0 0 5px var(--bg); }
.user-names { flex: 1; min-width: 12rem; padding-bottom: 2px; }
.user-names h1 { margin: 0; font-size: 26px; overflow-wrap: anywhere; }
.user-names h1 .tag { vertical-align: 5px; }
.user-names p { margin: 2px 0 0; }
.user-id .btn { margin-bottom: 6px; }

.tabs-line { display: flex; gap: 22px; margin: 20px 0 10px; border-bottom: 1px solid var(--border); }
.tabs-line > * {
    padding: 10px 2px; margin-bottom: -1px; border-bottom: 2px solid transparent;
    color: var(--muted); font-size: 14.5px; font-weight: 600; text-decoration: none;
}
.tabs-line .active { color: var(--text-strong); border-bottom-color: var(--text-strong); }
.tabs-line .count { color: var(--muted); font-weight: 500; margin-left: 4px; }

.activity-list { list-style: none; margin: 0; padding: 0; }
.activity { padding: 12px 4px; border-bottom: 1px solid var(--border); }
.activity-where { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 0 0 4px; }
.activity-where .icon { width: 16px; height: 16px; }
.activity-where a { color: var(--text); font-weight: 600; }
.activity-body { display: block; color: var(--text); text-decoration: none; overflow-wrap: anywhere; }
.activity-body:hover { color: var(--text-strong); text-decoration: none; }

.profile-comments { list-style: none; margin: 0; padding: 0; }
.profile-comments li { display: flex; flex-direction: column; gap: 2px; padding: 10px 0; border-top: 1px solid var(--border); }
.profile-comments li:first-child { border-top: 0; padding-top: 0; }
.profile-comments a { color: var(--text); overflow-wrap: anywhere; }
.profile-comments a:hover { color: var(--text-strong); }
.profile-comments.compact li { padding: 7px 0; }
.profile-comments.compact a { font-size: 14px; }

/* the popover card (Discord-like: colour banner, avatar overlapping it) */
.profile-pop {
    position: absolute; z-index: 150; width: 330px; max-width: calc(100vw - 16px); max-height: 75vh; overflow-y: auto;
    padding: 0; background: var(--surface); border: 1px solid var(--border-strong);
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.profile-pop.sheet { position: fixed; left: 8px; right: 8px; top: auto; bottom: 8px; width: auto; max-width: none; }
.profile-pop > [data-profile-pop-body] > p { padding: 16px; margin: 0; }
.profile-pop-close {
    position: absolute; top: 8px; right: 8px; z-index: 2; display: grid; place-items: center;
    width: 30px; height: 30px; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .45); color: #fff; cursor: pointer;
}
.profile-pop-close:hover { background: rgba(0, 0, 0, .7); }
.profile-pop-close .icon { width: 16px; height: 16px; }
.pc-banner { height: 64px; background-image: linear-gradient(rgba(12, 12, 14, .1), rgba(12, 12, 14, .45)); }
.pc-head { padding: 0 16px; margin-top: -32px; }
.pc-head .avatar { box-shadow: 0 0 0 4px var(--surface); }
.pc-names { padding: 8px 16px 0; }
.profile-card-name { color: var(--text-strong); font-size: 18px; overflow-wrap: anywhere; }
.pc-names .tag { margin-left: 4px; vertical-align: 2px; }
.profile-card-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 12px 16px 8px; }
.profile-card-stats div { padding: 8px 6px; text-align: center; background: var(--surface-2); border-radius: 10px; }
.profile-card-stats dt { color: var(--muted); font-size: 11.5px; }
.profile-card-stats dd { margin: 0; color: var(--text-strong); font-weight: 700; font-size: 15px; white-space: nowrap; }
.profile-card-votes { margin: 0 16px 12px; }
.profile-card-private {
    display: flex; gap: 8px; align-items: center; margin: 0 16px 4px; padding: 8px 10px;
    border-radius: 10px; background: var(--surface-2); color: var(--muted); font-size: 13px;
}
.profile-card-private .icon { width: 16px; height: 16px; }
.pc-label { margin: 0 16px 4px; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.profile-card .profile-comments { margin: 0 16px; }
.pc-empty { margin: 0 16px; }
.pc-full { display: flex; margin: 12px 16px 16px; width: calc(100% - 32px); }
.profile-card-own { margin: -6px 16px 14px; }

/* ---------------------------------------------------------------- settings */

.settings-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.settings-who { flex: 1; min-width: 12rem; }
.settings-who h1 { margin: 0; }
.settings-who p { margin: 2px 0 0; overflow-wrap: anywhere; }
.settings-card h2 { font-size: 17px; margin: 0 0 14px; }
.settings-card .card-head h2 { margin: 0; }
.settings-card .form + .form { margin-top: 20px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.setting-row p { margin: 3px 0 0; }

.profile-kv { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.profile-kv .hint { display: block; }
.profile-verify { margin-top: 16px; padding: 12px; border-radius: 12px; background: var(--warning-soft); }

.switch-form { margin: 0; flex: none; }
.switch {
    display: inline-flex; align-items: center; gap: 10px; padding: 0; border: 0; background: none;
    color: var(--text); font: 600 13px/1.3 var(--font); cursor: pointer;
}
.switch-track {
    position: relative; flex: none; width: 40px; height: 24px; border-radius: 999px;
    background: var(--surface-3); transition: background .15s;
}
.switch-thumb {
    position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
    background: #a5a5ae; transition: transform .15s, background .15s;
}
.switch:hover .switch-track { background: #3a3a41; }
.switch[aria-checked=true] .switch-track { background: var(--primary); }
.switch[aria-checked=true] .switch-thumb { transform: translateX(16px); background: #fff; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

.security-rows { margin: 16px 0; border: 1px solid var(--border); border-radius: 12px; }
.security-row { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; padding: 14px 16px; }
.security-row + .security-row { border-top: 1px solid var(--border); }
.security-row > div:first-child { flex: 1; min-width: 14rem; }
.security-row p { margin: 3px 0 0; }
.confirm-details > summary { list-style: none; cursor: pointer; display: inline-flex; }
.confirm-details > summary::-webkit-details-marker { display: none; }
.confirm-details[open] { flex-basis: 100%; }
.confirm-details[open] > summary { margin-bottom: 8px; }
.confirm-form { max-width: 340px; }
.confirm-form .btn { margin-top: 12px; }

/* ---------------------------------------------------------------- contact */

.compose-card { padding: 20px; }
.msg-people { margin: 0 0 18px; border: 1px solid var(--border); border-radius: 12px; }
.msg-people p { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0; padding: 10px 12px; font-size: 14px; }
.msg-people p + p { border-top: 1px solid var(--border); }
.msg-people strong { color: var(--text-strong); }
.msg-label { width: 44px; color: var(--muted); font-size: 13px; }

/* ---------------------------------------------------------------- auth */

.auth-card { padding: 28px; border-radius: 20px; }
.auth-logo { display: inline-block; margin-bottom: 14px; }
.auth-card h1 { font-size: 24px; margin-bottom: 4px; }
.auth-card > p.muted { margin-bottom: 20px; }
.auth-alt { text-align: center; margin: 20px 0 0; font-size: 14px; }
.twofa-alt { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); }
.twofa-alt p { width: 100%; margin: 0; }
.twofa-alt form:last-child { margin-left: auto; }

/* authenticator setup */
.steps { margin: 0 0 20px; padding-left: 22px; }
.steps > li { padding-left: 6px; }
.steps > li + li { margin-top: 24px; }
.steps > li::marker { color: var(--link); font-weight: 700; }
.steps p { margin: 3px 0 0; }
.qr-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 22px; margin-top: 12px; }
.qr { flex: none; line-height: 0; }
.qr svg { display: block; width: 200px; height: 200px; border-radius: 10px; }   /* white quiet zone comes from the SVG */
.qr-manual { flex: 1; min-width: 14rem; }
.secret-key {
    display: block; margin: 8px 0; padding: 10px 12px; color: var(--text-strong); font-size: 15px; letter-spacing: .05em;
    background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px; overflow-wrap: anywhere; user-select: all;
}
.totp-setup .form { margin-top: 10px; }

.error-page { padding-top: 64px; text-align: center; }
.error-code { margin: 0 0 4px; font-size: 76px; font-weight: 800; line-height: 1; color: var(--surface-3); letter-spacing: -.02em; }
.error-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 20px; }

/* ---------------------------------------------------------------- lightbox */

.lightbox {
    position: fixed; inset: 0; z-index: 200; background: rgba(0, 0, 0, .94);
    display: flex; align-items: center; justify-content: center; padding: 64px 76px 32px;
}
.lightbox-bar {
    position: absolute; top: 0; left: 0; right: 0; height: 60px;
    display: flex; align-items: center; gap: 10px; padding: 0 12px 0 20px; color: #fff;
}
.lightbox-count { margin-right: auto; color: #bdbdc5; font-size: 14px; font-variant-numeric: tabular-nums; }
.lightbox-post {
    display: inline-flex; align-items: center; height: 36px; padding: 0 14px; border-radius: 999px;
    background: rgba(255, 255, 255, .12); color: #fff; font-size: 14px; font-weight: 600; max-width: 50vw;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lightbox-post:hover { background: rgba(255, 255, 255, .2); color: #fff; text-decoration: none; }
.lightbox figure { margin: 0; max-width: 100%; max-height: 100%; display: flex; flex-direction: column; align-items: center; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 130px); object-fit: contain; border-radius: 4px; }
.lightbox figcaption { color: #cfcfd6; text-align: center; }
.lightbox-close, .lightbox-nav {
    display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%;
    background: rgba(255, 255, 255, .12); color: #fff; cursor: pointer; font-size: 30px; line-height: 1;
}
.lightbox-close:hover, .lightbox-nav:hover { background: rgba(255, 255, 255, .24); }
.lightbox-nav { position: absolute; top: 50%; transform: translateY(-50%); padding-bottom: 4px; }
.lightbox-nav.prev { left: 16px; }
.lightbox-nav.next { right: 16px; }
body.no-scroll { overflow: hidden; }

/* ==========================================================================
   Admin
   ========================================================================== */

.admin-shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.admin-sidebar {
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
    background: var(--bg); border-right: 1px solid var(--border);
    padding: 14px 12px; display: flex; flex-direction: column; gap: 18px;
}
.admin-sidebar .brand { padding: 2px 8px; font-size: 19px; }
.admin-nav { display: flex; flex-direction: column; gap: 2px; }
.admin-nav a {
    display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 12px; border-radius: 10px;
    color: var(--text); text-decoration: none; font-size: 14.5px; font-weight: 500;
}
.admin-nav a:hover { background: var(--surface-2); color: var(--text-strong); text-decoration: none; }
.admin-nav a.active { background: var(--surface-2); color: var(--text-strong); font-weight: 600; }
.admin-nav a.active .icon { color: var(--like); }
.admin-sidebar-foot { margin-top: auto; padding: 0 4px; font-size: 14px; }
.admin-sidebar-foot a { display: flex; align-items: center; gap: 8px; color: var(--muted); padding: 8px; border-radius: 8px; }
.admin-sidebar-foot a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.admin-sidebar-foot .icon { width: 18px; height: 18px; }

.admin-main { min-width: 0; display: flex; flex-direction: column; }
.admin-topbar {
    position: sticky; top: 0; z-index: 40;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    height: 60px; padding: 0 24px; background: var(--bg); border-bottom: 1px solid var(--border);
}
.admin-user { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.admin-user > a { display: inline-flex; align-items: center; gap: 8px; color: var(--text); }
.admin-user > a:hover { text-decoration: none; color: var(--text-strong); }
.admin-content { padding: 24px; max-width: 1280px; width: 100%; }
.admin-content .flashes { margin-bottom: 16px; }

.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.admin-head h1 { margin: 0; font-size: 1.6rem; }

.wiki-search { position: relative; display: flex; align-items: center; gap: 8px; flex: 1; max-width: 480px; }
.wiki-search input { height: 38px; padding: 0 12px 0 40px; border-radius: 999px; background: var(--surface-2); border-color: transparent; font-size: 14px; }
.wiki-search .wiki-search-icon { position: absolute; left: 13px; color: var(--muted); pointer-events: none; width: 18px; height: 18px; }
.wiki-search .btn .icon { width: 15px; height: 15px; }
.wiki-search-lg { max-width: none; }
.wiki-search-lg input { height: 44px; font-size: 15px; }
.wiki-card { margin: 20px 0; }
.wiki-card h2 { margin: 0 0 2px; font-size: 1.1rem; }
.wiki-card form { margin: 14px 0 10px; }
.wiki-card p { margin: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.stat-grid .card + .card { margin-top: 0; }
.stat { display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: var(--text); padding: 16px 18px; }
a.stat:hover { border-color: var(--border-strong); background: #1b1b1f; color: var(--text); text-decoration: none; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text-strong); line-height: 1.15; }
.stat-label { color: var(--muted); font-size: 13.5px; }
.stat-alert { border-color: rgba(139, 71, 245, .6); background: var(--primary-soft); }
.stat-alert .stat-value { color: var(--like); }

.admin-columns { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.admin-columns .card + .card { margin-top: 0; }

.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { padding: 10px 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; }
.mini-list li:first-child { border-top: 0; padding-top: 0; }
.mini-list a { color: var(--text); font-weight: 500; }
.mini-list a:hover { color: var(--text-strong); }
.mini-list li.unread a { color: var(--text-strong); font-weight: 700; }
.mini-list li.unread a::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--primary); vertical-align: 1px; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar p { margin: 0; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .tabs { margin-bottom: 0; }
.tabs a {
    display: inline-flex; align-items: center; height: 32px; padding: 0 12px; border-radius: 8px;
    background: var(--surface-2); color: var(--text); font-size: 14px; font-weight: 500; text-decoration: none;
}
.tabs a:hover { background: var(--surface-3); color: var(--text-strong); text-decoration: none; }
.tabs a.active { background: var(--text-strong); color: var(--bg); }
.tabs .count { opacity: .7; font-size: 12.5px; margin-left: 5px; }

.table-wrap { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { color: var(--muted); font-weight: 600; font-size: 12.5px; background: var(--bg-soft); }
.table tbody tr:hover { background: rgba(255, 255, 255, .02); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td a { text-decoration: none; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions .btn, .table .actions form { margin-left: 4px; }
.table.compact td { padding: 6px 10px; }
tr.is-hidden td { opacity: .6; }

.stack-list { display: flex; flex-direction: column; gap: 12px; }
.stack-list .card + .card { margin-top: 0; }
.comment-admin-item { padding: 16px 18px; }
.comment-admin-item .comment-head { gap: 8px; margin-bottom: 6px; font-size: 14px; }
.comment-admin-item.is-hidden { opacity: .65; border-style: dashed; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* inbox */
.inbox { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
.inbox.has-open { grid-template-columns: minmax(280px, 380px) 1fr; }
.message-list { list-style: none; margin: 0; padding: 0; overflow: hidden; }
.message-list li + li { border-top: 1px solid var(--border); }
.message-list a { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 12px 16px; text-decoration: none; color: var(--text); }
.message-list a:hover { background: var(--surface-2); text-decoration: none; }
.message-list li.current a { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--primary); }
.message-list li.unread .message-subject, .message-list li.unread .message-from { color: var(--text-strong); font-weight: 700; }
.message-list li.unread .message-from::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--primary); vertical-align: 1px; }
.message-from { font-size: 14px; }
.message-subject { grid-column: 1 / -1; font-weight: 500; }
.message-snippet { grid-column: 1 / -1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.message-view h2 { margin-top: 8px; }
.message-body { margin: 20px 0; padding: 16px; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 12px; overflow-wrap: anywhere; }
.back-link { display: none; }

/* editor */
.editor { display: grid; grid-template-columns: 1fr 300px; gap: 16px; align-items: start; }
.editor-main { min-width: 0; }
.editor-main > .card + .card { margin-top: 16px; }
.editor-side .sticky { position: sticky; top: 76px; }
.editor-side h2 { font-size: 1.05rem; }
.editor-side .stack { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; }
.editor-side .stack .btn-block { margin-top: 0; }
.radio-group { border: 0; padding: 0; margin: 0; display: flex; gap: 18px; }
.radio-group label { display: flex; align-items: center; gap: 6px; font-weight: 500; margin: 0; cursor: pointer; }

.editor-tabs { display: flex; align-items: center; gap: 4px; margin: 20px 0 8px; flex-wrap: wrap; }
.editor-tabs > button {
    background: none; border: 0; color: var(--muted); height: 32px; padding: 0 12px;
    border-radius: 8px; cursor: pointer; font: 600 14px var(--font);
}
.editor-tabs > button:hover { color: var(--text); background: var(--surface-2); }
.editor-tabs > button.active { color: var(--bg); background: var(--text-strong); }
.md-toolbar { margin-left: auto; display: flex; gap: 2px; }
.md-toolbar button {
    background: var(--surface-2); border: 0; color: var(--text); min-width: 32px; height: 30px;
    border-radius: 8px; cursor: pointer; font-size: 13.5px;
}
.md-toolbar button:hover { background: var(--surface-3); color: var(--text-strong); }
textarea.mono { font-size: 14px; line-height: 1.65; min-height: 22rem; }
.preview-pane { min-height: 22rem; padding: 14px 16px; border: 1px dashed var(--border-strong); border-radius: 10px; max-width: none; }
.md-help { margin-top: 14px; font-size: 14px; }
.md-help summary { cursor: pointer; color: var(--muted); }
.md-help table { margin-top: 10px; }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 14px; }
.media-item { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 12px; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.media-thumb { position: relative; aspect-ratio: 4 / 3; background: #000; border-radius: 8px; overflow: hidden; }
.media-thumb img, .media-thumb video { width: 100%; height: 100%; object-fit: cover; }
.media-type { position: absolute; top: 6px; left: 6px; background: rgba(0, 0, 0, .75); color: #fff; }
.media-item input[type=text] { padding: 6px 9px; font-size: 13.5px; }
.media-controls { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.media-controls label { display: inline-flex; align-items: center; gap: 5px; margin: 0; font-weight: 500; }

.dropzone {
    display: flex !important; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center;
    padding: 28px 16px; margin: 16px 0 0 !important; border: 2px dashed var(--border-strong); border-radius: 14px;
    background: var(--bg-soft); cursor: pointer; font-weight: 400 !important; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--link); background: var(--primary-soft); }
.dropzone input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone-text strong { color: var(--link); }
.upload-preview { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin-top: 12px; }
.upload-preview figure { margin: 0; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.upload-preview img, .upload-preview .vid { width: 100%; aspect-ratio: 1; object-fit: cover; display: grid; place-items: center; background: #000; color: var(--muted); font-size: 1.6rem; }
.upload-preview figcaption { font-size: 11.5px; margin: 0; padding: 4px 6px; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 20px; border-color: rgba(242, 85, 90, .3); flex-wrap: wrap; }
.danger-zone p { margin: 0; }

.phpinfo-frame-wrap { padding: 0; overflow: hidden; }
.phpinfo-frame { display: block; width: 100%; height: calc(100vh - 230px); min-height: 500px; border: 0; background: var(--bg); }

/* ==========================================================================
   Responsive
   ========================================================================== */

/* No right sidebar column: it moves under the main column. */
@media (max-width: 1079px) {
    .with-rail { grid-template-columns: minmax(0, 1fr); }
    .page-rail { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); align-items: start; }
}

/* Side nav becomes an icon rail (like YouTube's mini guide). */
@media (max-width: 1239px) {
    .sidenav { width: 76px; padding: 8px 4px; gap: 4px; }
    .nav-group { gap: 4px; }
    .nav-item {
        flex-direction: column; justify-content: center; gap: 5px; height: auto; padding: 14px 0 10px;
        font-size: 10.5px; font-weight: 500; text-align: center;
    }
    .nav-item.active { font-weight: 600; }
    .nav-item .badge { position: absolute; top: 6px; right: 12px; margin: 0; }
    .nav-extra { display: none; }
}

@media (max-width: 960px) {
    .editor { grid-template-columns: 1fr; }
    .editor-side .sticky { position: static; }
    .admin-columns { grid-template-columns: 1fr; }
    .inbox.has-open { grid-template-columns: 1fr; }
    .inbox.has-open .inbox-list { display: none; }
    .back-link { display: inline-block; }
}

@media (max-width: 820px) {
    .admin-shell { grid-template-columns: 1fr; }
    .admin-sidebar {
        position: static; height: auto; flex-direction: row; align-items: center; gap: 12px;
        padding: 8px var(--gutter); border-right: 0; border-bottom: 1px solid var(--border); overflow-x: auto;
    }
    .admin-sidebar .brand-name small, .admin-sidebar-foot { display: none; }
    .admin-nav { flex-direction: row; gap: 2px; }
    .admin-nav a { height: 36px; padding: 0 10px; white-space: nowrap; font-size: 13.5px; }
    .admin-nav a .icon { display: none; }
    .admin-topbar { padding: 0 var(--gutter); position: static; }
    .admin-content { padding: 16px var(--gutter); }
}

/* Phones: no side nav, a bottom tab bar instead, and a search button in the top bar. */
@media (max-width: 759px) {
    .sidenav { display: none; }
    .topbar { grid-template-columns: auto minmax(0, 1fr); gap: 8px; padding: 0 8px 0 12px; }
    .topbar-search { display: none; }
    .search-link { display: inline-grid; }
    .create-btn span { display: none; }
    .create-btn { width: 36px; padding: 0; }
    .brand { font-size: 20px; }

    .tabbar {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
        display: grid; grid-template-columns: repeat(5, 1fr);
        padding-bottom: env(safe-area-inset-bottom);
        background: rgba(12, 12, 14, .97); border-top: 1px solid var(--border);
    }
    .tabbar a {
        display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
        height: 56px; color: var(--muted); font-size: 10.5px; font-weight: 500; text-decoration: none;
    }
    .tabbar a .icon { width: 23px; height: 23px; }
    .tabbar a.active { color: var(--text-strong); font-weight: 600; }
    .tabbar a.active .icon { color: var(--like); }
    .main { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }

    .page { padding: 12px 12px 0; }
    .page-auth { padding-top: 20px; }
    .page-search { display: flex; }

    .channel-banner { border-radius: 12px; }
    .channel-head { gap: 14px; align-items: flex-start; padding-top: 14px; }
    .channel-avatar { width: 64px; height: 64px; }
    .channel-info h1 { font-size: 24px; }
    .channel-meta { font-size: 13px; }

    .feed-post { padding: 12px 6px 14px; border-radius: 12px; }
    .feed-post + .feed-post::before { left: 6px; right: 6px; }
    .feed-title { font-size: 17px; }
    .mosaic-2 { height: 220px; }
    .mosaic-3 { height: 260px; }
    .mosaic-4 { height: 290px; }
    .gallery-3 { height: 300px; }

    .post-row { gap: 12px; padding: 6px 2px; }
    .row-thumb { width: 132px; border-radius: 10px; }
    .row-title { font-size: 15px; }
    .row-excerpt { display: none; }
    .row-meta { font-size: 12.5px; }

    .post-title { font-size: 23px; }
    .comment { padding: 10px 2px; }

    .user-banner { height: 90px; }
    .user-id { padding: 0 8px; }
    .user-id .avatar-xl { width: 76px; height: 76px; font-size: 32px; }

    .pagination { gap: 4px; }
    .page-step { padding: 0 10px; }

    .lightbox { padding: 60px 4px 76px; }
    .lightbox-nav { top: auto; bottom: 16px; transform: none; }
    .lightbox-nav.prev { left: calc(50% - 56px); }
    .lightbox-nav.next { right: calc(50% - 56px); }
}

@media (max-width: 640px) {
    .card { padding: 16px; }
    .auth-card { padding: 22px 18px; }
    .search-form { width: 100%; }
    .search-form input { width: auto; flex: 1; }
    .admin-topbar { flex-direction: column; align-items: stretch; height: auto; padding: 10px var(--gutter); }
    .wiki-search { max-width: none; }
    .admin-user { justify-content: space-between; }
    .input-prefix span { display: none; }
    .input-prefix input { border-radius: 10px; }
    .setting-row { align-items: flex-start; }

    /* tables become stacked cards */
    .table thead { display: none; }
    .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
    .table tr { padding: 12px 16px; border-bottom: 1px solid var(--border); }
    .table td { border: 0; padding: 3px 0; text-align: left !important; }
    .table td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: 12.5px; }
    .table td:first-child::before { content: none; }
    .table .actions { padding-top: 10px; white-space: normal; }
    .table .actions .btn, .table .actions form { margin: 0 4px 4px 0; }
}

@media (max-width: 400px) {
    .signup-btn { display: none; }
    .channel-actions .btn { flex: 1; }
}

@media (hover: none) {
    .feed-post:hover, .post-row:hover { background: transparent; }
    .feed-post:hover::before, .feed-post:hover + .feed-post::before { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
