/* ==========================================================================
   Tribe — Refined Aurora theme
   Dark, understated, layered. Single-file stylesheet.
   ========================================================================== */

/* ---------- Fonts ---------- */
@font-face {
    font-family: "Manrope";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/manrope-v20-latin_latin-ext-regular.woff2") format("woff2");
}
@font-face {
    font-family: "Manrope";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/manrope-v20-latin_latin-ext-500.woff2") format("woff2");
}
@font-face {
    font-family: "Manrope";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("../fonts/manrope-v20-latin_latin-ext-600.woff2") format("woff2");
}
@font-face {
    font-family: "Manrope";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("../fonts/manrope-v20-latin_latin-ext-700.woff2") format("woff2");
}
@font-face {
    font-family: "Manrope";
    font-style: normal;
    font-weight: 800;
    font-display: swap;
    src: url("../fonts/manrope-v20-latin_latin-ext-800.woff2") format("woff2");
}
@font-face {
    font-family: "JetBrains Mono";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/jetbrains-mono-v24-latin_latin-ext-regular.woff2") format("woff2");
}
@font-face {
    font-family: "JetBrains Mono";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/jetbrains-mono-v24-latin_latin-ext-500.woff2") format("woff2");
}
@font-face {
    font-family: "JetBrains Mono";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("../fonts/jetbrains-mono-v24-latin_latin-ext-600.woff2") format("woff2");
}

/* ---------- Tokens ---------- */
:root {
    --bg: #080a0f;
    --bg-soft: #0b0e15;
    --surface: #0f131c;
    --surface-2: #141925;
    --surface-3: #1b2130;

    --border: rgba(255, 255, 255, 0.07);
    --border-strong: rgba(255, 255, 255, 0.13);
    --hairline: rgba(255, 255, 255, 0.06);

    --text: #eef2fa;
    --text-2: #a7b1c6;
    --text-3: #707c93;
    --text-disabled: #4d5769;

    --accent: #6f8cff;
    --accent-2: #a06bff;
    --accent-strong: #8aa4ff;
    --accent-soft: rgba(111, 140, 255, 0.14);
    --accent-soft-2: rgba(160, 107, 255, 0.13);
    --accent-ring: rgba(111, 140, 255, 0.38);
    --accent-glow: rgba(111, 140, 255, 0.45);
    /* Shared muted accent fill for solid accent surfaces (primary buttons, the
       brand mark, the user avatar, checked controls). A touch darker than
       --accent/--accent-2 so the chrome is calmer and easier on the eyes while
       staying the same hue family. */
    --accent-fill: linear-gradient(150deg, #5f78dd, #8a5ad2);
    --accent-fill-glow: rgba(95, 120, 221, 0.34);

    /* Body/content link colour. Defaults to the accent's lighter tint, so it
       follows the accent; admins can override it via theme.php. */
    --link: var(--accent-strong);

    /* Navigation links. Independent of the accent (admin-configurable via
       theme.php); the defaults match the accent's bright tint. */
    --nav-accent: #a7bcff;
    --nav-soft: rgba(111, 140, 255, 0.14);
    --nav-glow: rgba(111, 140, 255, 0.45);
    --nav-ring: rgba(111, 140, 255, 0.38);

    --danger: #ff6b81;
    --danger-soft: rgba(255, 107, 129, 0.12);
    --success: #3ddc97;
    --success-soft: rgba(61, 220, 151, 0.12);
    --warning: #f5b942;
    --warning-soft: rgba(245, 185, 66, 0.14);

    --radius-lg: 22px;
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 7px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.9);
    --shadow-pop: 0 30px 70px -28px rgba(0, 0, 0, 0.95);

    --font: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: "JetBrains Mono", "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;

    --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    color-scheme: dark;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background-color: var(--bg);
    background-image:
        radial-gradient(1100px 560px at 12% -12%, rgba(111, 140, 255, 0.16), transparent 62%),
        radial-gradient(820px 520px at 100% -6%, rgba(160, 107, 255, 0.13), transparent 58%),
        linear-gradient(rgba(255, 255, 255, 0.022) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.022) 1px, transparent 1px);
    background-size: auto, auto, 46px 46px, 46px 46px;
    background-attachment: fixed, fixed, fixed, fixed;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* subtle film grain */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: 0.028;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection {
    background: rgba(111, 140, 255, 0.32);
    color: #fff;
}

/* ---------- Typography ---------- */
a {
    color: var(--link);
    text-decoration: none;
    transition: color 0.15s var(--ease);
}

a:hover {
    color: #fff;
    text-decoration: none;
}

h1,
h2,
h3 {
    margin: 0;
    line-height: 1.2;
    letter-spacing: -0.022em;
    font-weight: 700;
    color: var(--text);
}

h1 { font-size: 1.6rem; font-weight: 800; }
h2 { font-size: 1.12rem; }

p {
    margin: 0;
}

code,
kbd {
    font-family: var(--mono);
}

.muted { color: var(--text-2); }
.small { font-size: 0.82rem; }
.ta-right { text-align: right; }

.icon {
    flex: none;
    display: block;
}

/* ---------- Topbar ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(8, 10, 15, 0.72);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    border-bottom: 1px solid var(--border);
    box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.02);
}

.topbar__inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0.7rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    color: var(--text);
    font-weight: 800;
    letter-spacing: -0.02em;
    font-size: 1.02rem;
}

.brand:hover { color: var(--text); }

.brand__mark {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: var(--accent-fill);
    color: #fff;
    font-weight: 800;
    font-size: 0.95rem;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.28),
        inset 0 -8px 16px -8px rgba(0, 0, 0, 0.5),
        0 8px 22px -8px var(--accent-fill-glow);
}

.brand__logo {
    display: block;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    object-fit: contain;
    background: rgba(255, 255, 255, 0.04);
}

.branding-preview {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.favicon-choices {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.favicon-choice {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    cursor: pointer;
    transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}

.favicon-choice:hover {
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.03);
}

.favicon-choice input[type="radio"] {
    margin: 0;
}

.favicon-choice img {
    width: 40px;
    height: 40px;
    border-radius: 12px;
}

.favicon-choice:has(input:checked) {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent-ring), 0 6px 18px -12px var(--accent-glow);
}

.tabs {
    display: flex;
    gap: 0.3rem;
}

.tab {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    color: var(--text-2);
    font-weight: 600;
    font-size: 0.9rem;
    transition: color 0.15s var(--ease), background 0.15s var(--ease);
}

.tab .icon { opacity: 0.75; transition: opacity 0.15s var(--ease); }

.tab:hover {
    color: var(--nav-accent);
    background: rgba(255, 255, 255, 0.045);
}

.tab:hover .icon { opacity: 1; }

.tab.is-active {
    color: var(--nav-accent);
    background: linear-gradient(180deg, var(--nav-soft), rgba(255, 255, 255, 0.02));
    box-shadow: inset 0 0 0 1px var(--border-strong), 0 6px 18px -12px var(--nav-glow);
}

.tab.is-active .icon { opacity: 1; color: var(--nav-accent); }

/* Keyboard focus for navigation links (tabs and sidebar/sub navigation). */
.tab:focus-visible,
.subtab:focus-visible,
.pagination__link:focus-visible,
.per-page__opt:focus-visible {
    outline: 2px solid var(--nav-ring);
    outline-offset: 2px;
}

.topbar__user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-menu { position: relative; }

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.6rem 0.35rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.02);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
}

.user-chip:hover,
.user-chip[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-strong);
}

.user-chip__avatar {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--accent-fill);
    color: #fff;
    font-size: 0.76rem;
    font-weight: 700;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.user-chip__name { color: var(--text); }

.user-chip__caret {
    width: 7px;
    height: 7px;
    margin-left: 0.1rem;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg) translate(-1px, -1px);
    opacity: 0.6;
    transition: transform 0.18s var(--ease);
}

.user-chip[aria-expanded="true"] .user-chip__caret {
    transform: rotate(225deg) translate(-1px, -1px);
}

.dropdown {
    position: absolute;
    top: calc(100% + 0.55rem);
    right: 0;
    min-width: 210px;
    padding: 0.35rem;
    background: linear-gradient(180deg, var(--surface-2), var(--surface));
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-pop);
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    animation: dropdown-in 0.16s var(--ease);
}

.dropdown[hidden] { display: none; }

.dropdown__item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.65rem;
    border-radius: var(--radius-xs);
    color: var(--text-2);
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 0.13s var(--ease), color 0.13s var(--ease);
}

.dropdown__item .icon { opacity: 0.8; }

.dropdown__item:hover {
    color: var(--nav-accent);
}

.dropdown__form { margin: 0; }

button.dropdown__item {
    width: 100%;
    border: none;
    background: transparent;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.dropdown__separator {
    height: 1px;
    margin: 0.25rem 0.4rem;
    background: var(--border);
}

.dropdown__item--danger { color: #ff9bb0; }
.dropdown__item--danger:hover { background: var(--danger-soft); color: #ffc4cf; }

.dropdown__item--warn { color: #f6c667; }
.dropdown__item--warn:hover { background: var(--warning-soft); color: #ffd98a; }

@keyframes dropdown-in {
    from { opacity: 0; transform: translateY(-6px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Row menus (admin user list) - floating so the table's horizontal
   scroll container does not clip the dropdown. */
.row-menu { position: relative; display: inline-block; }

.row-menu__trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.2rem 0.5rem;
    margin-left: -0.5rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
}

.row-menu__trigger:hover,
.row-menu__trigger[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-strong);
}

.row-menu__name { color: inherit; }

.dropdown--floating { position: fixed; right: auto; white-space: normal; }

.dropdown__note { padding: 0.5rem 0.7rem; }

.dropdown__note-text {
    margin: 0.45rem 0 0;
    color: #ffb4c0;
    font-size: 0.84rem;
    line-height: 1.4;
    max-width: 240px;
}

.dropdown__note-meta {
    margin: 0.35rem 0 0;
    color: var(--text-3);
    font-size: 0.76rem;
}

/* ---------- Modal ---------- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
}

.modal[hidden] { display: none; }

.modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(3, 5, 9, 0.7);
    backdrop-filter: blur(4px);
}

.modal__panel {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 470px;
    animation: modal-in 0.2s var(--ease);
}

.modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    margin-top: 0.5rem;
}

@keyframes modal-in {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.inline-form { display: inline; }

/* ---------- Layout ---------- */
.page {
    max-width: 1120px;
    margin: 0 auto;
    padding: 2.25rem 1.25rem 4.5rem;
    animation: page-in 0.35s var(--ease);
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

@keyframes page-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---------- Auth ---------- */
.auth-wrap {
    min-height: calc(100vh - 130px);
    min-height: calc(100svh - 130px);
    display: grid;
    place-items: center;
    padding: 1rem;
    position: relative;
}

/* Login/registration hide the topbar, so there is no header height to offset. */
.no-topbar .auth-wrap {
    min-height: calc(100vh - 7rem);
    min-height: calc(100svh - 7rem);
}

.auth-wrap::before {
    content: "";
    position: absolute;
    top: 12%;
    width: 420px;
    height: 420px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(111, 140, 255, 0.22), transparent 68%);
    filter: blur(20px);
    pointer-events: none;
    z-index: -1;
}

.card {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.028), rgba(255, 255, 255, 0)) padding-box,
        linear-gradient(180deg, var(--surface-2), var(--surface)) padding-box;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow:
        inset 0 1px 0 var(--hairline),
        var(--shadow);
    padding: 1.85rem;
}

.card--auth {
    width: 100%;
    max-width: 430px;
    backdrop-filter: blur(6px);
}

.card--auth.card--wide {
    max-width: 580px;
}

.card__head {
    margin-bottom: 1.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.card__head h1 { font-size: 1.45rem; }

/* ---------- Forms ---------- */
.form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form__row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.42rem;
}

.field[hidden],
.check-row[hidden] { display: none; }

.field__label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-2);
    letter-spacing: 0.005em;
}

.field__hint {
    font-size: 0.76rem;
    color: var(--text-3);
}

.field__hint code {
    padding: 0.05rem 0.32rem;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    font-size: 0.72rem;
}

/* Live password-match feedback (register / password change). */
.field__hint--match { color: #a9f2cd; }
.field__hint--mismatch { color: #ffb4c0; }

input.is-match { border-color: rgba(61, 220, 151, 0.55); }
input.is-mismatch { border-color: rgba(255, 107, 129, 0.6); }

input.is-match:focus {
    border-color: var(--success);
    box-shadow: 0 0 0 3.5px var(--success-soft);
}

input.is-mismatch:focus {
    border-color: var(--danger);
    box-shadow: 0 0 0 3.5px var(--danger-soft);
}

.check-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea {
    width: 100%;
    padding: 0.72rem 0.9rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: rgba(4, 6, 10, 0.55);
    color: var(--text);
    font: inherit;
    box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.25);
    transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease), background 0.15s var(--ease);
}

input[type="text"]:hover,
input[type="email"]:hover,
input[type="password"]:hover,
textarea:hover {
    border-color: rgba(255, 255, 255, 0.2);
}

textarea {
    resize: vertical;
    min-height: 6rem;
    line-height: 1.55;
}

input:focus,
textarea:focus {
    outline: none;
    background: rgba(4, 6, 10, 0.8);
    border-color: var(--accent);
    box-shadow: 0 0 0 3.5px var(--accent-soft);
}

input::placeholder,
textarea::placeholder { color: var(--text-disabled); }

/* custom checkboxes */
.check-row input[type="checkbox"],
.msg-checkbox input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    flex: none;
    width: 18px;
    height: 18px;
    border: 1px solid var(--border-strong);
    border-radius: 5px;
    background: rgba(4, 6, 10, 0.6);
    cursor: pointer;
    position: relative;
    transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
}

.check-row input[type="checkbox"]:hover,
.msg-checkbox input[type="checkbox"]:hover { border-color: var(--accent-ring); }

.check-row input[type="checkbox"]:checked,
.msg-checkbox input[type="checkbox"]:checked {
    background: var(--accent-fill);
    border-color: transparent;
}

.check-row input[type="checkbox"]:checked::after,
.msg-checkbox input[type="checkbox"]:checked::after {
    content: "";
    position: absolute;
    left: 6px;
    top: 2.5px;
    width: 4px;
    height: 8px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.check-row input[type="checkbox"]:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 2px; }

/* toggle switch variant */
.switch {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    cursor: pointer;
}

.switch input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    flex: none;
    width: 40px;
    height: 23px;
    margin-top: 0.05rem;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    background: var(--surface-3);
    cursor: pointer;
    position: relative;
    transition: background 0.18s var(--ease), border-color 0.18s var(--ease);
}

.switch input[type="checkbox"]::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    transition: transform 0.18s var(--ease);
}

.switch input[type="checkbox"]:checked {
    background: var(--accent-fill);
    border-color: transparent;
}

.switch input[type="checkbox"]:checked::after { transform: translateX(17px); }
.switch input[type="checkbox"]:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 2px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.42rem;
    padding: 0.62rem 1.05rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 650;
    cursor: pointer;
    white-space: nowrap;
    transition: transform 0.08s var(--ease), background 0.15s var(--ease),
        border-color 0.15s var(--ease), box-shadow 0.15s var(--ease), filter 0.15s var(--ease);
}

.btn .icon { opacity: 0.95; }

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 2px; }

.btn--primary {
    background: var(--accent-fill);
    color: #fff;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.28),
        0 10px 26px -12px var(--accent-fill-glow);
}

.btn--primary:hover { filter: brightness(1.08); color: #fff; }

.btn--block { width: 100%; }

.btn--ghost {
    background: rgba(255, 255, 255, 0.025);
    border-color: var(--border-strong);
    color: var(--text-2);
}

.btn--ghost:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--accent-ring);
}

.btn--danger {
    background: var(--danger-soft);
    border-color: rgba(255, 107, 129, 0.32);
    color: #ff9bb0;
}

.btn--danger:hover { background: rgba(255, 107, 129, 0.2); color: #ffc4cf; }

.btn--sm { padding: 0.36rem 0.68rem; font-size: 0.82rem; border-radius: var(--radius-xs); }

.btn.is-loading { opacity: 0.6; pointer-events: none; }
.btn.is-loading::before {
    content: "";
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Alerts ---------- */
.alert {
    display: flex;
    gap: 0.6rem;
    border-radius: var(--radius-sm);
    padding: 0.8rem 0.95rem;
    margin-bottom: 1rem;
    font-size: 0.88rem;
    border: 1px solid transparent;
    white-space: pre-line;
    line-height: 1.5;
}

.alert[hidden] { display: none; }

.alert .icon { margin-top: 0.12rem; opacity: 0.9; }

.alert p { margin: 0; }
.alert p + p { margin-top: 0.35rem; }

.alert--error {
    background: var(--danger-soft);
    border-color: rgba(255, 107, 129, 0.3);
    color: #ffb4c0;
}

.alert--success {
    background: var(--success-soft);
    border-color: rgba(61, 220, 151, 0.3);
    color: #a9f2cd;
}

.alert--info {
    background: linear-gradient(180deg, var(--accent-soft), rgba(255, 255, 255, 0.01));
    border-color: var(--border-strong);
    color: var(--text);
}

.alert--warning {
    background: var(--warning-soft);
    border-color: rgba(245, 185, 66, 0.32);
    color: #fcd34d;
}

.auth-alt {
    margin-top: 1.3rem;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-2);
}

/* ---------- Contact form ---------- */
.linklike {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    color: var(--accent-strong);
    cursor: pointer;
}

.linklike:hover { text-decoration: underline; }

.honeypot {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.contact-box {
    margin-top: 1.2rem;
    padding-top: 1.2rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    text-align: left;
    scroll-margin-top: 5.5rem;
}

.contact-box[hidden] { display: none; }

.contact-box__head h2 { font-size: 1.05rem; }

.contact-meta { padding: 0 1.3rem 1.2rem; }

/* ---------- Hero / Panels ---------- */
.hero {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.5rem 0 0.25rem;
}

.hero h1 { font-size: 1.9rem; }

.hero__name {
    background: linear-gradient(115deg, var(--accent-strong) 10%, #c3a0ff 90%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.panel {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.022), rgba(255, 255, 255, 0)) padding-box,
        var(--surface) padding-box;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: inset 0 1px 0 var(--hairline), var(--shadow);
    overflow: hidden;
}

.panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.1rem 1.3rem;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
    flex-wrap: wrap;
}

.panel__head > div { display: flex; flex-direction: column; gap: 0.22rem; }
.panel__head > .panel__actions { display: flex; flex-direction: row; align-items: center; gap: 0.6rem; flex-wrap: wrap; }

/* Compact header: the title and its control share one row. */
.panel__head--inline { padding: 0.7rem 1.3rem; }
.panel__head > .lang-control { align-items: flex-end; margin-left: auto; }
.lang-control { display: flex; flex-direction: column; align-items: flex-end; gap: 0.35rem; }
.lang-control .lang-form { gap: 0.35rem; }

.settings-body {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
    padding: 1.3rem;
    max-width: 500px;
}

.settings-body[hidden] { display: none; }

.settings-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-3);
}

.pill {
    padding: 0.28rem 0.72rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-2);
}

/* ---------- Dashboard stats + quick links ---------- */
.stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.stat {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.15rem 1.25rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0)) padding-box,
        linear-gradient(160deg, var(--surface-2), var(--surface)) padding-box;
    box-shadow: inset 0 1px 0 var(--hairline), var(--shadow);
    transition: transform 0.16s var(--ease), border-color 0.16s var(--ease);
}

.stat:hover { transform: translateY(-2px); border-color: var(--border-strong); }

.stat__chip {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    flex: none;
    border-radius: 13px;
    color: #fff;
    background: var(--accent-fill);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 10px 24px -12px var(--accent-fill-glow);
}

.stat__chip--alt {
    background: linear-gradient(150deg, #35c9b0, var(--accent));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 10px 24px -12px rgba(53, 201, 176, 0.45);
}

.stat__body { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }

.stat__value {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.stat__label {
    font-size: 0.8rem;
    color: var(--text-2);
    font-weight: 600;
}

.stat__meta {
    font-size: 0.76rem;
    color: var(--text-3);
}

.quick {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.quick__link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
    color: var(--text);
    font-weight: 600;
    font-size: 0.9rem;
    transition: background 0.15s var(--ease), border-color 0.15s var(--ease), transform 0.15s var(--ease);
}

.quick__link .icon { color: var(--accent-strong); }

.quick__link .quick__arrow {
    margin-left: auto;
    opacity: 0.4;
    transition: transform 0.15s var(--ease), opacity 0.15s var(--ease);
}

.quick__link:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--accent-ring);
    transform: translateY(-1px);
    color: var(--text);
}

.quick__link:hover .quick__arrow { opacity: 1; transform: translateX(3px); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th,
.data-table td {
    padding: 0.85rem 1.3rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-3);
    background: var(--surface-2);
    font-weight: 700;
}

.data-table tbody tr {
    transition: background 0.12s var(--ease);
}

.data-table tbody tr:hover { background: rgba(255, 255, 255, 0.025); }

.data-table tbody tr.is-clickable { cursor: pointer; }

.data-table tbody tr.is-clickable .msg-checkbox,
.data-table tbody tr.is-clickable .msg-checkbox input { cursor: default; }

.data-table tbody tr:last-child td { border-bottom: none; }

.data-table tbody tr.is-banned > td { color: #ff9bb0; }
.data-table tbody tr.is-banned .row-menu__name { color: inherit; }

.empty-row td {
    text-align: center;
    color: var(--text-3);
    padding: 2.5rem 1rem;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-3);
}

.empty-state .icon { opacity: 0.45; }

.avatar {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 9px;
    background: linear-gradient(150deg, var(--accent-soft), var(--accent-soft-2));
    border: 1px solid var(--border-strong);
    color: var(--accent-strong);
    font-size: 0.8rem;
    font-weight: 700;
    flex: none;
}

.status-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex: none;
    background: var(--text-3);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.04);
}

.status-dot--online {
    background: var(--success);
    box-shadow: 0 0 0 3px var(--success-soft);
    animation: pulse-dot 2.2s var(--ease) infinite;
}

.status-dot--idle {
    background: var(--warning);
    box-shadow: 0 0 0 3px var(--warning-soft);
}

.status-dot--offline {
    background: var(--text-disabled);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.03);
}

@keyframes pulse-dot {
    0%, 100% { box-shadow: 0 0 0 3px var(--success-soft); }
    50% { box-shadow: 0 0 0 5px rgba(61, 220, 151, 0.06); }
}

/* ---------- Badges / Status ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.22rem 0.58rem;
    border-radius: 999px;
    font-size: 0.73rem;
    font-weight: 700;
    letter-spacing: 0.015em;
    border: 1px solid transparent;
}

.badge[hidden] { display: none; }

.badge--flash,
.stat__value--flash { animation: badge-flash 0.9s var(--ease); }

@keyframes badge-flash {
    0% { transform: scale(1); }
    30% { transform: scale(1.35); }
    100% { transform: scale(1); }
}

.badge--accent {
    background: var(--accent-soft);
    border-color: rgba(111, 140, 255, 0.28);
    color: var(--accent-strong);
}

.badge--muted {
    background: rgba(255, 255, 255, 0.045);
    border-color: var(--border);
    color: var(--text-2);
}

.badge--danger {
    background: var(--danger-soft);
    border-color: rgba(255, 107, 129, 0.3);
    color: #ffb4c0;
}

.badge--unread {
    margin-left: 0.4rem;
    background: var(--accent-fill);
    border-color: transparent;
    color: #fff;
    min-width: 1.3rem;
    height: 1.3rem;
    padding: 0 0.35rem;
    justify-content: center;
    box-shadow: 0 4px 12px -5px var(--accent-fill-glow);
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-3);
}

.status::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.status--free { color: var(--success); }
.status--used { color: var(--text-3); }
.status--ok { color: var(--success); }
.status--warn { color: var(--warning); }
.status--fail { color: var(--danger); }
.status--info { color: var(--text-2); }

/* ---------- Subtabs ---------- */
.subtabs {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.65rem;
    flex-wrap: wrap;
}

.subtab {
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    color: var(--text-2);
    font-weight: 600;
    font-size: 0.9rem;
    transition: color 0.15s var(--ease), background 0.15s var(--ease);
}

.subtab:hover { color: var(--nav-accent); background: rgba(255, 255, 255, 0.045); }

.subtab.is-active {
    color: var(--nav-accent);
    background: linear-gradient(180deg, var(--nav-soft), rgba(255, 255, 255, 0.02));
    box-shadow: inset 0 0 0 1px var(--border-strong), 0 6px 18px -12px var(--nav-glow);
}

/* Compose is an action, not a folder: it is pushed to the right of the folder
   tabs and styled like the primary "Add Friend" button (filled accent). */
.subtab--compose {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: #fff;
    border: 1px solid transparent;
    background: var(--accent-fill);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 10px 26px -12px var(--accent-fill-glow);
    transition: filter 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.subtab--compose .icon { opacity: 0.95; }

.subtab--compose:hover {
    color: #fff;
    background: var(--accent-fill);
    border-color: transparent;
    filter: brightness(1.08);
}

.subtab--compose.is-active {
    color: #fff;
    background: var(--accent-fill);
    border-color: transparent;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 10px 26px -12px var(--accent-fill-glow), 0 0 0 2px var(--accent-ring);
}

/* ---------- Invite code display ---------- */
.code-value {
    font-family: var(--mono);
    font-size: 0.88rem;
    letter-spacing: 0.04em;
    color: var(--text);
}

.code-value--muted { color: var(--text-3); }

.new-code {
    margin: 1.1rem 1.3rem 0;
    padding: 0.95rem 1.05rem;
    border-radius: var(--radius-sm);
    background: linear-gradient(180deg, var(--success-soft), rgba(255, 255, 255, 0.01));
    border: 1px solid rgba(61, 220, 151, 0.28);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.new-code[hidden] { display: none; }

.new-code__head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.new-code__row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.new-code .code-value {
    font-size: 1.08rem;
    font-weight: 600;
    color: #c6ffe4;
}

/* ---------- Two-factor authentication ---------- */
.code-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin: 0.4rem 0 0.6rem;
}

.recovery-codes {
    list-style: none;
    margin: 0.7rem 0;
    padding: 0.9rem 1.05rem;
    border-radius: var(--radius-sm);
    background: linear-gradient(180deg, var(--success-soft), rgba(255, 255, 255, 0.01));
    border: 1px solid rgba(61, 220, 151, 0.28);
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.4rem 1rem;
}

.recovery-codes li {
    font-family: var(--mono);
    font-size: 0.92rem;
    letter-spacing: 0.05em;
    font-weight: 600;
    color: #c6ffe4;
}

/* ---------- Messages ---------- */
.msg-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.msg-body {
    padding: 1.4rem 1.3rem;
    overflow-wrap: break-word;
    word-break: break-word;
    line-height: 1.65;
    color: var(--text);
}

.msg-subject {
    font-size: 1.18rem;
    word-break: break-word;
}

.msg-peer {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
}

.msg-peer .avatar {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    font-size: 0.74rem;
}

.data-table tbody tr.is-unread {
    background: rgba(111, 140, 255, 0.055);
    box-shadow: inset 2px 0 0 var(--accent);
}

.data-table tbody tr.is-unread td {
    font-weight: 600;
}

/* Compose form: a wider, more composer-like layout with a prominent editor.
   Kept as a modifier so the shared .settings-body stays narrow elsewhere. */
.settings-body--compose {
    max-width: 760px;
    margin-inline: auto;
}

/* Card-in-card: the composer sits on a slightly inset surface so it reads as
   the central element of the panel. */
.compose-card {
    gap: 1.15rem;
    padding: 1.15rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.016), rgba(255, 255, 255, 0));
}

/* Separates the message metadata (To/Subject) from the message body. */
.compose-head {
    padding-bottom: 1.15rem;
    border-bottom: 1px solid var(--border);
}

.compose-hint { margin: 0; }

/* Reply context shown above the composer when composing a reply. */
.compose-reply {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-2);
    font-size: 0.85rem;
}

.compose-reply svg { flex: none; color: var(--accent-strong); }

.compose-reply__text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.compose-reply__text strong { color: var(--text); font-weight: 650; }

.compose-reply__cancel {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    color: var(--text-3);
    flex: none;
    transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.compose-reply__cancel:hover { background: rgba(255, 255, 255, 0.07); color: var(--text); }

/* Leading field icons. */
.field__control { position: relative; display: block; }

.field__control .field__icon {
    position: absolute;
    left: 0.8rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-3);
    pointer-events: none;
    transition: color 0.15s var(--ease);
}

.field--icon .field__control input { padding-left: 2.4rem; }
.field--recipient .field__control input { padding-right: 2.2rem; }
.field__control:focus-within .field__icon { color: var(--accent-strong); }

/* Avatar shown inside the recipient field once it matches a friend. */
.field__peer {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent-fill);
    color: #fff;
    font-size: 0.66rem;
    font-weight: 700;
    pointer-events: none;
}

.field__peer[hidden] { display: none; }

/* Usage bar under the message editor (driven by the counter script). */
.field__bar {
    display: block;
    height: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    overflow: hidden;
}

.field__bar > i {
    display: block;
    height: 100%;
    width: calc(var(--fill, 0) * 100%);
    border-radius: inherit;
    background: var(--accent-strong);
    transition: width 0.15s var(--ease), background 0.15s var(--ease);
}

.field__bar.is-near > i { background: var(--warning); }
.field__bar.is-over > i { background: var(--danger); }

.field--message textarea {
    min-height: 15rem;
}

.field__count {
    align-self: flex-end;
    font-family: var(--mono);
    font-size: 0.74rem;
    color: var(--text-3);
    letter-spacing: 0.01em;
    transition: color 0.15s var(--ease);
}

.field__count--inline { align-self: auto; }

.field__count.is-near { color: var(--warning); }
.field__count.is-over { color: var(--danger); }

.compose-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

@media (max-width: 640px) {
    .compose-actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }
    .compose-actions .btn {
        width: 100%;
    }
}

.data-table tbody tr.is-unread:hover {
    background: rgba(111, 140, 255, 0.09);
}

.msg-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1.3rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.msg-toolbar__right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.msg-checkbox {
    width: 3rem;
    text-align: center;
}

.msg-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1.3rem;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.per-page {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.per-page__opt {
    padding: 0.22rem 0.6rem;
    border-radius: 999px;
    color: var(--text-2);
    font-size: 0.82rem;
    font-weight: 600;
    transition: color 0.15s var(--ease), background 0.15s var(--ease);
}

.per-page__opt:hover {
    color: var(--nav-accent);
    background: rgba(255, 255, 255, 0.05);
}

.per-page__opt.is-active {
    color: var(--nav-accent);
    background: var(--nav-soft);
    box-shadow: inset 0 0 0 1px var(--border-strong);
}

.pagination {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.pagination__link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    padding: 0.32rem 0.6rem;
    border-radius: var(--radius-xs);
    color: var(--text-2);
    font-size: 0.85rem;
    font-weight: 600;
    transition: color 0.15s var(--ease), background 0.15s var(--ease);
}

.pagination__link:hover {
    color: var(--nav-accent);
    background: rgba(255, 255, 255, 0.05);
}

.pagination__link.is-active {
    color: var(--nav-accent);
    background: linear-gradient(180deg, var(--nav-soft), rgba(255, 255, 255, 0.02));
    box-shadow: inset 0 0 0 1px var(--border-strong);
}

.usage {
    display: inline-flex;
    align-items: center;
    padding: 0.28rem 0.72rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    border: 1px solid transparent;
    white-space: nowrap;
    font-family: var(--mono);
    letter-spacing: 0.01em;
}

.usage--low {
    background: var(--success-soft);
    border-color: rgba(61, 220, 151, 0.3);
    color: #a9f2cd;
}

.usage--medium {
    background: var(--warning-soft);
    border-color: rgba(245, 185, 66, 0.32);
    color: #fcd34d;
}

.usage--high {
    background: var(--danger-soft);
    border-color: rgba(255, 107, 129, 0.3);
    color: #ffb4c0;
}

/* ---------- Toasts ---------- */
.toast-region {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.72rem 1rem;
    border-radius: var(--radius-sm);
    background: linear-gradient(180deg, var(--surface-2), var(--surface));
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-pop);
    font-size: 0.88rem;
    font-weight: 550;
    animation: toast-in 0.22s var(--ease);
    max-width: min(340px, calc(100vw - 2rem));
}

.toast--success { border-color: rgba(61, 220, 151, 0.35); color: #c9ffe1; }
.toast--error { border-color: rgba(255, 107, 129, 0.35); color: #ffc4cf; }

.toast--link { color: inherit; text-decoration: none; }
.toast--link:hover { border-color: var(--border-strong); }

.toast::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex: none;
    background: var(--accent-strong);
}

.toast--success::before { background: var(--success); }
.toast--error::before { background: var(--danger); }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
    .stats,
    .quick { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .topbar__inner { gap: 0.6rem; flex-wrap: wrap; }
    .tabs {
        order: 3;
        width: 100%;
        overflow-x: auto;
        padding-bottom: 0.15rem;
        -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 22px), transparent);
        mask-image: linear-gradient(to right, #000 calc(100% - 22px), transparent);
    }
    .brand__name { display: none; }
    .form__row { grid-template-columns: 1fr; }
    .hero h1 { font-size: 1.6rem; }
    /* Avoid iOS Safari zooming into fields with a font-size below 16px. */
    input[type="text"], input[type="email"], input[type="password"], textarea { font-size: 16px; }

    .data-table th { display: none; }
    .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
    .data-table th { position: static; }
    .data-table tr {
        padding: 0.5rem 0;
        border-bottom: 1px solid var(--border);
    }
    .data-table td {
        display: flex;
        justify-content: space-between;
        gap: 1rem;
        border: none;
        padding: 0.32rem 1.3rem;
        white-space: normal;
        overflow-wrap: anywhere;
        text-align: right;
    }
    .msg-peer, .code-value { overflow-wrap: anywhere; }
    .data-table td::before {
        content: attr(data-label);
        color: var(--text-3);
        font-size: 0.74rem;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        font-weight: 700;
        text-align: left;
    }
    .data-table td.ta-right { text-align: right; }
    .msg-checkbox { width: auto; padding: 0.32rem 1.3rem; justify-content: flex-start; }
    .msg-checkbox::before { display: none; }
    .data-table td.pm-cell { flex-direction: column; align-items: flex-start; text-align: left; }
}

/* Fixed-attachment backgrounds repaint heavily while scrolling on touch
   devices, so fall back to a normal scroll attachment there. */
@media (pointer: coarse), (max-width: 720px) {
    body { background-attachment: scroll; }
}

/* Larger tap targets on touch devices (and small screens). */
@media (pointer: coarse), (max-width: 640px) {
    .btn--sm { min-height: 40px; padding: 0.5rem 0.8rem; }
    .tab,
    .subtab { min-height: 40px; }
    .pagination__link { min-height: 40px; min-width: 40px; }
    .dropdown__item { min-height: 40px; }
    .row-menu__trigger { min-height: 40px; }
    .msg-checkbox { padding-top: 0.5rem; padding-bottom: 0.5rem; }
    .msg-checkbox input[type="checkbox"],
    .check-row input[type="checkbox"] { width: 22px; height: 22px; }
}

@media (max-width: 480px) {
    .page { padding: 1.5rem 1rem 3.5rem; }
    .topbar__inner { padding: 0.6rem 1rem; }
    .panel__head { padding: 1rem; }
    .card { padding: 1.4rem; }
    .data-table td { padding: 0.32rem 1rem; }

    .toast-region { left: 1rem; right: 1rem; }
    .toast { max-width: 100%; }

    .modal { padding: 1rem; }
    .modal__panel { max-height: calc(100dvh - 2rem); overflow-y: auto; }
}

/* ---------- Chat ---------- */
.chat { display: flex; flex-direction: column; }
.chat__title { display: flex; align-items: center; gap: 0.5rem; margin: 0; font-size: 1.15rem; }
.chat__title svg { color: var(--accent-strong); }
.chat__subtitle { margin: 0; }
.chat-head-actions { display: flex; align-items: center; gap: 0.6rem; }
.chat-status { display: inline-flex; align-items: center; gap: 0.45rem; font-size: 0.82rem; color: var(--text-2); }
.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    padding: 1.1rem 1.3rem;
    height: min(58vh, 560px);
    overflow-y: auto;
    scroll-behavior: smooth;
    background: radial-gradient(600px 300px at 100% 0, rgba(111, 140, 255, 0.06), transparent 60%);
}
.chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    height: 100%;
    text-align: center;
}
.chat-empty svg { color: var(--text-3); }
.chat-msg { max-width: min(78%, 640px); align-self: flex-start; display: flex; flex-direction: column; gap: 0.2rem; }
.chat-msg--own { align-self: flex-end; align-items: flex-end; }
.chat-msg__meta { display: flex; align-items: baseline; gap: 0.45rem; font-size: 0.76rem; color: var(--text-3); padding: 0 0.35rem; }
.chat-msg--own .chat-msg__meta { flex-direction: row-reverse; }
.chat-msg__name { font-weight: 700; color: var(--text-2); font-size: var(--chat-name-size, 0.85rem); }
.chat-msg__text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: var(--chat-text-size, 1rem);
    padding: 0.55rem 0.8rem;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
}
.chat-msg--own .chat-msg__text { background: var(--accent-soft); border-color: var(--accent-ring); }
.chat-msg__id { font-family: var(--mono); font-size: 0.7rem; color: var(--text-3); }
.chat-msg__delete {
    display: none;
    border: none;
    background: transparent;
    color: var(--text-3);
    cursor: pointer;
    padding: 0 0.15rem;
    line-height: 1;
    align-items: center;
}
.chat-msg:hover .chat-msg__delete { display: inline-flex; }
.chat-msg__delete:hover { color: var(--danger); }

.chat-msg__reply {
    display: none;
    border: none;
    background: transparent;
    color: var(--text-3);
    cursor: pointer;
    padding: 0 0.15rem;
    line-height: 1;
    align-items: center;
}
.chat-msg:hover .chat-msg__reply { display: inline-flex; }
.chat-msg__reply:hover { color: var(--accent-strong); }

/* A received whisper keeps its Reply action visible without hovering. */
.chat-msg--whisper-in .chat-msg__reply { display: inline-flex; }

.chat-msg:focus-within .chat-msg__reply,
.chat-msg:focus-within .chat-msg__delete { display: inline-flex; }
.chat-msg__reply:focus-visible,
.chat-msg__delete:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 1px; border-radius: 4px; }
.chat-room__btn:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 1px; }

/* On touch devices there is no hover, so keep the action buttons visible. */
@media (pointer: coarse) {
    .chat-msg__reply,
    .chat-msg__delete { display: inline-flex; }
}

.chat-reply {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    padding: 0.5rem 1.3rem;
    border-top: 1px solid var(--border);
    background: var(--accent-soft);
}
.chat-reply[hidden] { display: none; }

.chat-msg--whisper .chat-msg__name { color: var(--accent-2); }
.chat-msg--whisper .chat-msg__text {
    background: rgba(160, 107, 255, 0.16);
    border-color: rgba(160, 107, 255, 0.42);
}
.chat-msg--whisper-out .chat-msg__text { opacity: 0.92; }

.chat-system {
    align-self: center;
    max-width: 90%;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-3);
    border: 1px dashed var(--border-strong);
    border-radius: 999px;
    padding: 0.25rem 0.85rem;
    white-space: pre-wrap;
}
.chat-system--error { color: var(--danger); border-color: var(--danger-soft); }
.chat-system--success { color: var(--success); border-color: var(--success-soft); }
/* Multi-line output (e.g. /help, /rooms) reads better as a left-aligned block. */
.chat-system--block {
    align-self: stretch;
    max-width: 100%;
    text-align: left;
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.8rem;
}
.chat-load-older {
    align-self: center;
    margin-bottom: 0.2rem;
    padding: 0.3rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-2);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}
.chat-load-older:hover { background: rgba(255, 255, 255, 0.05); border-color: var(--border-strong); }
.chat-load-older:disabled { opacity: 0.6; cursor: default; }

.msg-link {
    color: var(--link);
    text-decoration: underline;
    text-underline-offset: 2px;
    overflow-wrap: anywhere;
}
.msg-link:hover { color: var(--accent); }
.chat-composer {
    display: flex;
    gap: 0.6rem;
    align-items: flex-end;
    padding: 0.9rem 1.3rem calc(1.1rem + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border);
    background: linear-gradient(0deg, rgba(255, 255, 255, 0.02), transparent);
}
.chat-composer__input {
    flex: 1;
    resize: none;
    min-height: 42px;
    max-height: 160px;
    padding: 0.65rem 0.8rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface-2);
    color: var(--text);
    font-family: var(--font);
    font-size: var(--chat-text-size, 1rem);
    line-height: 1.45;
}
.chat-composer__input:focus { outline: none; border-color: var(--accent-ring); box-shadow: 0 0 0 3px var(--accent-soft); }
.chat-composer__send { white-space: nowrap; }

.chat-presence {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.6rem 1.3rem;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.015), transparent);
    flex-wrap: wrap;
}
.chat-presence__label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.74rem;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    white-space: nowrap;
}
.chat-presence__list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    list-style: none;
    margin: 0;
    padding: 0;
}
.chat-presence__user {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.2rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    font-size: 0.82rem;
}
.chat-presence__user .status-dot { width: 7px; height: 7px; box-shadow: none; }
.chat-presence__name { color: var(--text); font-weight: 600; font-size: 0.95rem; }
.chat-presence__you { color: var(--text-3); font-size: 0.72rem; }
.chat-presence__empty[hidden] { display: none; }

/* Clickable member name (opens the compact user menu). */
.chat-presence__name-btn {
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
}
.chat-presence__name-btn:hover { color: var(--accent-strong); text-decoration: underline; }

/* Members sidebar (desktop only; the inline presence row is used on smaller
   screens). */
.chat-members {
    display: none;
    flex-direction: column;
}
.chat-members__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--border);
}
.chat-members__head h2 { display: flex; align-items: center; gap: 0.45rem; margin: 0; font-size: 0.95rem; }
.chat-members__head svg { color: var(--accent-strong); }
.chat-members__list {
    list-style: none;
    margin: 0;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    max-height: min(60vh, 560px);
    overflow-y: auto;
}
.chat-members__list .chat-presence__user { width: 100%; }
.chat-members__list .chat-presence__name { font-size: var(--chat-member-size, 1.05rem); }
.chat-members__empty { padding: 0.75rem 1rem; }

/* Compact menu opened from a member name. */
.chat-user-menu {
    position: fixed;
    z-index: 80;
    min-width: 170px;
    padding: 0.3rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-3);
    box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.7);
}
.chat-user-menu[hidden] { display: none; }
.chat-user-menu__head {
    padding: 0.35rem 0.6rem 0.45rem;
    font-size: 0.8rem;
    color: var(--text-3);
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-user-menu__name { color: var(--text); }
.chat-user-menu__item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.45rem 0.6rem;
    border: 0;
    border-radius: var(--radius-xs);
    background: none;
    color: var(--text-2);
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}
.chat-user-menu__item:hover { background: var(--surface-2); color: var(--text); }
.chat-user-menu__item:disabled { opacity: 0.6; cursor: default; }
.chat-user-menu__item svg { color: var(--accent-strong); flex: none; }

/* Rooms sidebar */
.chat-layout {
    display: grid;
    grid-template-columns: 230px minmax(0, 1fr);
    gap: 0.8rem;
    align-items: start;
}

/* Add the members column on large displays and hide the inline presence row.
   The side columns are kept narrow so the chat itself stays wide. */
@media (min-width: 1000px) {
    .chat-layout { grid-template-columns: 210px minmax(0, 1fr) 180px; }
    .chat-members { display: flex; }
    .chat-presence { display: none; }
}

/* Progressive enhancement: on browsers that support :has(), give the chat page
   a wider canvas than the rest of the site (the topbar follows so it stays
   aligned). Older browsers simply keep the 1120px page with narrower columns. */
@supports selector(:has(*)) {
    body:has(.chat-layout) .topbar__inner { max-width: 1280px; }
    .page:has(.chat-layout) { max-width: 1280px; }
}
.chat-rooms { display: flex; flex-direction: column; }
.chat-rooms__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--border);
}
.chat-rooms__head h2 { display: flex; align-items: center; gap: 0.45rem; margin: 0; font-size: 0.95rem; }
.chat-rooms__head svg { color: var(--accent-strong); }
.chat-rooms__head-actions { display: flex; align-items: center; gap: 0.4rem; }
.chat-rooms__collapse {
    display: none;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xs);
    background: var(--surface-2);
    color: var(--text-2);
    cursor: pointer;
}
.chat-rooms__collapse svg { transition: transform 0.15s var(--ease); }
.chat-rooms__collapse[aria-expanded="false"] svg { transform: rotate(-90deg); }
.chat-rooms__body { display: block; }
.chat-rooms__new,
.chat-rooms__join {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.015);
}
.chat-rooms__new[hidden],
.chat-rooms__join[hidden] { display: none; }
.chat-rooms__join-actions { display: flex; gap: 0.5rem; }
.chat-room-list {
    list-style: none;
    margin: 0;
    padding: 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    max-height: min(60vh, 560px);
    overflow-y: auto;
}
.chat-room__btn {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.5rem 0.6rem;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    text-decoration: none;
    border: 1px solid transparent;
}
.chat-room__btn:hover { background: var(--surface-2); color: var(--text); }
.chat-room.is-active .chat-room__btn { background: var(--accent-soft); border-color: var(--accent-ring); color: var(--text); }
.chat-room__name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.chat-room__lock { color: var(--text-3); flex: none; }
.chat-room__online {
    font-size: 0.74rem;
    color: var(--text-3);
    background: var(--surface-3);
    border-radius: 999px;
    padding: 0.05rem 0.45rem;
    min-width: 1.5em;
    text-align: center;
}
.chat-room-list__empty { padding: 1rem 0.6rem; }
.chat-owner {
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid var(--border);
    background: rgba(111, 140, 255, 0.05);
}
.chat-owner[hidden] { display: none; }
.chat-owner__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    width: 100%;
    padding: 0.55rem 1.3rem;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.chat-owner__head:hover { background: rgba(255, 255, 255, 0.03); }
.chat-owner__title { display: flex; align-items: center; gap: 0.45rem; font-size: 0.9rem; font-weight: 700; }
.chat-owner__title svg { color: var(--accent-strong); }
.chat-owner__caret {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    flex: none;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xs);
    background: var(--surface-2);
    color: var(--text-2);
}
.chat-owner__caret svg { transition: transform 0.15s var(--ease); }
.chat-owner__head[aria-expanded="false"] .chat-owner__caret svg { transform: rotate(-90deg); }
.chat-owner__body {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 0 1.3rem 0.9rem;
}
.chat-owner__body[hidden] { display: none; }
.chat-owner__row { display: flex; align-items: flex-end; gap: 0.5rem; flex-wrap: wrap; }
.chat-owner__row[hidden] { display: none; }
.chat-owner__field { flex: 1; min-width: 160px; }

/* Admin: chat log filters + settings */
.chat-filters { display: flex; gap: 0.8rem; align-items: flex-end; flex-wrap: wrap; padding: 0 1.3rem 1rem; }
.chat-filters .field { flex: 1; min-width: 150px; }
.chat-filters__actions { display: flex; gap: 0.5rem; }
.chat-settings-backup {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    margin-top: 1.2rem;
    padding-top: 1.2rem;
    border-top: 1px solid var(--border);
}

@media (max-width: 900px) {
    .chat-layout { grid-template-columns: 1fr; }
    .chat-rooms__collapse { display: inline-flex; }
    .chat-rooms.is-collapsed .chat-rooms__body { display: none; }
    .chat-rooms__head { padding: 0.7rem 0.9rem; }
    .chat-rooms__new,
    .chat-rooms__join { padding: 0.8rem 0.9rem; }
    .chat-room-list { max-height: 240px; padding: 0.3rem; }
    .chat-room__btn { padding: 0.45rem 0.55rem; }
    .chat-presence__list { flex-wrap: nowrap; overflow-x: auto; }
}

@media (max-width: 640px) {
    .chat-messages { height: min(62dvh, 520px); padding: 1rem; }
    .chat-msg { max-width: 88%; }
    .chat-composer { padding: 0.8rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px)); }
    .chat-composer__send-label { display: none; }
    /* Keep at least 16px on mobile so iOS Safari does not zoom on focus. */
    .chat-composer__input { font-size: max(16px, var(--chat-text-size, 1rem)); }
    .chat-owner__row { flex-direction: column; align-items: stretch; }
    .chat-owner__row .btn { width: 100%; }
    .chat-rooms__join-actions { flex-direction: column; }
    .chat-rooms__join-actions .btn { width: 100%; }
}

/* ---------- Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

/* ---- Language picker (settings) ---- */
.lang-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.lang-option {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.lang-option:hover {
    border-color: var(--accent-ring);
}
.lang-option input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}
.lang-option__label {
    font-weight: 500;
    color: var(--text);
}
.lang-option__check {
    display: inline-flex;
    opacity: 0;
    color: var(--accent);
    transition: opacity 0.15s var(--ease);
}
.lang-option.is-active {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.lang-option.is-active .lang-option__check {
    opacity: 1;
}
.lang-option:focus-within {
    outline: 2px solid var(--accent-ring);
    outline-offset: 2px;
}
/* Compact variant used in the one-row language header. */
.lang-picker--compact { gap: 0.4rem; }
.lang-picker--compact .lang-option { padding: 0.3rem 0.55rem; gap: 0.4rem; }
.lang-picker--compact .lang-option__label { font-size: 0.88rem; }
.flag {
    display: inline-block;
    border-radius: 3px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18);
    vertical-align: middle;
}

/* ---------- BBCode (private messages) ---------- */
.bb-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
    padding: 0.35rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.02);
}
.bb-toolbar__buttons,
.bb-toolbar__right {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    flex-wrap: wrap;
}
.bb-toolbar__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.35rem;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--text-2);
    font: inherit;
    cursor: pointer;
}
.bb-toolbar__btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
}
.bb-toolbar__btn[aria-pressed="true"] {
    background: var(--accent-soft);
    color: var(--accent-strong);
    border-color: var(--accent-ring);
}
.bb-toolbar__btn:focus-visible {
    outline: 2px solid var(--accent-ring);
    outline-offset: 1px;
}
.bb-toolbar__btn--text {
    width: auto;
    padding: 0 0.55rem;
    font-size: 0.85rem;
    font-weight: 600;
}
.bb-help {
    margin: 0.5rem 0;
    padding: 0.8rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}
.bb-help__title {
    margin: 0 0 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
}
.bb-help__list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.3rem 1rem;
    margin: 0 0 0.5rem;
    padding: 0;
    list-style: none;
}
.bb-help__list li {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.85rem;
}
.bb-help__list code {
    padding: 0.1rem 0.4rem;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.78rem;
}
.bb-help__list span { color: var(--text-2); }
.bb-preview {
    margin-top: 0.5rem;
    padding: 0.9rem 1rem;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.015);
    color: var(--text);
    line-height: 1.6;
    overflow-wrap: break-word;
}
.bb-preview--empty { color: var(--text-2); font-style: italic; }
.bb-quote {
    margin: 0.5rem 0;
    padding: 0.5rem 0.9rem;
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    background: var(--accent-soft);
    color: var(--text);
}
.bb-quote__cite {
    display: block;
    margin-bottom: 0.15rem;
    font-style: normal;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--accent-strong);
}
.bb-code {
    margin: 0.5rem 0;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.25);
    overflow-x: auto;
    white-space: pre;
}
.bb-code code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85rem;
    color: var(--text);
}
.bb-list {
    margin: 0.4rem 0;
    padding-left: 1.4rem;
}
ul.bb-list { list-style: disc; }
ol.bb-list { list-style: decimal; }
.bb-list li { margin: 0.15rem 0; }
.bb-tt {
    padding: 0.05rem 0.35rem;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.88em;
}
/* Fixed BBCode colour palette, shared by text spans and the picker swatches. */
:root {
    --bb-color-red: #ff7b72;
    --bb-color-orange: #ffa657;
    --bb-color-yellow: #e3b341;
    --bb-color-green: #7ee787;
    --bb-color-teal: #58d3c0;
    --bb-color-cyan: #5bd6e6;
    --bb-color-blue: #79c0ff;
    --bb-color-indigo: #a3a8ff;
    --bb-color-purple: #d2a8ff;
    --bb-color-pink: #ff9bce;
    --bb-color-brown: #caa472;
    --bb-color-gray: #9aa4b2;
}
.bb-color--red { color: var(--bb-color-red); }
.bb-color--orange { color: var(--bb-color-orange); }
.bb-color--yellow { color: var(--bb-color-yellow); }
.bb-color--green { color: var(--bb-color-green); }
.bb-color--teal { color: var(--bb-color-teal); }
.bb-color--cyan { color: var(--bb-color-cyan); }
.bb-color--blue { color: var(--bb-color-blue); }
.bb-color--indigo { color: var(--bb-color-indigo); }
.bb-color--purple { color: var(--bb-color-purple); }
.bb-color--pink { color: var(--bb-color-pink); }
.bb-color--brown { color: var(--bb-color-brown); }
.bb-color--gray { color: var(--bb-color-gray); }
.bb-size--small { font-size: 0.85em; }
.bb-size--medium { font-size: 1em; }
.bb-size--large { font-size: 1.3em; }
.bb-center { text-align: center; }
.bb-hr {
    margin: 0.8rem 0;
    border: 0;
    border-top: 1px solid var(--border-strong);
}
.bb-spoiler {
    margin: 0.5rem 0;
    padding: 0.35rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.02);
}
.bb-spoiler > summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--text-2);
    list-style: none;
}
.bb-spoiler > summary::-webkit-details-marker { display: none; }
.bb-spoiler > summary::before {
    content: "▸ ";
    color: var(--accent-strong);
}
.bb-spoiler[open] > summary::before { content: "▾ "; }
.bb-spoiler[open] > summary { margin-bottom: 0.4rem; }

/* Admin PM archive: the list shows a short, clamped preview; the full message
   opens in the same compact viewer as the user-level message view. */
.pm-preview {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    overflow-wrap: anywhere;
    color: var(--text-2);
}
.bb-picker {
    position: relative;
    display: inline-flex;
}
.bb-picker__panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(4, 1.15rem);
    gap: 0.35rem;
    padding: 0.45rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}
.bb-picker__panel[hidden] { display: none; }
.bb-swatch {
    width: 1.15rem;
    height: 1.15rem;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 50%;
    cursor: pointer;
}
.bb-swatch:hover { transform: scale(1.15); }
.bb-swatch:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 2px; }
.bb-swatch--red { background: var(--bb-color-red); }
.bb-swatch--orange { background: var(--bb-color-orange); }
.bb-swatch--yellow { background: var(--bb-color-yellow); }
.bb-swatch--green { background: var(--bb-color-green); }
.bb-swatch--teal { background: var(--bb-color-teal); }
.bb-swatch--cyan { background: var(--bb-color-cyan); }
.bb-swatch--blue { background: var(--bb-color-blue); }
.bb-swatch--indigo { background: var(--bb-color-indigo); }
.bb-swatch--purple { background: var(--bb-color-purple); }
.bb-swatch--pink { background: var(--bb-color-pink); }
.bb-swatch--brown { background: var(--bb-color-brown); }
.bb-swatch--gray { background: var(--bb-color-gray); }
