/* PichFans — an Apple-inspired interface.
   Local system fonts and calm surfaces, with palettes for the existing theme
   classes. Existing selectors and application visibility hooks are retained. */

:root,
body.dark-mode,
body.darkblue-mode {
    color-scheme: only light;
    --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
    --bg-primary: #F5F5F7;
    --bg-secondary: #FFFFFF;
    --surface: #FFFFFF;
    --surface-alt: #F5F5F7;
    --surface-muted: #EDEDF0;
    --surface-glass: rgb(255 255 255 / 88%);
    --text-primary: #1D1D1F;
    --text-secondary: #626267;
    --text-dim: #6E6E73;
    --border-color: #E2E2E7;
    --border-strong: #86868B;
    --border-soft: #EDEDF0;
    --accent-color: #007AFF;
    --accent-hover: #005BBF;
    --accent-border: #0066D6;
    --accent-soft: #EDF5FF;
    --accent-soft-hover: #E0EEFF;
    --accent-contrast: #FFFFFF;
    /* A slightly deeper action blue keeps small white button labels legible. */
    --action-bg: #0066D6;
    --link-color: #0066CC;
    --focus: rgb(0 122 255 / 18%);
    --button-bg: #FFFFFF;
    --button-hover: #F5F5F7;
    --input-bg: #FFFFFF;
    --card-bg: var(--surface);
    --card-alt: var(--surface-alt);
    --row-even: #FAFAFC;
    --row-hover: #F0F6FF;
    --success: #247843;
    --success-dark: #21683B;
    --success-color: var(--success-dark);
    --success-bg: #EFF8F1;
    --success-border: #CEE6D4;
    --warning: #805500;
    --warning-bg: #FFF8E8;
    --warning-border: #F0DFB1;
    --danger: #C9342B;
    --danger-dark: #B4231B;
    --error-color: var(--danger-dark);
    --danger-bg: #FFF2F1;
    --error-bg: var(--danger-bg);
    --danger-border: #F1CCC8;
    --info-text: #215B91;
    --info-bg: #EFF6FF;
    --info-border: #D1E3F6;
    --shadow-xs: 0 1px 3px rgb(29 29 31 / 5%);
    --shadow-sm: 0 2px 6px rgb(29 29 31 / 3%), 0 8px 24px rgb(29 29 31 / 4%);
    --shadow-md: 0 8px 24px rgb(29 29 31 / 6%), 0 24px 64px rgb(29 29 31 / 8%);
    --radius-sm: 12px;
    --radius-md: 20px;
    --radius-lg: 28px;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;
    --page-width: 1200px;
    --ease-out: cubic-bezier(.22, 1, .36, 1);
    --duration-fast: 160ms;
    --duration-normal: 240ms;
    --control-transition: color var(--duration-fast) ease, background-color var(--duration-fast) ease,
        border-color var(--duration-fast) ease, box-shadow var(--duration-normal) ease,
        transform var(--duration-fast) var(--ease-out);
}

/* Follow the existing body theme classes; keep the root canvas in sync. */

:root:has(> body:is(.dark-mode, .darkblue-mode)),
body.dark-mode,
body.darkblue-mode {
    color-scheme: dark;
    --theme-color-scheme: dark;
    --bg-primary: #1C1C1E;
    --bg-secondary: var(--surface);
    --surface: #2C2C2E;
    --surface-alt: #242426;
    --surface-muted: #3A3A3C;
    --surface-glass: rgb(44 44 46 / 88%);
    --text-primary: #F5F5F7;
    --text-secondary: #B8B8BF;
    --text-dim: #A1A1AA;
    --border-color: #454549;
    --border-strong: #777780;
    --border-soft: #38383D;
    --accent-color: #64ABFF;
    --accent-hover: #8CC2FF;
    --accent-border: #4598F0;
    --accent-soft: #18344F;
    --accent-soft-hover: #214564;
    --accent-contrast: #101820;
    --action-bg: #64ABFF;
    --link-color: #79B8FF;
    --focus: rgb(100 171 255 / 30%);
    --button-bg: var(--surface);
    --button-hover: var(--surface-muted);
    --input-bg: var(--surface-alt);
    --row-even: #28282B;
    --row-hover: #24374D;
    --success: #86D99F;
    --success-dark: #9CE7B2;
    --success-bg: #193426;
    --success-border: #315D42;
    --warning: #F3CE77;
    --warning-bg: #382F1C;
    --warning-border: #665331;
    --danger: #FF8E85;
    --danger-dark: #FFA79F;
    --danger-bg: #3D2325;
    --danger-border: #71403F;
    --info-text: #9CCFFF;
    --info-bg: #1B3048;
    --info-border: #385579;
    --shadow-xs: 0 1px 3px rgb(0 0 0 / 18%);
    --shadow-sm: 0 2px 6px rgb(0 0 0 / 12%), 0 8px 24px rgb(0 0 0 / 18%);
    --shadow-md: 0 8px 24px rgb(0 0 0 / 24%), 0 24px 64px rgb(0 0 0 / 32%);
    --selection-bg: #285078;
    --navbar-border: rgb(255 255 255 / 8%);
    --navbar-shadow: 0 1px 12px rgb(0 0 0 / 18%);
    --avatar-border: rgb(100 171 255 / 20%);
    --border-hover: #68686F;
    --thread-border: #58585F;
    --tab-shadow: 0 1px 4px rgb(0 0 0 / 20%);
    --drawer-shadow: -12px 0 48px rgb(0 0 0 / 30%);
    --overlay-bg: rgb(12 12 16 / 72%);
    --overlay-reduced-bg: rgb(12 12 16 / 92%);
    --video-play-border: rgb(255 255 255 / 18%);
}

:root:has(> body.darkblue-mode),
body.darkblue-mode {
    --bg-primary: #0D1726;
    --surface: #152338;
    --surface-alt: #101E31;
    --surface-muted: #21354E;
    --surface-glass: rgb(21 35 56 / 88%);
    --text-primary: #EDF4FF;
    --text-secondary: #B2C3D9;
    --text-dim: #96ABC4;
    --border-color: #30465F;
    --border-strong: #6F87A3;
    --border-soft: #243950;
    --row-even: #132136;
    --row-hover: #1D3652;
    --border-hover: #5D7898;
    --thread-border: #425E7C;
    --overlay-bg: rgb(5 12 23 / 72%);
    --overlay-reduced-bg: rgb(5 12 23 / 92%);
}

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

html {
    -webkit-text-size-adjust: 100%;
    min-width: 280px;
    scroll-padding-top: 100px;
    text-rendering: optimizeLegibility;
    background: var(--bg-primary);
    color-scheme: only light;
}

body {
    margin: 0;
    -webkit-font-smoothing: antialiased;
    min-height: 100svh;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    font-kerning: normal;
    font-family: var(--font-sans) !important;
    letter-spacing: -.012em;
    color-scheme: only light;
}

::selection {
    color: var(--text-primary);
    background: var(--selection-bg, #D6E8FF);
}

a {
    color: var(--link-color);
    text-decoration: none;
    text-underline-offset: .2em;
    text-decoration-thickness: 1px;
    transition: color var(--duration-fast) ease;
}

a:hover,
a:focus {
    color: var(--accent-hover);
    text-decoration: underline;
}

img,
video,
audio {
    max-width: 100%;
}

p {
    margin: 0 0 var(--space-4);
}

h1,
h2,
h3,
h4 {
    color: var(--text-primary);
    margin: 0 0 var(--space-3);
    line-height: 1.25;
    font-weight: 600;
    text-wrap: pretty;
}

h1 {
    font-size: clamp(28px, 3.4vw, 40px);
    font-weight: 600;
    letter-spacing: -.045em;
}

h2 {
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -.035em;
}

h3,
h4 {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -.015em;
}

:where(a,button,input,textarea,select,[tabindex]):focus-visible {
    outline: 3px solid var(--accent-color) !important;
    outline-offset: 3px;
    box-shadow: 0 0 0 5px var(--focus);
}

/* Header and navigation */

.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: var(--space-5);
    min-height: 72px;
    margin: 0;
    padding: 14px max(24px, calc((100% - var(--page-width)) / 2));
    border: 0;
    border-bottom: 1px solid var(--navbar-border, rgb(29 29 31 / 8%));
    border-radius: 0;
    background: var(--surface-glass);
    box-shadow: var(--navbar-shadow, 0 1px 12px rgb(29 29 31 / 2%));
    -webkit-backdrop-filter: saturate(160%) blur(20px);
    backdrop-filter: saturate(160%) blur(20px);
}

.navbar::before,
.navbar::after,
.navbar-brand::before {
    content: none;
}

.navbar-brand {
    display: inline-block;
    flex: 0 0 auto;
    color: var(--text-primary);
    text-shadow: none;
    white-space: nowrap;
    font-size: 23px;
    font-weight: 650;
    letter-spacing: -.055em;
    line-height: 1.3;
}

body.dark-mode .navbar-brand,
body.darkblue-mode .navbar-brand {
    color: var(--text-primary);
}

.navbar-user {
    display: flex;
    flex: 0 1 auto;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
    padding: 0;
    border: 0;
    background: transparent;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.nav-link,
button.nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    box-shadow: none;
    text-decoration: none;
    text-shadow: none;
    white-space: nowrap;
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
    padding: 10px 14px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    font: 500 14px/1.3 var(--font-sans);
    transition: var(--control-transition);
}

.nav-link:hover,
.nav-link:focus-visible {
    border-color: transparent;
    color: var(--text-primary);
    background: var(--surface-alt);
}

.nav-link.primary {
    color: var(--link-color);
    background: var(--accent-soft);
    border-color: transparent;
    font-weight: 600;
}

.nav-link.primary:hover {
    border-color: transparent;
    background: var(--accent-soft-hover);
    transform: none;
    box-shadow: none;
    color: var(--accent-hover);
}

.nav-link:active {
    box-shadow: none;
    transform: scale(.98);
}

.theme-toggle {
    padding: 9px 10px;
}

.theme-icon {
    display: block;
    filter: none;
    transition: transform var(--duration-normal) var(--ease-out);
}

.theme-toggle:hover .theme-icon {
    transform: rotate(-8deg);
}

/* Layout, panels and sidebar */

.container {
    display: flex;
    flex: 1 1 auto;
    gap: var(--space-6);
    width: min(var(--page-width), calc(100% - 48px));
    max-width: var(--page-width);
    margin: 40px auto 64px;
    padding: 0;
    align-items: flex-start;
}

.sidebar {
    position: sticky;
    height: fit-content;
    top: 104px;
    flex: 0 0 240px;
    width: 240px;
}

.main-content {
    flex: 1 1 auto;
    width: 0;
    min-width: 0;
    max-width: 100%;
}

.card,
.sidebar-section,
.auth-card,
.pagination-container,
.admin-contact-card,
.hosting-note,
.reaction-picker,
.comment-reaction-picker,
.reaction-tooltip-content {
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.card,
.sidebar-section,
.auth-card,
.admin-contact-card {
    position: relative;
    overflow: visible;
}

.card::before,
.sidebar-section::before,
.auth-card::before,
.admin-contact-card::before {
    content: none;
}

.card>*,
.sidebar-section>*,
.auth-card>*,
.admin-contact-card>* {
    position: relative;
    z-index: auto;
}

.card {
    margin: 0 0 var(--space-5);
    padding: 28px;
    transition: border-color var(--duration-normal) ease, box-shadow var(--duration-normal) ease;
}

.sidebar-section {
    margin: 0 0 var(--space-4);
    padding: var(--space-4);
    background: var(--surface);
    border-color: var(--border-color);
}

.sidebar-title,
.section-title,
.admin-contact-title {
    display: block;
    border: 0;
    border-bottom: 0;
    border-radius: 0;
    color: var(--text-primary);
    background: transparent;
    box-shadow: none;
    line-height: 1.3;
    text-shadow: none;
    margin: 0 0 var(--space-5);
    padding: 0;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -.03em;
}

.sidebar-title {
    color: var(--text-secondary);
    text-transform: none;
    margin: var(--space-2) var(--space-2) var(--space-3);
    padding: 0;
    font-size: 12px;
    letter-spacing: .04em;
    font-weight: 600;
    border-bottom: 0;
}

.sidebar-link,
.friend-item {
    display: flex;
    align-items: center;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    background: transparent;
    text-decoration: none;
    cursor: pointer;
    transition: var(--control-transition);
    gap: var(--space-3);
    min-height: 48px;
    margin: 2px 0;
    padding: 11px 12px;
    font-size: 14px;
    font-weight: 500;
}

.sidebar-link span:first-child {
    width: 21px;
    text-align: center;
    font-size: 17px;
    opacity: .85;
}

.sidebar-link:hover,
.friend-item:hover {
    border-color: transparent;
    color: var(--text-primary);
    background: var(--surface-alt);
}

.sidebar-link.active {
    border-color: transparent;
    color: var(--link-color);
    background: var(--accent-soft);
    font-weight: 600;
}

body.dark-mode .sidebar-link.active,
body.darkblue-mode .sidebar-link.active {
    color: var(--link-color);
    background: var(--accent-soft);
    border-color: transparent;
}

.sidebar-link.active::after {
    content: "\203a";
    margin-left: auto;
    color: var(--link-color);
    font-size: 18px;
}

.friend-request {
    display: flex;
    align-items: center;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    background: var(--surface-alt);
    gap: var(--space-2);
    margin: var(--space-2) 0;
    padding: var(--space-3);
    border-color: transparent;
    flex-wrap: wrap;
}

.friend-request-actions {
    display: flex;
    margin-left: auto;
    gap: var(--space-1);
}

.friend-name {
    min-width: 0;
    overflow: hidden;
    color: var(--text-primary);
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    font-weight: 500;
}

/* Account pictures */

.post-avatar,
.comment-avatar,
.friend-avatar,
.friend-grid-avatar,
.profile-avatar-big,
.user-avatar,
.avatar-preview {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    text-shadow: none;
    border: 1px solid var(--avatar-border, rgb(0 102 204 / 10%));
    border-radius: 50%;
    color: var(--link-color);
    background: var(--accent-soft);
    box-shadow: none;
    font-weight: 600;
}

.post-avatar {
    width: 48px;
    height: 48px;
    font-size: 18px;
}

.comment-avatar,
.friend-avatar {
    width: 36px;
    height: 36px;
    font-size: 14px;
}

.friend-grid-avatar {
    width: 56px;
    height: 56px;
    font-size: 20px;
}

.profile-avatar-big {
    width: 104px;
    height: 104px;
    font-size: 34px;
    box-shadow: 0 0 0 5px var(--surface), var(--shadow-sm);
}

.user-avatar {
    width: 64px;
    height: 64px;
    font-size: 24px;
}

.avatar-preview {
    cursor: pointer;
    width: 80px;
    height: 80px;
    font-size: 28px;
}

.avatar-preview-letter {
    color: var(--link-color);
    font-size: 28px;
    font-weight: 600;
}

.post-avatar img,
.comment-avatar img,
.friend-avatar img,
.friend-grid-avatar img,
.profile-avatar-big img,
.user-avatar img,
.avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-upload-wrapper {
    position: relative;
}

.avatar-upload-overlay {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    right: -2px;
    bottom: -2px;
    width: 30px;
    height: 30px;
    color: var(--accent-contrast);
    background: var(--action-bg);
    box-shadow: 0 0 0 3px var(--surface);
    font-size: 13px;
}

.avatar-input,
input[type=file] {
    display: none;
}

/* Consistent, rounded forms and controls */

label {
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
}

.form-group {
    margin-bottom: var(--space-5);
}

.form-group>label {
    display: block;
    margin-bottom: var(--space-2);
}

input,
textarea,
select {
    max-width: 100%;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    background: var(--input-bg);
    outline: none;
    min-width: 0;
    font: 400 15px/1.5 var(--font-sans);
    border: 1px solid var(--border-strong);
    box-shadow: none;
    transition: var(--control-transition);
    caret-color: var(--accent-color);
}

input[type=text],
input[type=email],
input[type=password],
input[type=url],
input[type=search],
textarea,
select {
    min-height: 48px;
    padding: 12px 15px;
}

textarea {
    resize: vertical;
    line-height: 1.65;
}

input::placeholder,
textarea::placeholder {
    color: var(--text-dim);
    opacity: 1;
}

input:hover,
textarea:hover,
select:hover {
    border-color: var(--text-secondary);
}

input:focus,
textarea:focus,
select:focus {
    background: var(--surface);
    border-color: var(--accent-color);
    box-shadow: 0 0 0 4px var(--focus);
}

input[type=checkbox],
input[type=radio] {
    accent-color: var(--accent-color);
    cursor: pointer;
    width: 17px !important;
    height: 17px !important;
    min-height: 17px;
    margin: 0;
    vertical-align: middle;
    padding: 0;
    flex-shrink: 0;
    box-shadow: none;
}

select {
    cursor: pointer;
    min-width: 0;
}

button,
.btn,
.search-btn,
.search-clear,
.pagination-btn,
.per-page-btn,
.media-tab,
.file-input-label,
.add-friend-btn,
.friend-action-btn,
.btn-accept,
.btn-reject,
.comment-btn,
.comment-image-btn,
.comment-reaction-main-btn,
.reaction-main-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    background: var(--button-bg);
    text-decoration: none;
    text-shadow: none;
    cursor: pointer;
    min-height: 44px;
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    font: 500 14px/1.3 var(--font-sans);
    box-shadow: var(--shadow-xs);
    transition: var(--control-transition);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    gap: 6px;
}

button::before,
.btn::before,
.search-btn::before,
.pagination-btn::before,
.per-page-btn::before,
.media-tab::before,
.file-input-label::before,
.reaction-main-btn::before {
    content: none;
}

button:hover,
.btn:hover,
.search-btn:hover,
.search-clear:hover,
.pagination-btn:hover:not(.disabled),
.per-page-btn:hover,
.media-tab:hover,
.file-input-label:hover,
.add-friend-btn:hover,
.friend-action-btn:hover,
.btn-accept:hover,
.btn-reject:hover,
.comment-btn:hover,
.comment-image-btn:hover,
.comment-reaction-main-btn:hover,
.reaction-main-btn:hover {
    background: var(--button-hover);
    box-shadow: var(--shadow-xs);
    color: var(--text-primary);
    border-color: var(--border-hover, #C7C7CC);
}

button:active,
.btn:active,
.search-btn:active,
.search-clear:active,
.pagination-btn:active,
.media-tab:active,
.reaction-main-btn:active,
.comment-reaction-main-btn:active,
.comment-btn:active {
    box-shadow: none;
    transform: scale(.98);
    background: var(--button-hover);
}

.btn,
.search-btn,
.comment-btn,
.add-friend-btn,
.btn-accept,
.friend-action-btn.add,
.friend-action-btn.accept,
.pagination-btn.active,
.per-page-btn.active,
.media-tab.active,
.reaction-main-btn.active,
.comment-reaction-main-btn.active {
    border-color: var(--accent-border);
    color: var(--accent-contrast);
    background: var(--action-bg);
    box-shadow: var(--shadow-xs);
    font-weight: 600;
}

.btn:hover,
.search-btn:hover,
.comment-btn:hover,
.add-friend-btn:hover,
.btn-accept:hover,
.friend-action-btn.add:hover,
.friend-action-btn.accept:hover,
.pagination-btn.active:hover,
.per-page-btn.active:hover,
.media-tab.active:hover {
    border-color: var(--accent-hover);
    color: var(--accent-contrast);
    background: var(--accent-hover);
    box-shadow: var(--shadow-xs);
    transform: none;
}

.btn {
    width: 100%;
    min-height: 48px;
    padding: 13px 20px;
    font-size: 15px;
    margin-top: 0;
    border-radius: var(--radius-sm);
}

.btn-secondary {
    width: auto;
    margin-top: var(--space-2);
    color: var(--text-primary);
    background: var(--button-bg);
    border-color: var(--border-color);
}

.btn-accept,
.btn-reject {
    min-width: 36px;
    min-height: 36px;
    padding: 7px;
}

.add-friend-btn,
.friend-action-btn {
    min-height: 40px;
    padding: 9px 14px;
    border-radius: 999px;
    font-size: 13px;
}

.btn-reject,
.friend-action-btn.remove,
.post-delete,
.comment-delete,
.comment-image-remove {
    border-color: transparent;
    color: var(--danger-dark);
    background: var(--danger-bg);
    box-shadow: none;
}

.btn-reject:hover,
.friend-action-btn.remove:hover,
.post-delete:hover,
.comment-delete:hover,
.comment-image-remove:hover {
    border-color: var(--danger);
    color: var(--danger-dark);
    background: var(--danger-bg);
}

button:disabled,
.disabled,
.friend-action-btn.pending {
    color: var(--text-dim);
    background: var(--surface-muted);
    box-shadow: none;
    cursor: not-allowed;
    pointer-events: none;
    opacity: .7;
    border-color: var(--border-color);
    transform: none;
}

.hint,
.external-url-hint,
.filename-display,
.search-info {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.6;
}

.hint,
.external-url-hint {
    margin-top: var(--space-2);
}

/* Authentication and status messages */

.auth-card {
    width: min(460px, 100%);
    max-width: 460px;
    padding: 44px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.auth-logo {
    padding: 0;
    border: 0;
    color: var(--text-primary);
    background: transparent;
    text-align: center;
    text-shadow: none;
    margin: 0 0 var(--space-2);
    font-size: 34px;
    font-weight: 650;
    letter-spacing: -.055em;
}

.auth-logo::before {
    content: none;
}

body.dark-mode .auth-logo,
body.darkblue-mode .auth-logo {
    color: var(--text-primary);
}

.auth-subtitle {
    color: var(--text-secondary);
    text-align: center;
    margin: 0 0 var(--space-6);
    font-size: 15px;
    line-height: 1.6;
}

.auth-footer {
    color: var(--text-secondary);
    text-align: center;
    margin-top: var(--space-5);
    padding-top: var(--space-5);
    border-top: 1px solid var(--border-soft);
    font-size: 14px;
}

.auth-footer a {
    color: var(--link-color);
    font-weight: 550;
}

.alert,
.login-prompt,
.external-media-error {
    position: relative;
    border: 1px solid var(--info-border);
    border-radius: var(--radius-sm);
    color: var(--info-text);
    background: var(--info-bg);
    box-shadow: none;
    margin: 0 0 var(--space-4);
    padding: 16px 18px;
    font-size: 14px;
    line-height: 1.6;
}

.alert::before,
.login-prompt::before,
.external-media-error::before {
    content: none;
}

.alert-error,
.external-media-error {
    border-color: var(--danger-border);
    color: var(--danger-dark);
    background: var(--danger-bg);
}

.alert-success {
    border-color: var(--success-border);
    color: var(--success-dark);
    background: var(--success-bg);
}

.login-prompt {
    text-align: center;
}

.hosting-note {
    position: relative;
    color: var(--text-secondary);
    margin: 0 0 var(--space-4);
    padding: var(--space-5);
    background: var(--surface);
    font-size: 13px;
}

.hosting-note::before {
    content: none;
}

.hosting-note strong {
    color: var(--text-primary);
}

/* Composer, upload tabs and posts */

.profile-section {
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-soft);
    background: transparent;
    gap: var(--space-4);
    margin: 0 0 var(--space-5);
    padding: 0 0 var(--space-5);
}

.post-form textarea {
    width: 100%;
    min-height: 128px;
    margin: 0 0 var(--space-3);
    padding: 20px;
    font-size: 16px;
    background: var(--surface-alt);
    border-color: var(--border-color);
    border-radius: var(--radius-md);
}

.anonymous-option {
    display: flex;
    align-items: center;
    width: fit-content;
    max-width: 100%;
    color: var(--text-secondary);
    cursor: pointer;
    gap: var(--space-2);
    min-height: 40px;
    margin: 0 0 var(--space-3);
    font-size: 13px;
}

.anonymous-option-compact {
    min-height: 24px;
    margin: 0;
}

.anonymous-option-locked {
    cursor: default;
}

.anonymous-option-locked>span:first-child,
.anonymous-name {
    color: var(--text-secondary);
}

.media-upload-tabs {
    display: flex;
    border-radius: 14px;
    gap: 4px;
    margin: 0 0 var(--space-3);
    padding: 5px;
    border: 0;
    background: var(--surface-alt);
    width: fit-content;
    max-width: 100%;
}

.media-tab {
    box-shadow: none;
    min-height: 38px;
    padding: 9px 16px;
    border-color: transparent;
    border-radius: 10px;
    color: var(--text-secondary);
    background: transparent;
    font-size: 13px;
}

.media-tab.active {
    transform: none;
    border-color: transparent;
    background: var(--surface);
    color: var(--text-primary);
    box-shadow: var(--tab-shadow, 0 1px 4px rgb(29 29 31 / 10%));
    font-weight: 600;
}

.media-upload-content {
    display: none;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    margin: 0 0 var(--space-4);
    padding: 20px;
    background: var(--surface-alt);
}

.media-upload-content.active {
    display: block;
    animation: surface-reveal var(--duration-fast) var(--ease-out) both;
}

.file-input-wrapper {
    margin: 0;
}

.file-input-label {
    display: inline-flex;
    padding: 11px 16px;
}

.filename-display {
    display: inline-block;
    margin-left: var(--space-3);
    overflow-wrap: anywhere;
}

.external-url-input {
    width: 100%;
}

.post {
    margin-bottom: var(--space-5);
    padding: 28px;
}

.post-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: transparent;
    box-shadow: none;
    gap: var(--space-4);
    min-height: 48px;
    margin: 0 0 20px;
    padding: 0;
    border-bottom: 0;
}

.post-author {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: var(--space-3);
}

.post-author.anonymous-author,
.post-author.anonymous-author .post-info,
.post-info {
    min-width: 0;
}

.post-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.post-username,
a.post-username {
    overflow-wrap: anywhere;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 15px;
    font-weight: 600;
}

.post-username:hover {
    color: var(--accent-hover);
    text-decoration: none;
}

.post-time {
    font-size: 12px;
    color: var(--text-dim);
}

.post-delete,
.comment-delete {
    display: inline-flex;
    font-size: 10px;
    font-weight: 650;
    text-decoration: none;
    cursor: pointer;
    min-height: 36px;
    padding: 7px 11px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font: 500 12px/1.3 var(--font-sans);
    color: var(--danger-dark);
    background: var(--danger-bg);
}

.post-content {
    color: var(--text-primary);
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    margin: 0 0 var(--space-4);
    padding: 0;
    font-size: 16px;
    line-height: 1.75;
}

.post-image,
.post-external-media,
.post-external-video,
.post-external-audio,
.comment-image {
    display: block;
    width: 100%;
    background: var(--surface-alt);
    box-shadow: none;
    margin: var(--space-4) 0 0;
    border: 1px solid var(--border-soft);
    border-radius: 16px;
}

.post-external-media {
    object-fit: contain;
    max-height: 640px;
}

.post-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    border-top: 1px solid var(--border-soft);
    gap: var(--space-2);
    margin: var(--space-5) 0 0;
    padding: var(--space-4) 0 0;
}

.reaction-container,
.comment-reaction-container {
    position: relative;
    display: inline-block;
}

.reaction-main-btn {
    gap: 8px;
    min-height: 42px;
    padding: 10px 14px;
    border-radius: 999px;
    border-color: transparent;
    background: var(--surface-alt);
    box-shadow: none;
}

.reaction-icon {
    font-size: 16px;
}

.reaction-text {
    font-size: 13px;
}

.reaction-picker,
.comment-reaction-picker {
    position: absolute;
    left: 0;
    z-index: 1000;
    display: none;
    white-space: nowrap;
    gap: 4px;
    padding: 8px;
    border-radius: 999px;
    bottom: calc(100% + 10px);
    box-shadow: var(--shadow-md);
    opacity: 1;
    transform: none;
    animation: none;
    background: var(--surface-glass);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
}

.reaction-picker.show,
.comment-reaction-picker.show {
    display: flex;
    animation: surface-reveal var(--duration-fast) var(--ease-out) both;
}

.reaction-picker-item,
.comment-reaction-picker-item {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    min-width: 42px;
    min-height: 42px;
    padding: 6px;
    border-radius: 50%;
    font-size: 22px;
    color: var(--text-primary);
    transition: var(--control-transition);
}

.reaction-picker-item:hover,
.comment-reaction-picker-item:hover {
    border-color: var(--border-color);
    background: var(--surface-muted);
    transform: translateY(-2px);
}

.reaction-count {
    color: var(--text-secondary);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.reaction-tooltip {
    position: relative;
    display: inline-block;
}

.reaction-tooltip-content {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    z-index: 1000;
    visibility: hidden;
    color: var(--text-primary);
    text-align: left;
    opacity: 0;
    min-width: 160px;
    max-width: min(280px, calc(100vw - 32px));
    padding: 14px 16px;
    font-size: 13px;
    white-space: normal;
    overflow-wrap: anywhere;
    transform: translateY(4px);
    transition: opacity var(--duration-fast) ease, transform var(--duration-fast) var(--ease-out), visibility var(--duration-fast) ease;
    box-shadow: var(--shadow-md);
    background: var(--surface-glass);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
}

.reaction-tooltip-content::after {
    content: none;
}

.reaction-tooltip:hover .reaction-tooltip-content {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
}

.reaction-list {
    overflow-y: auto;
    max-height: 200px;
    overscroll-behavior: contain;
}

.reaction-user {
    border-bottom: 1px solid var(--border-soft);
    padding: 6px 0;
}

.reaction-user:last-child {
    border-bottom: 0;
}

/* Threaded comments */

.comments-section {
    border-top: 1px solid var(--border-soft);
    background: transparent;
    margin: var(--space-4) 0 0;
    padding: var(--space-4) 0 0;
}

.comments-section:empty {
    display: none;
}

.comment {
    display: flex;
    box-shadow: none;
    gap: var(--space-3);
    margin: 0 0 var(--space-3);
    padding: 14px;
    border: 1px solid transparent;
    border-radius: 16px;
    background: var(--surface-alt);
}

.comment.reply {
    margin-left: 40px;
    background: var(--surface-alt);
    border-left: 2px solid var(--thread-border, #D2D2D7);
}

.comment>div[style] {
    min-width: 0;
}

.comment-content {
    border-radius: var(--radius-sm);
    box-shadow: none;
    padding: 2px 0;
    border: 0;
    background: transparent;
}

.comment-author,
a.comment-author {
    margin-bottom: 1px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
}

.comment-author:hover {
    text-decoration: underline;
}

.comment-text {
    color: var(--text-primary);
    overflow-wrap: anywhere;
    font-size: 15px;
    line-height: 1.65;
}

.comment-image {
    cursor: pointer;
    max-width: 340px;
}

.comment-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin: var(--space-2) 0 0;
}

.comment-time,
.comment-reaction-count {
    color: var(--text-secondary);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.comment-action-btn {
    border: 0;
    background: transparent;
    box-shadow: none;
    text-shadow: none;
    min-height: 32px;
    padding: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.comment-action-btn::before {
    content: none;
}

.comment-action-btn:hover {
    color: var(--accent-hover);
    background: transparent;
    text-decoration: underline;
}

.comment-reactions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-1);
}

.comment-reaction-main-btn {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 999px;
    border-color: transparent;
    background: var(--surface);
    box-shadow: none;
}

.comment-reaction-picker {
    bottom: calc(100% + 5px);
}

.comment-reaction-picker-item {
    min-width: 36px;
    min-height: 36px;
    font-size: 20px;
}

.comment-form {
    display: none;
    align-items: flex-start;
    gap: var(--space-3);
    margin-top: var(--space-3);
}

.comment-form-wrapper {
    flex: 1;
    min-width: 0;
}

.comment-input-wrapper {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.comment-input {
    flex: 1;
    min-height: 44px;
    width: auto;
    min-width: 0;
    border-radius: 999px;
}

.comment-btn,
.comment-image-btn {
    flex: 0 0 auto;
    min-height: 44px;
    padding: 11px 14px;
    border-radius: 999px;
}

.comment-image-preview-wrapper {
    margin-top: var(--space-2);
}

.comment-image-preview {
    position: relative;
    display: inline-block;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--surface);
    padding: var(--space-1);
}

.comment-image-preview img {
    display: block;
    max-width: 160px;
    max-height: 120px;
    border-radius: 8px;
}

.comment-image-remove {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    width: 28px;
    height: 28px;
    top: -8px;
    right: -8px;
    padding: 0;
    border-radius: 50%;
    background: var(--danger-bg);
    color: var(--danger-dark);
}

.reply-form {
    margin-left: 40px;
}

.login-to-interact {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    background: var(--surface-alt);
    text-align: center;
    padding: var(--space-4);
    font-size: 13px;
}

/* Profiles and user directory */

.profile-header {
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-soft);
    gap: 28px;
    padding: 0 0 28px;
    flex-wrap: wrap;
}

.profile-info {
    flex: 1;
    min-width: 0;
}

.profile-name {
    overflow-wrap: anywhere;
    color: var(--text-primary);
    text-shadow: none;
    font-size: 34px;
    font-weight: 600;
    letter-spacing: -.045em;
    line-height: 1.2;
}

.profile-meta {
    color: var(--text-secondary);
    margin-top: var(--space-2);
    font-size: 14px;
}

.profile-stats {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin-top: var(--space-5);
}

.profile-stat {
    border-radius: 16px;
    background: var(--surface-alt);
    box-shadow: none;
    min-width: 112px;
    padding: 16px 20px;
    border: 1px solid transparent;
    text-align: left;
}

.profile-stat-num {
    color: var(--text-primary);
    font-size: 30px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.035em;
    line-height: 1.25;
}

.profile-stat-label {
    color: var(--text-secondary);
    text-transform: none;
    font-size: 13px;
    letter-spacing: 0;
    margin-top: var(--space-1);
}

.friends-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    gap: var(--space-3);
}

.friend-grid-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    color: var(--text-primary);
    text-align: center;
    text-decoration: none;
    transition: var(--control-transition);
    gap: var(--space-3);
    padding: 20px 12px;
    border-color: var(--border-soft);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}

.friend-grid-item:hover {
    border-color: var(--border-color);
    background: var(--surface);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

body.dark-mode .friend-grid-item:hover,
body.darkblue-mode .friend-grid-item:hover {
    background: var(--surface);
}

.friend-grid-name {
    width: 100%;
    overflow: hidden;
    color: var(--text-primary);
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
}

.search-form {
    display: flex;
    gap: var(--space-3);
}

.search-input {
    flex: 1;
    width: auto;
    min-width: 0;
}

.search-btn,
.search-clear {
    min-height: 48px;
    padding: 12px 20px;
}

.search-info {
    margin-top: var(--space-3);
}

.users-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(184px, 1fr));
    gap: 20px;
    margin-top: var(--space-5);
}

.user-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    background: var(--surface);
    text-align: center;
    text-decoration: none;
    transition: var(--control-transition);
    gap: 14px;
    padding: 28px 20px;
    box-shadow: var(--shadow-xs);
    border-color: var(--border-color);
}

.user-card:hover {
    border-color: var(--border-color);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
}

.user-name {
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 600;
}

.user-joined {
    color: var(--text-secondary);
    font-size: 13px;
}

.user-badge {
    margin-top: 1px;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 550;
    letter-spacing: 0;
}

.user-badge.friend {
    border-color: var(--success-border);
    color: var(--success-dark);
    background: var(--success-bg);
}

.user-badge.pending {
    border-color: var(--info-border);
    color: var(--info-text);
    background: var(--info-bg);
}

.user-badge.sent {
    border-color: var(--border-color);
    color: var(--text-secondary);
    background: var(--surface-muted);
}

/* Airy tables and pagination */

.rankings-table {
    width: 100%;
    overflow: hidden;
    border: 1px solid var(--border-color);
    border-collapse: separate;
    border-spacing: 0;
    background: var(--surface);
    box-shadow: var(--shadow-xs);
    border-radius: var(--radius-md);
    font-size: 14px;
    margin-top: var(--space-5);
}

.rankings-table th {
    border: 0;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    box-shadow: none;
    text-align: left;
    text-transform: none;
    padding: 16px 20px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -.01em;
    background: var(--surface-alt);
}

.rankings-table td {
    border: 0;
    border-bottom: 1px solid var(--border-soft);
    padding: 18px 20px;
    font-variant-numeric: tabular-nums;
}

.rankings-table tbody tr:last-child td {
    border-bottom: 0;
}

.rankings-table tbody tr:nth-child(even) {
    background: var(--row-even);
}

.rankings-table tbody tr:hover {
    background: var(--row-hover);
}

.pagination-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin: var(--space-5) 0;
    padding: 18px 20px;
    background: var(--surface);
    border-radius: var(--radius-md);
}

.pagination-controls,
.per-page-selector {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.pagination-btn,
.per-page-btn {
    min-width: 40px;
    min-height: 40px;
    padding: 10px 12px;
    font-variant-numeric: tabular-nums;
    border-radius: 10px;
    box-shadow: none;
}

.pagination-info,
.per-page-label {
    color: var(--text-secondary);
    font-size: 13px;
}

.empty-state {
    color: var(--text-secondary);
    text-align: center;
    padding: var(--space-7) var(--space-5);
    font-size: 14px;
}

.empty-icon {
    filter: none;
    margin-bottom: var(--space-4);
    font-size: 32px;
    opacity: .6;
}

.admin-contact-card {
    margin: var(--space-4) 0;
    padding: var(--space-5);
}

.admin-contact-full {
    width: 100%;
}

.admin-contact-id {
    margin: var(--space-3) 0;
}

.admin-contact-id code {
    display: inline-block;
    border: 1px solid var(--border-soft);
    color: var(--text-primary);
    background: var(--surface-alt);
    box-shadow: none;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font: 13px/1.7 var(--font-mono);
    max-width: 100%;
    overflow-wrap: anywhere;
    white-space: normal;
}

.admin-contact-links {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
}

/* Contact and abuse reporting */

.contact-page {
    width: min(800px, calc(100% - 48px));
    margin: var(--space-6) auto var(--space-7);
}

.contact-card {
    padding: 40px;
}

.contact-card h1 {
    margin: 0 0 var(--space-3);
    font-size: clamp(28px, 4vw, 36px);
    letter-spacing: -.035em;
}

.contact-intro,
.contact-notice,
.contact-help {
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.75;
}

.contact-notice {
    border: 1px solid var(--info-border);
    border-radius: var(--radius-sm);
    color: var(--info-text);
    background: var(--info-bg);
    margin: var(--space-5) 0;
    padding: var(--space-4);
}

.contact-form {
    margin-top: var(--space-6);
}

.contact-field {
    margin-bottom: var(--space-5);
}

.contact-field label {
    display: block;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
    font-size: 14px;
    font-weight: 500;
}

.contact-field input,
.contact-field select,
.contact-field textarea {
    width: 100%;
}

.contact-field textarea {
    min-height: 200px;
}

.contact-limit {
    display: block;
    color: var(--text-secondary);
    margin-top: var(--space-2);
    font-size: 13px;
    line-height: 1.6;
}

.contact-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-4);
    margin-top: var(--space-5);
}

.contact-actions .btn {
    width: auto;
    min-width: 160px;
}

.contact-trap {
    position: absolute !important;
    left: -10000px !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
}

.contact-legal-note {
    border-top: 1px solid var(--border-soft);
    color: var(--text-secondary);
    margin-top: var(--space-5);
    padding-top: var(--space-5);
    font-size: 12px;
    line-height: 1.7;
}

/* Navigation drawer, search and administrative surfaces */

.site-nav-toggle {
    min-height: 44px;
    padding: 11px 16px;
    border-color: var(--border-color) !important;
    border-radius: 999px !important;
    background: var(--button-bg) !important;
    color: var(--text-primary) !important;
    box-shadow: var(--shadow-xs) !important;
    font: 500 14px/1.3 var(--font-sans) !important;
}

.site-nav-toggle:hover {
    border-color: var(--border-hover, #C7C7CC) !important;
    color: var(--text-primary) !important;
    background: var(--button-hover) !important;
}

.site-nav-drawer {
    border-color: var(--border-color);
    background: var(--surface-glass);
    box-shadow: var(--drawer-shadow, -12px 0 48px rgb(29 29 31 / 10%));
    padding: 28px;
    transition: transform 240ms var(--ease-out), visibility 240ms ease;
    scrollbar-gutter: stable;
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
    -webkit-backdrop-filter: saturate(150%) blur(24px);
    backdrop-filter: saturate(150%) blur(24px);
}

.site-nav-head {
    border-color: var(--border-soft);
    padding-bottom: var(--space-5);
}

.site-nav-title strong {
    color: var(--text-primary);
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -.03em;
}

.site-nav-close {
    border-radius: 50% !important;
    font: 400 22px/1 var(--font-sans) !important;
    border-color: transparent !important;
    background: var(--surface-alt) !important;
    color: var(--text-secondary) !important;
}

.site-nav-link {
    border-radius: var(--radius-sm);
    min-height: 52px;
    font-size: 15px;
    font-weight: 500;
    transition: var(--control-transition);
    padding: 12px 14px;
}

.site-nav-link:hover {
    border-color: transparent;
    color: var(--text-primary);
    background: var(--surface-alt);
    transform: none;
}

.site-nav-link.active {
    border-color: transparent;
    color: var(--link-color);
    background: var(--accent-soft);
}

.site-nav-icon {
    border-radius: 10px;
    background: var(--surface-alt);
    width: 34px;
    height: 34px;
    flex-basis: 34px;
    font-size: 16px;
}

.site-nav-footer,
.feed-nav-search input,
.feed-create-form input {
    border-color: var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 15px;
    min-height: 44px;
}

.feed-nav-search button,
.feed-create-form button {
    border-radius: var(--radius-sm);
    font: 500 14px/1.3 var(--font-sans);
    padding: 11px 14px;
}

.feed-create summary,
.feed-heading-home {
    color: var(--link-color);
}

.post-search-input,
body .post-search-input {
    min-height: 50px;
    padding: 14px 18px;
    border-color: var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 16px;
}

.post-search-input:focus,
body .post-search-input:focus {
    border-color: var(--accent-color);
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px var(--focus);
}

.post-search-button,
body .post-search-button {
    min-height: 50px;
    padding: 14px 22px;
    border-color: var(--accent-border);
    border-radius: var(--radius-sm);
    background: var(--action-bg);
    color: var(--accent-contrast);
    font-family: var(--font-sans);
    box-shadow: var(--shadow-xs);
}

.post-search-button:hover,
body .post-search-button:hover {
    border-color: var(--accent-hover);
    background: var(--accent-hover);
    box-shadow: none;
}

.search-result,
body .search-result {
    transition: border-color var(--duration-normal) ease, box-shadow var(--duration-normal) ease;
}

.search-result:hover,
body .search-result:hover {
    border-color: var(--border-hover, #C7C7CC) !important;
    box-shadow: var(--shadow-sm);
    transform: none;
}

.role-ladder,
body .role-ladder {
    border-color: transparent;
    background: var(--surface-alt);
    padding: 20px;
    border-radius: var(--radius-md);
}

.admin-top {
    border-color: var(--border-color);
    background: var(--surface-glass);
    box-shadow: var(--shadow-xs);
    padding: 16px max(24px, calc((100% - 1300px) / 2)) !important;
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
}

.admin-nav,
.stat,
.record,
.security-card {
    border-radius: var(--radius-md) !important;
    background: var(--surface);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.admin-nav a {
    transition: var(--control-transition);
    border-radius: var(--radius-sm) !important;
    padding: 10px 12px !important;
}

.admin-nav a:hover,
.admin-nav a.active {
    border-color: transparent;
    color: var(--link-color);
    background: var(--accent-soft);
}

.record-content,
.codes code {
    border-color: var(--border-color);
    border-radius: var(--radius-sm) !important;
    background: var(--input-bg);
}

.status {
    border-radius: 999px !important;
    font-weight: 550;
    letter-spacing: .01em;
    font-size: 12px;
}

.pager a {
    background: var(--surface);
    min-height: 44px;
    padding: 11px 16px;
    border-radius: var(--radius-sm);
    transition: var(--control-transition);
    border: 1px solid var(--border-color);
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) var(--bg-primary);
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    border-radius: 999px;
    border: 3px solid var(--bg-primary);
    background: var(--border-strong);
    background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-dim);
    background-clip: padding-box;
}

/* Shared native-control and accessibility foundations. */

/* Native controls, keyboard interaction, and reading rhythm. */

button,
input,
select,
textarea {
    letter-spacing: inherit;
}

input:not([type]),
input[type=number],
input[type=tel],
input[type=date],
input[type=datetime-local] {
    min-height: 48px;
    padding: 12px 15px;
}

input[type=hidden],
[hidden] {
    display: none !important;
}

input[readonly],
textarea[readonly] {
    color: var(--text-secondary);
    background: var(--surface-alt);
}

input:disabled,
textarea:disabled,
select:disabled {
    opacity: .7;
    cursor: not-allowed;
    background: var(--surface-alt);
}

input:autofill {
    background: var(--input-bg);
    color: var(--text-primary);
}

input:-webkit-autofill {
    -webkit-text-fill-color: var(--text-primary);
    caret-color: var(--text-primary);
    box-shadow: 0 0 0 1000px var(--input-bg) inset;
}

input:user-invalid,
textarea:user-invalid,
select:user-invalid {
    border-color: var(--danger);
}

button:focus-visible,
.btn:focus-visible,
summary:focus-visible,
.file-input-label:focus-within,
.video-upload-button:focus-within {
    outline: 3px solid var(--accent-color) !important;
    outline-offset: 3px;
}

.btn-secondary:hover {
    color: var(--text-primary);
    background: var(--button-hover);
    border-color: var(--border-strong);
}

a.nav-link:hover,
a.sidebar-link:hover,
a.friend-item:hover,
a.friend-grid-item:hover,
a.user-card:hover,
a.site-nav-link:hover,
a.pagination-btn:hover,
a.per-page-btn:hover,
a.btn:hover,
a.search-clear:hover {
    text-decoration: none;
}

:where(.post, .comment) a:not([class]) {
    text-decoration: underline;
    text-decoration-color: var(--border-strong);
}

:where(.post, .comment) a:not([class]):hover {
    text-decoration-color: currentColor;
}

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

pre {
    max-width: 100%;
    overflow-x: auto;
}

hr {
    margin: var(--space-5) 0;
    border: 0;
    border-top: 1px solid var(--border-soft);
}

:where(.card, .contact-notice, .alert) ul,
:where(.card, .contact-notice, .alert) ol {
    padding-inline-start: 1.4em;
}

:where(.card, .auth-card, .alert, .hosting-note) > :last-child {
    margin-bottom: 0;
}

:where(.card, .sidebar-section):focus-within {
    border-color: var(--border-hover, #C7C7CC);
}

body .post-search-button {
    color: var(--accent-contrast);
    border-radius: var(--radius-sm);
    font: 600 14px/1.4 var(--font-sans);
}

/* Navigation retains its existing inert, aria, and body-class behavior. */

.site-nav-backdrop,
.site-nav-backdrop:hover,
.site-nav-backdrop:active {
    transform: none;
    min-height: 0;
    padding: 0;
    background: var(--overlay-bg, rgb(245 245 247 / 72%)) !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

.site-nav-section {
    margin-top: var(--space-5);
}

.site-nav-section-title,
.feed-heading-label {
    color: var(--text-dim);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: .025em;
    line-height: 1.5;
    text-transform: none;
}

.site-nav-title span,
.site-nav-link-text small {
    font-size: 12px;
    line-height: 1.5;
}

button.site-nav-link {
    font: 500 15px/1.4 var(--font-sans) !important;
    border-radius: var(--radius-sm) !important;
}

.site-nav-link.danger {
    color: var(--danger-dark);
}

.site-nav-link.danger:hover {
    border-color: var(--danger-border);
    background: var(--danger-bg);
}

.site-nav-footer {
    padding: var(--space-4);
    font-size: 12px;
    line-height: 1.7;
}

.site-nav-toggle:active,
.site-nav-close:active {
    transform: translateY(1px);
}

.feed-nav-search {
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.feed-nav-search input,
.feed-create-form input {
    font-size: 14px;
}

.feed-create {
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-color: var(--border-soft);
}

.feed-create summary {
    min-height: 40px;
    padding: 9px 0;
    font-weight: 550;
    font-size: 14px;
}

.feed-create[open] .feed-create-form {
    animation: surface-reveal var(--duration-fast) var(--ease-out) both;
}

.feed-create-form {
    gap: var(--space-3);
}

.feed-create-form button {
    color: var(--accent-contrast);
    background: var(--action-bg);
    min-height: 44px;
}

.feed-create-form button:hover {
    background: var(--accent-hover);
}

.feed-nav-empty,
.feed-create-help {
    font-size: 12px;
    line-height: 1.65;
}

.feed-heading {
    gap: var(--space-4);
    flex-wrap: wrap;
}

.feed-heading h1 {
    font-size: 32px;
    font-weight: 600;
    letter-spacing: -.04em;
}

.feed-heading-home {
    min-height: 32px;
    padding: 6px 0;
    font-size: 13px;
    font-weight: 550;
}

/* Larger action targets and popovers without clipping post media. */

.comment > .comment-content,
.comment-form > div {
    min-width: 0;
}

.comment-image-btn {
    color: var(--text-secondary);
    background: var(--button-bg);
}

.reaction-main-btn.active,
.comment-reaction-main-btn.active {
    color: var(--link-color);
    border-color: transparent;
    background: var(--accent-soft);
    box-shadow: none;
}

.reaction-main-btn.active:hover,
.comment-reaction-main-btn.active:hover {
    color: var(--link-color);
    background: var(--accent-soft-hover);
}

.reaction-tooltip:focus-within .reaction-tooltip-content {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
}

.reaction-picker-item:focus-visible,
.comment-reaction-picker-item:focus-visible {
    background: var(--surface-muted);
}

.reaction-picker::after,
.comment-reaction-picker::after {
    content: "";
    position: absolute;
    inset: 100% 0 -12px;
}

.post-image,
.comment-image {
    height: auto;
}

.post-external-audio {
    min-height: 48px;
}

.profile-section > :last-child {
    min-width: 0;
}

.friend-name,
.friend-grid-name,
.user-name {
    line-height: 1.5;
}

.user-card:focus-visible,
.friend-grid-item:focus-visible {
    border-color: var(--accent-color);
}

/* Search pages load embedded styles after this sheet. Scoped selectors
   keep typography, controls, and reading width consistent without editing HTML. */

body .search-shell {
    width: min(800px, calc(100% - 48px));
    margin: var(--space-6) auto var(--space-7);
}

body .post-search-form {
    gap: var(--space-3);
    margin: var(--space-5) 0 var(--space-3);
}

body .post-search-input {
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
}

body .post-search-help,
body .search-summary {
    font-size: 12px;
    line-height: 1.7;
}

body .search-result-content {
    font-size: 16px;
    line-height: 1.75;
}

body .search-result-author {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

body .search-result-time,
body .search-result-open,
body .search-back {
    font-size: 12px;
}

body .search-result-open {
    margin-top: var(--space-4);
    font-weight: 550;
}

body .search-result:hover {
    text-decoration: none;
}

body .search-empty {
    padding: var(--space-7) var(--space-5);
}

body .ranking-intro {
    font-size: 13px;
    line-height: 1.7;
}

body .role-threshold {
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

/* Calm, legible role badges retain their role and effect class hooks. */

body .forum-role {
    padding: .35em .75em;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    background: var(--surface-alt);
    box-shadow: none;
    text-shadow: none;
    font-size: 12px;
    font-weight: 550;
    letter-spacing: 0;
    text-transform: none;
    white-space: normal;
    animation: none;
    border-radius: 999px;
}

body .forum-role--contributor,
body .forum-role--active-voice {
    color: var(--success-dark);
    border-color: var(--success-border);
    background: var(--success-bg);
}

body .forum-role--veteran,
body .forum-role--elite-member {
    color: var(--warning);
    border-color: var(--warning-border);
    background: var(--warning-bg);
}

body .forum-role--forum-legend,
body .forum-role--icon {
    color: var(--accent-contrast);
    border-color: var(--accent-border);
    background: var(--action-bg);
}

body .forum-role-effect--icon::before {
    color: currentColor;
    text-shadow: none;
    animation: none;
}

/* Gallery presentation; tile playback, hidden progress and paging are untouched. */

body .video-gallery {
    width: min(var(--page-width), 100%);
    padding: var(--space-6) var(--space-5) var(--space-7);
}

body .video-gallery-bar {
    margin-bottom: var(--space-6);
    gap: var(--space-5);
}

body .video-gallery-bar h1 {
    font-size: clamp(26px, 3vw, 34px);
    font-weight: 600;
    letter-spacing: -.04em;
}

body .video-upload-button {
    min-height: 44px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    color: var(--accent-contrast);
    background: var(--action-bg);
    font-size: 13px;
    font-weight: 600;
    transition: var(--control-transition);
}

body .video-upload-button:hover {
    background: var(--accent-hover);
}

body .video-upload-button:active {
    transform: translateY(1px);
}

body .video-tile {
    border-color: var(--border-color);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
    transition: var(--control-transition);
}

body .video-tile:hover {
    border-color: var(--border-hover, #C7C7CC);
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
}

body .video-play {
    width: 48px;
    height: 48px;
    background: var(--surface-glass);
    backdrop-filter: blur(16px);
    color: var(--text-primary);
    border: 1px solid var(--video-play-border, rgb(255 255 255 / 75%));
    -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--shadow-sm);
}

body .tile-title {
    inset: auto 12px 12px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--text-primary);
    background: var(--surface-glass);
    text-shadow: none;
    font-size: 13px;
    font-weight: 500;
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
}

body .video-status,
body .video-alert {
    padding: 16px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
}

body .media-primary {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--input-bg);
}

body .media-detail h1 {
    font-size: clamp(28px, 5vw, 42px);
    font-weight: 600;
}

body .media-date,
body .media-breadcrumb,
body .media-caption {
    font-size: 13px;
    line-height: 1.7;
}

/* Administration uses the same tokens despite its later embedded styles. */

.admin-page .admin-top h1 {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -.03em;
}

.admin-page .admin-shell {
    gap: var(--space-5);
    margin-top: var(--space-5);
}

.admin-page .stat {
    padding: var(--space-5) !important;
}

.admin-page .stat strong {
    font-size: 34px;
    font-weight: 600;
    letter-spacing: -.04em;
    font-variant-numeric: tabular-nums;
}

.admin-page .stat span,
.admin-page .muted,
.admin-auth .muted {
    font-size: 12px;
    line-height: 1.65;
}

.admin-page .record {
    padding: var(--space-5) !important;
}

.admin-page .record-content {
    padding: var(--space-4);
    font-size: 14px;
    line-height: 1.7;
}

.admin-page .record-grid strong {
    font-size: 12px;
    font-weight: 550;
    letter-spacing: .02em;
}

.admin-page .security-card {
    padding: var(--space-5) !important;
}

.admin-page .toolbar {
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

.admin-page .field,
.admin-auth .field {
    margin-bottom: var(--space-4);
}

.admin-page .field label,
.admin-auth .field label {
    margin-bottom: var(--space-2);
}

.admin-page .actions {
    gap: var(--space-3);
    padding-top: var(--space-4);
}

.admin-page .actions button,
.admin-page .toolbar .btn {
    min-height: 36px;
}

.admin-page .danger {
    color: var(--danger-dark) !important;
    background: var(--danger-bg) !important;
    border-color: var(--danger-border) !important;
}

.admin-page .danger:hover {
    border-color: var(--danger) !important;
}

.admin-page .pager a:hover {
    border-color: var(--border-strong);
    background: var(--button-hover);
    text-decoration: none;
}

.admin-auth .admin-brand {
    margin-bottom: var(--space-5);
}

.admin-auth .admin-brand h1 {
    font-size: 26px;
}

.admin-auth .admin-mark {
    width: 52px;
    height: 52px;
    margin-bottom: var(--space-4);
    border-radius: var(--radius-md);
    color: var(--accent-contrast);
    background: var(--action-bg);
    font-size: 22px;
}

.admin-auth .admin-card {
    padding: var(--space-6) !important;
}

.admin-auth .secret {
    padding: var(--space-3);
    border-radius: var(--radius-sm);
    font: 13px/1.7 var(--font-mono);
}

.admin-auth .qr {
    border-radius: var(--radius-sm);
}

/* Floating menus and dialogs share the same bright material.
   Visibility, positioning, and open/close states remain owned by the app. */

:where(dialog, .modal-content, .dropdown-menu, .popover) {
    max-width: min(100%, calc(100vw - 32px));
    color: var(--text-primary);
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    font-family: var(--font-sans);
    color-scheme: var(--theme-color-scheme, only light);
}

dialog {
    max-height: calc(100svh - 48px);
    overflow-y: auto;
    padding: clamp(20px, 4vw, 36px);
    border-radius: var(--radius-lg);
}

dialog::backdrop {
    background: var(--overlay-bg, rgb(245 245 247 / 72%));
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

:where(.modal-header, .modal-footer) {
    padding: 20px 24px;
    border-color: var(--border-soft);
}

:where(.modal-body) {
    padding: 24px;
}

:where(.dropdown-menu, .popover) {
    padding: 8px;
    background: var(--surface-glass);
    -webkit-backdrop-filter: saturate(150%) blur(20px);
    backdrop-filter: saturate(150%) blur(20px);
}

:where(.dropdown-menu) :where(a, button, [role=menuitem]) {
    border: 0;
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text-primary);
    background: transparent;
    box-shadow: none;
    font: 400 14px/1.4 var(--font-sans);
    text-decoration: none;
}

:where(.dropdown-menu) :where(a, button, [role=menuitem]):hover {
    color: var(--link-color);
    background: var(--accent-soft);
}

:where(.modal-header) :where(h1, h2, h3) {
    margin: 0;
    letter-spacing: -.03em;
}

/* Page styles embedded after this file inherit the same light materials. */

body .video-tile video,
body .video-tile img {
    background: var(--surface-alt);
}

body .video-error {
    color: var(--text-secondary);
    background: var(--surface-alt);
    font-size: 14px;
}

body .video-upload-button {
    border-color: var(--accent-border);
}

body .media-neighbors a,
body .crawl-pagination a {
    color: var(--link-color);
    font-weight: 500;
}

body .forum-role-effect--legend,
body .forum-role-effect--icon {
    box-shadow: none;
    text-shadow: none;
    animation: none;
}

body .forum-role-effect--legend::before,
body .forum-role-effect--legend::after,
body .forum-role-effect--icon::after {
    content: none;
    animation: none;
}

body.security-page .security-brand-mark {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    border-color: var(--accent-border);
    background: var(--action-bg);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
}

body.security-page .security-brand h1 {
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -.04em;
}

body.security-page .security-brand p {
    margin-top: 8px;
    font-size: 13px;
    letter-spacing: 0;
    text-transform: none;
}

body.security-page .security-card {
    padding: clamp(24px, 5vw, 36px) !important;
    border-radius: var(--radius-lg) !important;
}

body.security-page .security-intro,
body.security-page .security-help {
    font-size: 14px;
    line-height: 1.65;
}

body.security-page .security-field {
    margin-bottom: 20px;
}

body.security-page .security-field input {
    min-height: 48px;
}

.site-nav-close:hover,
.site-nav-close:active {
    border-color: transparent !important;
    background: var(--surface-muted) !important;
    color: var(--text-primary) !important;
}

button.site-nav-link:hover,
button.site-nav-link:active {
    border-color: transparent !important;
    background: var(--surface-alt) !important;
}

.media-tab.active:hover {
    color: var(--text-primary);
    border-color: transparent;
    background: var(--surface);
    box-shadow: var(--tab-shadow, 0 1px 4px rgb(29 29 31 / 10%));
}

.btn-secondary:active {
    color: var(--text-primary);
    border-color: var(--border-color);
    background: var(--surface-muted);
}

/* Primary actions keep readable labels during keyboard and pointer presses. */

.btn:not(.btn-secondary):active,
.search-btn:active,
.comment-btn:active,
.add-friend-btn:active,
.btn-accept:active,
.friend-action-btn.add:active,
.friend-action-btn.accept:active,
.pagination-btn.active:active,
.per-page-btn.active:active,
.post-search-button:active,
body .post-search-button:active,
.feed-create-form button:active,
body .video-upload-button:active {
    color: var(--accent-contrast);
    border-color: var(--accent-hover);
    background: var(--accent-hover);
    box-shadow: none;
}

/* Prefer solid white when transparency is reduced or unsupported. */

@media (prefers-reduced-transparency: reduce) {
    .navbar,
    .admin-top,
    .site-nav-drawer,
    .reaction-picker,
    .comment-reaction-picker,
    .reaction-tooltip-content,
    body .video-play,
    body .tile-title,
    .dropdown-menu,
    .popover {
        background: var(--surface);
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }

    .site-nav-backdrop,
    .site-nav-backdrop:hover,
    .site-nav-backdrop:active {
        background: var(--overlay-reduced-bg, rgb(245 245 247 / 92%)) !important;
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }

    dialog::backdrop {
        background: var(--overlay-reduced-bg, rgb(245 245 247 / 92%));
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
}

@keyframes surface-reveal {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (min-width:641px) {
    .navbar-user .nav-link[title]::after {
        content: attr(title);
        margin-left: 6px;
        font-size: 12px;
    }
}

@media (max-width:1024px) {
    .container {
        width: calc(100% - 40px);
        margin-top: var(--space-5);
    }

    .sidebar {
        display: none !important;
    }

    .main-content {
        width: 100%;
    }
}

@media (max-width:640px) {
    .navbar {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: var(--space-2);
        min-height: 72px;
        padding: 12px 16px;
    }

    .navbar-brand {
        text-align: left;
        font-size: 20px;
    }

    .navbar-user {
        padding: 0;
        overscroll-behavior-x: contain;
        justify-content: flex-end;
        width: auto;
        max-width: 100%;
        flex: 0 1 auto;
        flex-wrap: wrap;
        margin-left: auto;
        overflow-x: visible;
        gap: var(--space-1);
    }

    .nav-link,
    button.nav-link {
        flex: 0 0 auto;
        min-width: 40px;
        min-height: 40px;
        padding: 9px 10px;
    }

    .container {
        display: block;
        width: calc(100% - 24px);
        margin: var(--space-4) auto var(--space-6);
        padding: 0;
    }

    .main-content,
    .card,
    .post,
    .comment,
    .user-card,
    .admin-contact-card,
    .hosting-note {
        min-width: 0;
        max-width: 100%;
        overflow-wrap: anywhere;
    }

    .card {
        margin-bottom: var(--space-4);
        padding: 20px;
        border-radius: var(--radius-md);
    }

    .post {
        padding: 20px;
    }

    .profile-section,
    .profile-header,
    .post-header {
        align-items: flex-start;
    }

    .profile-section,
    .profile-header {
        gap: var(--space-4);
    }

    .profile-avatar-big {
        width: 72px;
        height: 72px;
        font-size: 26px;
    }

    .profile-stats {
        width: 100%;
    }

    .profile-stat {
        flex: 1;
        min-width: 64px;
        padding: var(--space-3);
    }

    .post-header>div:last-child {
        justify-content: flex-end;
    }

    .media-upload-tabs,
    .file-input-wrapper,
    .pagination-container,
    .per-page-selector,
    .pagination-controls {
        flex-wrap: wrap;
    }

    .media-tab {
        flex: 1 1 auto;
        min-height: 40px;
    }

    .file-input-label,
    .filename-display {
        width: 100%;
        margin: 0 0 var(--space-2);
    }

    .comment.reply,
    .reply-form {
        margin-left: 16px;
    }

    .comment-input-wrapper {
        flex-wrap: wrap;
    }

    .comment-input {
        width: auto;
        flex: 1 1 calc(100% - 52px);
        min-height: 44px;
        font-size: 16px;
    }

    .comment-btn {
        flex: 1 1 100%;
        min-height: 44px;
    }

    .reaction-picker,
    .comment-reaction-picker {
        flex-wrap: wrap;
        white-space: normal;
        right: auto;
        left: 0;
        max-width: min(280px, calc(100vw - 72px));
        border-radius: var(--radius-md);
    }

    .search-form {
        flex-wrap: wrap;
    }

    .search-input {
        flex: 1 1 100%;
        width: 100%;
    }

    .search-btn {
        flex: 1 1 auto;
    }

    .users-grid {
        grid-template-columns: repeat(2,minmax(0,1fr));
        gap: var(--space-3);
    }

    .user-card {
        padding: 20px 10px;
    }

    .rankings-table {
        display: block;
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
    }

    .rankings-table th,
    .rankings-table td {
        padding: 12px;
    }

    .pagination-container {
        justify-content: center;
    }

    .pagination-info,
    .per-page-label {
        flex: 1 1 100%;
        text-align: center;
    }

    .pagination-btn,
    .per-page-btn {
        flex: 1 1 auto;
        min-height: 40px;
    }

    .admin-contact-id code {
        display: block;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .auth-card {
        padding: 28px 22px;
    }

    .contact-page {
        width: calc(100% - 24px);
        margin: var(--space-4) auto var(--space-6);
        padding: 0;
    }

    .contact-card {
        padding: 20px;
    }

    .contact-actions .btn {
        width: 100%;
    }
}

@media (max-width:360px) {
    .users-grid {
        grid-template-columns: 1fr;
    }

    .post-header {
        flex-direction: column;
    }

    .post-header>div:last-child {
        width: 100%;
        justify-content: flex-start;
    }

    .profile-header {
        flex-direction: column;
    }

    .navbar-user {
        gap: var(--space-1);
    }
}

@media (prefers-reduced-motion:reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        animation-delay: 0ms !important;
        transition-delay: 0ms !important;
    }
}

@media (forced-colors:active) {
    .navbar,
    .card,
    .sidebar-section,
    .auth-card,
    .pagination-container,
    .admin-contact-card,
    .hosting-note,
    button,
    .btn,
    input,
    textarea,
    select {
        border: 1px solid CanvasText !important;
        box-shadow: none !important;
    }
}

@media (max-width: 640px) {
    input:not([type]),
    input[type=text],
    input[type=email],
    input[type=password],
    input[type=url],
    input[type=search],
    input[type=number],
    input[type=tel],
    input[type=date],
    input[type=datetime-local],
    textarea,
    select {
        font-size: 16px;
    }

    .navbar-user:has(> .nav-link:nth-child(5)) {
        flex-basis: 100%;
        justify-content: flex-start;
    }

    .sidebar-section {
        border-radius: var(--radius-md);
    }

    .post-form textarea {
        font-size: 16px;
        min-height: 104px;
    }

    .post-content {
        font-size: 15px;
        line-height: 1.75;
    }

    .post-header {
        gap: var(--space-3);
    }

    .post-delete,
    .comment-delete {
        min-height: 32px;
    }

    .post-actions {
        gap: 6px;
    }

    .reaction-main-btn,
    .comment-image-btn {
        min-height: 40px;
    }

    .reaction-picker-item,
    .comment-reaction-picker-item {
        min-width: 36px;
        min-height: 36px;
    }

    .comment {
        gap: var(--space-2);
        padding: 10px;
    }

    .comment-avatar {
        width: 28px;
        height: 28px;
        font-size: 11px;
    }

    .comment-text {
        font-size: 14px;
    }

    .comment-action-btn {
        min-height: 32px;
    }

    .comment-time {
        font-size: 11px;
    }

    .comment-image-remove {
        min-height: 28px;
    }

    .profile-name {
        font-size: 25px;
    }

    .profile-stat-num {
        font-size: 22px;
    }

    .friends-grid {
        grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
        gap: var(--space-2);
    }

    .pagination-container {
        padding: var(--space-3);
    }

    .pagination-controls,
    .per-page-selector {
        justify-content: center;
        max-width: 100%;
    }

    .site-nav-drawer {
        padding: 20px;
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }

    .site-nav-toggle {
        min-height: 40px;
    }

    .site-nav-title strong {
        font-size: 18px;
    }

    .site-nav-footer {
        font-size: 12px;
    }

    body .search-shell {
        width: calc(100% - 24px);
        margin: var(--space-4) auto var(--space-6);
        padding: 0;
    }

    body .post-search-input {
        font-size: 16px !important;
    }

    body .post-search-form {
        margin-top: var(--space-4);
    }

    body .video-gallery {
        padding: var(--space-4) var(--space-3) var(--space-6);
    }

    body .video-gallery-bar {
        margin-bottom: var(--space-5);
        gap: var(--space-4);
    }

    body .video-upload-form {
        flex-wrap: wrap;
    }

    body .media-title-input {
        flex: 1 1 140px;
        width: auto;
    }

    body .video-upload-button {
        flex-shrink: 0;
    }

    body .video-grid {
        gap: var(--space-4);
    }

    body .video-status {
        right: 12px;
        bottom: max(12px, env(safe-area-inset-bottom));
    }

    .admin-page .admin-top {
        padding: 14px 16px !important;
    }

    .admin-page .admin-top h1 {
        font-size: 17px;
    }

    .admin-page .admin-shell {
        width: calc(100% - 24px);
        gap: var(--space-4);
        margin-top: var(--space-4);
    }

    .admin-page .stat,
    .admin-page .record,
    .admin-page .security-card {
        padding: var(--space-4) !important;
    }

    .admin-page .admin-nav a {
        padding: 10px !important;
    }

    .admin-auth .admin-card {
        padding: var(--space-5) !important;
    }

    .admin-page .toolbar input,
    .admin-page .toolbar select {
        min-width: 0;
        max-width: 100%;
    }
}

@media (max-width: 360px) {
    .container,
    .contact-page,
    body .search-shell {
        width: calc(100% - 16px);
    }

    .card,
    .post {
        padding: 14px;
    }

    .reaction-text {
        font-size: 11px;
    }

    .comment.reply,
    .reply-form {
        margin-left: 10px;
    }

    .comment {
        gap: 6px;
        padding: 8px;
    }

    .comment-avatar {
        width: 24px;
        height: 24px;
    }

    body .video-upload-button {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .nav-link.primary:hover,
    .theme-toggle:hover .theme-icon,
    button:active,
    .btn:active,
    .search-btn:active,
    .search-clear:active,
    .pagination-btn:active,
    .media-tab:active,
    .reaction-main-btn:active,
    .comment-reaction-main-btn:active,
    .comment-btn:active,
    .friend-grid-item:hover,
    .user-card:hover,
    .search-result:hover,
    .reaction-picker-item:hover,
    .comment-reaction-picker-item:hover,
    .site-nav-toggle:active,
    .site-nav-close:active,
    body .video-tile:hover,
    body .video-upload-button:active {
        transform: none;
    }
}

@media (forced-colors: active) {
    :focus-visible {
        outline-color: Highlight !important;
    }

    .sidebar-link.active,
    .site-nav-link.active,
    .pagination-btn.active,
    .per-page-btn.active,
    .media-tab.active {
        outline: 1px solid Highlight;
    }

    .reaction-main-btn.active,
    .comment-reaction-main-btn.active {
        border-color: Highlight;
    }
}

/* Keep the top role's existing emblem clear of its label. */

body .forum-role-effect--icon {
    position: relative;
    padding-inline-start: 1.75em;
}
