/*
    Noplr design tokens and the Bootstrap 5.3 mapping (Design.md, Light and dark theming).

    Themes are CSS custom properties switched by the data-bs-theme attribute on <html>. No second stylesheet is loaded.
    Raw colors live only in the two token blocks below; everything else uses var(--sh-*).
    Contrast was measured against WCAG 2.2: 4.5:1 for text, 3:1 for control outlines and focus rings.
*/

:root,
[data-bs-theme="light"] {
    --sh-bg: #F4F6F9;
    --sh-surface: #FFFFFF;
    --sh-text: #0F172A;
    --sh-text-muted: #556070;
    --sh-link: #2347C9;
    --sh-accent: #2F5BE8;
    --sh-accent-hover: #2449C4;
    --sh-on-accent: #FFFFFF;
    --sh-danger: #C0261B;
    --sh-danger-strong: #C0261B;
    --sh-on-danger: #FFFFFF;
    --sh-on-avatar: #FFFFFF;
    --sh-success: #0E7C4A;
    --sh-warning: #B45309;
    --sh-info: #1D6FD8;
    --sh-border-strong: #8591A5;
    --sh-border-subtle: #E2E6EC;
    --sh-hover: #EDF0F5;
    --sh-focus: #2F5BE8;
    --sh-card-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.04);
}

:root[data-bs-theme="light"] {
    color-scheme: light;
}

[data-bs-theme="dark"] {
    --sh-bg: #0D1117;
    --sh-surface: #151B23;
    --sh-text: #E8ECF2;
    --sh-text-muted: #98A2B3;
    --sh-link: #8FA9FF;
    --sh-accent: #6C8CFF;
    --sh-accent-hover: #8FA9FF;
    --sh-on-accent: #0A1030;
    --sh-danger: #FF8A80;
    --sh-danger-strong: #A8231A;
    --sh-on-danger: #FFFFFF;
    --sh-on-avatar: #FFFFFF;
    --sh-success: #4CD08C;
    --sh-warning: #F5B544;
    --sh-info: #7DB8FF;
    --sh-border-strong: #6A7588;
    --sh-border-subtle: #252C37;
    --sh-hover: #1E2530;
    --sh-focus: #8AB4FF;
    --sh-card-shadow: none;
}

:root[data-bs-theme="dark"] {
    color-scheme: dark;
}

/* Map the tokens onto Bootstrap's own variables. */
:root,
[data-bs-theme="light"],
[data-bs-theme="dark"] {
    --bs-body-bg: var(--sh-bg);
    --bs-body-color: var(--sh-text);
    --bs-body-color-rgb: 15, 23, 42;
    --bs-secondary-color: var(--sh-text-muted);
    --bs-emphasis-color: var(--sh-text);
    --bs-link-color: var(--sh-link);
    --bs-link-hover-color: var(--sh-link);
    --bs-link-color-rgb: 35, 71, 201;
    --bs-link-hover-color-rgb: 35, 71, 201;
    --bs-border-color: var(--sh-border-subtle);
    --bs-tertiary-bg: var(--sh-hover);
    --bs-secondary-bg: var(--sh-hover);
    --bs-primary: var(--sh-accent);
    --bs-danger: var(--sh-danger);
    --bs-focus-ring-color: var(--sh-focus);
    --bs-border-radius: 8px;
    --bs-border-radius-lg: 12px;
    /* The system's own interface font, so there is nothing to download: Segoe UI Variable on Windows 11, San Francisco on
       Apple devices, Roboto or Noto elsewhere. Good coverage of CJK, Arabic, Hebrew and the other supported scripts. */
    --bs-font-sans-serif: "Segoe UI Variable Text", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
    --sh-font-display: "Segoe UI Variable Display", "Segoe UI Variable Text", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
}

[data-bs-theme="dark"] {
    --bs-body-color-rgb: 232, 236, 242;
    --bs-link-color-rgb: 143, 169, 255;
    --bs-link-hover-color-rgb: 143, 169, 255;
}

/* Typography: 16px body, 1.55 line height, headings 1.75 / 1.5 / 1.25 / 1.125 rem, slightly heavier and tighter. */
html, body {
    font-family: var(--bs-font-sans-serif);
    font-size: 1rem;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    background-color: var(--sh-bg);
    color: var(--sh-text);
}

h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
    font-family: var(--sh-font-display);
    font-weight: 650;
    letter-spacing: -0.012em;
    line-height: 1.25;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4, .h4 { font-size: 1.125rem; }
.h5 { font-size: 1rem; }
small, .small { font-size: 0.875rem; }

/* Links read as links without being underlined everywhere; the underline returns on hover and focus. */
a { text-decoration-thickness: 1px; text-underline-offset: 0.2em; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); }
a:not(.btn):not(.nav-link):not(.navbar-brand):hover { text-decoration-color: currentColor; }

a {
    color: var(--sh-link);
}

.content {
    padding-top: 1.1rem;
}

h1:focus {
    outline: none;
}

/* Visible focus on everything interactive: 2px ring, 2px offset. */
:focus-visible {
    outline: 2px solid var(--sh-focus);
    outline-offset: 2px;
}

.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible,
.form-check-input:focus-visible,
.btn-link.nav-link:focus-visible {
    outline: 2px solid var(--sh-focus);
    outline-offset: 2px;
    box-shadow: none;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-select:focus, .form-check-input:focus {
    box-shadow: none;
}

/* Surfaces use borders, not shadows, so they read the same in both themes. */
.card,
.list-group,
.dropdown-menu,
.modal-content {
    --bs-card-bg: var(--sh-surface);
    --bs-card-border-color: var(--sh-border-subtle);
    --bs-card-border-radius: 12px;
    --bs-list-group-bg: var(--sh-surface);
    --bs-list-group-border-color: var(--sh-border-subtle);
    --bs-list-group-color: var(--sh-text);
    box-shadow: none;
}

/* A soft lift in light mode; in dark mode shadows are invisible, so the border alone does the work. */
.card {
    border-radius: 12px;
    box-shadow: var(--sh-card-shadow);
}

.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--sh-text);
    --bs-table-border-color: var(--sh-border-subtle);
}

/* Forms. */
.form-control,
.form-select {
    background-color: var(--sh-surface);
    color: var(--sh-text);
    border-color: var(--sh-border-strong);
    border-radius: 8px;
}

.form-control::placeholder {
    color: var(--sh-text-muted);
}

.form-control:disabled,
.form-select:disabled {
    background-color: var(--sh-hover);
}

.form-check-input {
    background-color: var(--sh-surface);
    border-color: var(--sh-border-strong);
}

.form-check-input:checked {
    background-color: var(--sh-accent);
    border-color: var(--sh-accent);
}

.form-text {
    color: var(--sh-text-muted);
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--sh-success);
}

.invalid {
    outline: 1px solid var(--sh-danger);
}

.validation-message {
    color: var(--sh-danger);
}

/* Buttons. One primary per view; danger is always behind a confirmation. */
.btn {
    border-radius: 8px;
}

.btn-primary {
    --bs-btn-color: var(--sh-on-accent);
    --bs-btn-bg: var(--sh-accent);
    --bs-btn-border-color: var(--sh-accent);
    --bs-btn-hover-color: var(--sh-on-accent);
    --bs-btn-hover-bg: var(--sh-accent-hover);
    --bs-btn-hover-border-color: var(--sh-accent-hover);
    --bs-btn-active-color: var(--sh-on-accent);
    --bs-btn-active-bg: var(--sh-accent-hover);
    --bs-btn-active-border-color: var(--sh-accent-hover);
    --bs-btn-disabled-color: var(--sh-on-accent);
    --bs-btn-disabled-bg: var(--sh-accent);
    --bs-btn-disabled-border-color: var(--sh-accent);
}

.btn-secondary,
.btn-outline-secondary {
    --bs-btn-color: var(--sh-text);
    --bs-btn-bg: var(--sh-surface);
    --bs-btn-border-color: var(--sh-border-strong);
    --bs-btn-hover-color: var(--sh-text);
    --bs-btn-hover-bg: var(--sh-hover);
    --bs-btn-hover-border-color: var(--sh-border-strong);
    --bs-btn-active-color: var(--sh-text);
    --bs-btn-active-bg: var(--sh-hover);
    --bs-btn-active-border-color: var(--sh-border-strong);
    --bs-btn-disabled-color: var(--sh-text-muted);
    --bs-btn-disabled-bg: var(--sh-surface);
    --bs-btn-disabled-border-color: var(--sh-border-subtle);
}

.btn-danger {
    --bs-btn-color: var(--sh-on-danger);
    --bs-btn-bg: var(--sh-danger-strong);
    --bs-btn-border-color: var(--sh-danger-strong);
    --bs-btn-hover-color: var(--sh-on-danger);
    --bs-btn-hover-bg: var(--sh-danger-strong);
    --bs-btn-hover-border-color: var(--sh-danger-strong);
    --bs-btn-active-color: var(--sh-on-danger);
    --bs-btn-active-bg: var(--sh-danger-strong);
    --bs-btn-active-border-color: var(--sh-danger-strong);
}

.btn-outline-danger {
    --bs-btn-color: var(--sh-danger);
    --bs-btn-bg: transparent;
    --bs-btn-border-color: var(--sh-danger);
    --bs-btn-hover-color: var(--sh-on-danger);
    --bs-btn-hover-bg: var(--sh-danger-strong);
    --bs-btn-hover-border-color: var(--sh-danger-strong);
    --bs-btn-active-color: var(--sh-on-danger);
    --bs-btn-active-bg: var(--sh-danger-strong);
    --bs-btn-active-border-color: var(--sh-danger-strong);
}

.btn-link {
    --bs-btn-color: var(--sh-link);
    --bs-btn-hover-color: var(--sh-link);
    --bs-btn-active-color: var(--sh-link);
}

.text-danger {
    color: var(--sh-danger) !important;
}

/* Badges and alerts never rely on color alone: they carry text, and alerts are outlined. */
.badge.text-bg-primary {
    background-color: var(--sh-accent) !important;
    color: var(--sh-on-accent) !important;
}

.badge.text-bg-secondary {
    background-color: var(--sh-hover) !important;
    color: var(--sh-text) !important;
    border: 1px solid var(--sh-border-strong);
}

.badge.text-bg-info,
.badge.text-bg-success,
.badge.text-bg-warning {
    background-color: var(--sh-surface) !important;
    border: 1px solid currentColor;
}

.badge.text-bg-info { color: var(--sh-info) !important; }
.badge.text-bg-success { color: var(--sh-success) !important; }
.badge.text-bg-warning { color: var(--sh-warning) !important; }

.alert {
    background-color: var(--sh-surface);
    color: var(--sh-text);
    border-width: 1px;
    border-inline-start-width: 4px;
}

.alert-danger { border-color: var(--sh-danger); }
.alert-success { border-color: var(--sh-success); }
.alert-info { border-color: var(--sh-info); }
.alert-warning { border-color: var(--sh-warning); }

.list-group-item {
    background-color: var(--sh-surface);
    color: var(--sh-text);
}

.list-group-item-primary {
    background-color: var(--sh-hover);
    color: var(--sh-text);
    border-inline-start: 4px solid var(--sh-accent);
}

details > summary {
    cursor: pointer;
}

hr {
    border-color: var(--sh-border-subtle);
    opacity: 1;
}

/* Rendered markdown follows the same tokens, including code blocks. */
.post-body pre,
.post-body code {
    background-color: var(--sh-hover);
    color: var(--sh-text);
    border-radius: 6px;
}

.post-body pre {
    padding: 0.75rem;
    overflow-x: auto;
}

.post-body code {
    padding: 0.1em 0.3em;
}

.post-body pre code {
    padding: 0;
}

.post-body blockquote {
    border-inline-start: 4px solid var(--sh-border-strong);
    margin-inline-start: 0;
    padding-inline-start: 1rem;
    color: var(--sh-text-muted);
}

.post-body table {
    border-collapse: collapse;
}

.post-body th,
.post-body td {
    border: 1px solid var(--sh-border-subtle);
    padding: 0.25rem 0.5rem;
}

/* Touch targets of at least 44px on touch devices. */
@media (pointer: coarse) {
    .btn,
    .form-control,
    .form-select,
    .nav-link,
    summary {
        min-height: 44px;
    }

    .btn-sm {
        --bs-btn-padding-y: 0.6rem;
    }

    .form-check-input {
        width: 1.5rem;
        height: 1.5rem;
    }
}

/* Respect reduced motion. */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Avatars: round, initials on a color taken from the handle (set inline). White text on these dark colors passes 4.5:1. */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 50%;
    color: var(--sh-on-avatar);
    font-weight: 600;
    line-height: 1;
    user-select: none;
}

/* Skip link and the two quick theme buttons (only the one that switches to the other theme shows). */
.skip-link {
    position: absolute;
    inset-inline-start: 0.5rem;
    top: -4rem;
    z-index: 2000;
    padding: 0.5rem 1rem;
    background-color: var(--sh-surface);
    color: var(--sh-text);
    border: 2px solid var(--sh-focus);
    border-radius: 8px;
}

.skip-link:focus {
    top: 0.5rem;
}

[data-bs-theme="light"] .theme-to-light,
[data-bs-theme="dark"] .theme-to-dark {
    display: none;
}

.blazor-error-boundary {
    background-color: var(--sh-danger-strong);
    padding: 1rem 1rem 1rem 1rem;
    color: var(--sh-on-danger);
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: var(--sh-border-strong);
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* Direct messages: a plain thread, mine on the end side and theirs on the start side, so it mirrors in right-to-left. */
.dm-thread {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* The conversation fills the window below the header: the thread scrolls, the header and message bar stay in view. */
.dm-chat {
    display: flex;
    flex-direction: column;
    /* Window height minus the header (3.5rem + its border), the content's top padding (1.1rem) and some room to spare. */
    height: calc(100dvh - 7rem);
    min-height: 20rem;
}

/* This page never scrolls as a whole, whatever else is in the layout. */
html:has(.dm-chat), body:has(.dm-chat) { overflow: hidden; }

.dm-chat > * { flex: 0 0 auto; }
.dm-chat > .dm-new { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.dm-new > * { flex: 0 0 auto; }
.dm-new > .dm-scroll { flex: 1 1 auto; min-height: 0; }
.dm-chat > .dm-scroll { flex: 1 1 auto; min-height: 0; }
.dm-back { font-size: 1.4rem; line-height: 1; text-decoration: none; }

.dm-scroll {
    overflow-y: auto;
    padding-inline-end: 0.5rem;
    /* Few messages sit at the bottom, next to the message bar, like a chat. */
    display: flex;
    flex-direction: column;
}

.dm-scroll > .dm-thread { margin-top: auto; margin-bottom: 0; }

.dm-row {
    display: flex;
    flex-direction: column;
    max-width: min(36rem, 85%);
}

.dm-mine {
    align-self: flex-end;
    align-items: flex-end;
}

.dm-theirs {
    align-self: flex-start;
    align-items: flex-start;
}

.dm-meta { font-size: 0.7rem; line-height: 1.2; margin-top: 0.1rem; }
.dm-bubble .post-image { display: block; max-width: 14rem; max-height: 10rem; width: auto; height: auto; border-radius: 0.5rem; margin-bottom: 0.2rem; }

.dm-bubble {
    padding: 0.25rem 0.65rem;
    font-size: 0.9rem;
    line-height: 1.35;
    border-radius: 0.9rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    background: var(--sh-surface);
    color: var(--sh-text);
    border: 1px solid var(--sh-border-subtle);
}

.dm-mine .dm-bubble {
    background: var(--sh-accent);
    color: var(--sh-on-accent);
    border-color: var(--sh-accent);
}

/* Message bar: picture button, a box that grows with the text, and send, in one rounded row. */
.dm-compose-box {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    padding: 0.4rem;
    background: var(--sh-surface);
    border: 1px solid var(--sh-border-strong);
    border-radius: 1.5rem;
}

.dm-compose-box:focus-within { border-color: var(--sh-accent); }

.dm-attach {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 50%;
    color: var(--sh-text);
    opacity: 0.75;
    cursor: pointer;
}

.dm-attach:hover, #messageImage:focus-visible + .dm-attach { opacity: 1; background-color: var(--sh-hover); }

.dm-input {
    flex: 1 1 auto;
    min-width: 0;
    max-height: 10rem;
    padding: 0.5rem 0.25rem;
    border: 0;
    outline: 0;
    resize: none;
    background: none;
    color: var(--sh-text);
    font: inherit;
    line-height: 1.4;
}

.dm-send { flex: 0 0 auto; border-radius: 999px; padding-inline: 1.1rem; }

.dm-file {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0.5rem 0 0 0.75rem;
    padding: 0.15rem 0.3rem 0.15rem 0.7rem;
    background: var(--sh-surface);
    border: 1px solid var(--sh-border-subtle);
    border-radius: 999px;
}

.dm-file[hidden] { display: none; }
.dm-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 16rem; }
.dm-file-clear { width: 1.4rem; height: 1.4rem; border: 0; border-radius: 50%; background: none; color: var(--sh-text); font-size: 1.1rem; line-height: 1; cursor: pointer; }
.dm-file-clear:hover { background-color: var(--sh-hover); }

/* Markdown editor and uploaded images. */
.md-editor {
    margin-bottom: 0.5rem;
}

.post-body img.post-image,
.post-image {
    display: block;
    max-width: 100%;
    max-height: 32rem;
    height: auto;
    border-radius: 0.5rem;
    margin: 0.5rem 0;
}

.avatar-image {
    border-radius: 50%;
    object-fit: cover;
    flex: none;
}

.group-header-image {
    display: block;
    width: 100%;
    max-height: 14rem;
    object-fit: cover;
    border-radius: 0.5rem;
}

/* Chat rooms. */
.chat-log {
    height: 55vh;
    min-height: 16rem;
    overflow-y: auto;
    background: var(--sh-surface);
}

.chat-line {
    padding: 0.1rem 0;
}

.chat-text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.chat-system {
    padding: 0.1rem 0;
    font-style: italic;
}

/* Bar charts (group insights). The bars use the theme tokens, so they follow light and dark. */
.bar-chart {
    display: flex;
    gap: 0.25rem;
    height: 12rem;
    padding-top: 0.5rem;
}

.bar-column {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.bar-area {
    flex: 1 1 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    border-bottom: 1px solid var(--sh-border-strong);
    min-height: 0;
}

.bar {
    width: 100%;
    min-height: 2px;
    background: var(--bar-color, var(--sh-accent));
    border-radius: 0.2rem 0.2rem 0 0;
}

.bar-value {
    line-height: 1.2;
}

.bar-label {
    font-size: 0.7rem;
    white-space: nowrap;
    overflow: hidden;
    max-width: 100%;
    margin-top: 0.2rem;
}

/* Language page: one button per language, like a list of chips. */
.language-option {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.8rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.5rem;
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
    text-decoration: none;
    cursor: pointer;
}

.language-option:hover {
    background-color: var(--bs-tertiary-bg);
}

.language-option.active {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
    color: var(--sh-on-accent);
}

.language-native { font-weight: 500; line-height: 1; }
.language-english { font-size: 0.9rem; opacity: 0.75; line-height: 1; }
.language-code { font-size: 0.8rem; opacity: 0.6; line-height: 1; text-transform: uppercase; }

.language-link { font-weight: 600; }

/* Three panels: left menu with the person's card, the content, and a right rail that only shows when there is room. */
.profile-card {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin: 0 0 0.75rem;
    padding: 0.75rem;
    background-color: var(--sh-surface);
    border: 1px solid var(--sh-border-subtle);
    border-radius: 10px;
    text-decoration: none;
    color: var(--sh-text);
}

.profile-card:hover { background-color: var(--sh-hover); }
.profile-card-text { display: flex; flex-direction: column; min-width: 0; }
.profile-card-name { font-weight: 600; overflow-wrap: anywhere; }
.profile-card-handle, .profile-card-tagline { font-size: 0.8rem; opacity: 0.75; overflow-wrap: anywhere; }

/* "Your groups" in the sidebar: laid out like the menu under it (same insets, item height, text size and current-page highlight). */
.side-groups { display: flex; flex-direction: column; margin: 0 0 0.75rem; padding: 0.5rem 1rem; background-color: var(--sh-surface); border: 1px solid var(--sh-border-subtle); border-radius: 10px; }
.side-groups-title { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; opacity: 0.7; padding: 0.25rem 1rem; }
.side-groups a { display: flex; align-items: center; min-height: 2rem; padding: 0.25rem 1rem; margin-bottom: 0.1rem; border-radius: 8px; color: var(--sh-text); text-decoration: none; font-size: 0.9rem; overflow-wrap: anywhere; }
.side-groups a:hover { background-color: var(--sh-hover); }
.side-groups a.active { background-color: color-mix(in srgb, var(--sh-accent) 16%, transparent); color: var(--sh-accent); font-weight: 600; }
.side-groups a.active:hover { background-color: color-mix(in srgb, var(--sh-accent) 24%, transparent); }

/* Searchable boxes (the Autocomplete component): a text box with a short list that drops down under it. */
.ac { position: relative; }
.ac-narrow { max-width: 18rem; }
.ac-medium { flex: 1 1 14rem; max-width: 20rem; }
.ac-wide { max-width: 32rem; }
.ac-input { width: 100%; }
.ac:has(.ac-clear) .ac-input { padding-inline-end: 1.9rem; }
.ac-clear {
    position: absolute;
    inset-inline-end: 0.3rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.4rem;
    height: 1.4rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: none;
    color: var(--sh-text);
    opacity: 0.6;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}
.ac-clear:hover, .ac-clear:focus-visible { opacity: 1; background-color: var(--sh-hover); }
.ac-clear[hidden] { display: none; }
.ac-list {
    position: absolute;
    z-index: 5;
    inset-inline: 0;
    margin: 0.2rem 0 0;
    padding: 0.25rem;
    list-style: none;
    background-color: var(--sh-surface);
    border: 1px solid var(--sh-border-strong);
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}
.ac-list[hidden] { display: none; }
.ac-item { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: 0.35rem 0.6rem; border-radius: 6px; cursor: pointer; font-size: 0.9rem; }
.ac-item[aria-selected="true"], .ac-item:hover { background-color: var(--sh-hover); }
.ac-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-hint { font-size: 0.75rem; opacity: 0.65; white-space: nowrap; }
.ac-none { padding: 0.35rem 0.6rem; font-size: 0.9rem; opacity: 0.7; }

.rail { display: none; }

@media (min-width: 1200px) {
    .rail {
        display: block;
        flex: 0 0 300px;
        width: 300px;
        position: sticky;
        top: 4.5rem;
        padding-inline-end: 1.5rem;
    }
}

.rail-card {
    background-color: var(--sh-surface);
    border: 1px solid var(--sh-border-subtle);
    border-radius: 10px;
    padding: 0.9rem 1rem;
    margin-bottom: 1rem;
}

.rail-title { font-size: 1rem; font-weight: 600; margin-bottom: 0.6rem; }
.rail-list { list-style: none; margin: 0 0 0.5rem; padding: 0; }
.rail-list li { padding: 0.35rem 0; }

/* Post composer: the "Start a post" bar and its modal. */
.composer-start-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    margin-bottom: 1rem;
    background-color: var(--sh-surface);
    border: 1px solid var(--sh-border-subtle);
    border-radius: 10px;
}

.composer-start {
    flex: 1 1 auto;
    text-align: start;
    padding: 0.7rem 1.1rem;
    border: 1px solid var(--sh-border-strong);
    border-radius: 999px;
    background: transparent;
    color: var(--sh-text);
    font-weight: 500;
}

.composer-start:hover { background-color: var(--sh-hover); }

.composer-dialog {
    width: min(720px, calc(100vw - 2rem));
    max-height: calc(100vh - 2rem);
    padding: 0;
    border: 1px solid var(--sh-border-strong);
    border-radius: 12px;
    background-color: var(--sh-surface);
    color: var(--sh-text);
    overflow: hidden;
}

.composer-dialog::backdrop { background-color: rgba(0, 0, 0, 0.55); }

.composer-form { position: relative; display: flex; flex-direction: column; max-height: calc(100vh - 2rem); }

.composer-header { display: flex; align-items: flex-start; gap: 0.75rem; padding: 1rem 1rem 0.5rem; }
.composer-who { flex: 1 1 auto; min-width: 0; }
.composer-close { margin-top: 0.25rem; }

.composer-tabs { display: flex; gap: 0.25rem; padding: 0 1rem; border-bottom: 1px solid var(--sh-border-subtle); }
.composer-tab {
    padding: 0.45rem 0.9rem;
    border: 0;
    border-bottom: 3px solid transparent;
    background: transparent;
    color: var(--sh-text);
    opacity: 0.75;
}
.composer-tab.active { opacity: 1; font-weight: 600; border-bottom-color: var(--sh-accent); }

.composer-body { padding: 0.75rem 1rem; overflow-y: auto; flex: 1 1 auto; }
.composer-title { margin-bottom: 0.5rem; }

.composer-footer { display: flex; justify-content: flex-end; gap: 0.5rem; padding: 0.75rem 1rem; border-top: 1px solid var(--sh-border-subtle); }

.composer-confirm {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 1rem;
}
.composer-confirm[hidden] { display: none; }
/* Sign-in style pages: one compact card in the middle of the content column. */
.auth-card {
    max-width: 24rem;
    margin: 2rem auto;
    padding: 1.75rem 1.75rem 1.25rem;
    background-color: var(--sh-surface);
    border: 1px solid var(--sh-border-subtle);
    border-radius: 14px;
    box-shadow: var(--sh-card-shadow);
}
.auth-title { font-size: 1.4rem; margin-bottom: 1.25rem; }
.auth-alt { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--sh-border-subtle); text-align: center; }

/* Home page for visitors who are not signed in. */
.landing-hero {
    padding: 2.5rem 2rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--sh-border-subtle);
    border-radius: 16px;
    background: linear-gradient(135deg, color-mix(in srgb, var(--sh-accent) 14%, var(--sh-surface)), var(--sh-surface) 70%);
}
.landing-title { font-size: clamp(1.9rem, 4vw, 2.6rem); letter-spacing: -0.02em; margin-bottom: 0.75rem; }
.landing-lead { font-size: 1.2rem; max-width: 38rem; color: var(--sh-text-muted); margin-bottom: 1.5rem; }
.landing-panel {
    padding: 1.1rem 1.25rem;
    background-color: var(--sh-surface);
    border: 1px solid var(--sh-border-subtle);
    border-top: 3px solid var(--sh-accent);
    border-radius: 12px;
    box-shadow: var(--sh-card-shadow);
}
.landing-groups { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 0.75rem 1.5rem; }

/* Links that act: Report, Delete, Reply... in one quiet row. Buttons and summaries are drawn as links. */
.action-links { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 1rem; font-size: 0.875rem; }
/* A comment's name and date with its actions after them. An open reply or block form takes the full width on the next line. */
.comment-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.1rem 1rem; }
.comment-head .action-links { display: contents; }
.comment-head .action-links > details[open] { flex: 1 0 100%; order: 99; }

/* Reply: the label stays in the row; ticking its hidden checkbox shows the editor under the comment's name line. */
.reply-toggle:not(:checked) ~ .reply-form { display: none; }
.reply-toggle:checked ~ .comment-head .reply-label { font-weight: 600; }
.reply-toggle:focus-visible ~ .comment-head .reply-label { outline: 2px solid var(--sh-accent); outline-offset: 2px; border-radius: 3px; }
.link-action {
    display: inline;
    padding: 0;
    border: 0;
    background: none;
    color: var(--bs-link-color);
    font: inherit;
    list-style: none;
    cursor: pointer;
    text-decoration: none;
}
.link-action::-webkit-details-marker { display: none; }
.link-action:hover { color: var(--bs-link-hover-color); text-decoration: underline; }
.link-action.danger { color: var(--sh-danger); }

/* Modal dialogs (report, confirm). The box has no padding of its own so a click on the dark area is a click on the dialog. */
.app-dialog {
    width: min(26rem, calc(100vw - 2rem));
    padding: 0;
    color: var(--sh-text);
    background-color: var(--sh-surface);
    border: 1px solid var(--sh-border-strong);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.app-dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.app-dialog > form, .app-dialog-body { padding: 1.25rem; }
.app-dialog-wide { width: min(40rem, calc(100vw - 2rem)); }
.report-thread { max-height: 55vh; overflow-y: auto; margin: 0; padding: 0.5rem 0.75rem; background-color: var(--sh-hover); border-radius: 8px; }
.report-thread > li { padding: 0.25rem 0; }
.report-thread > li + li { border-top: 1px solid var(--sh-border-subtle); }
.report-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.app-dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; }

/* The small person / group icon at the start of a post's byline in a feed. */
.post-kind { display: inline-flex; vertical-align: -2px; margin-inline-end: 0.3rem; opacity: 0.75; }

/* An event's page: a card with its date, title, facts and your answer. */
.event-card { background-color: var(--sh-surface); border: 1px solid var(--sh-border-subtle); border-radius: 12px; padding: 1.1rem 1.25rem; }
.event-card.cancelled { opacity: 0.8; }
.event-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.event-date {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 3.6rem;
    height: 3.9rem;
    border: 1px solid var(--sh-border-strong);
    border-radius: 10px;
    background-color: color-mix(in srgb, var(--sh-accent) 10%, transparent);
    line-height: 1.1;
}
.event-date-month { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--sh-accent); }
.event-date-day { font-size: 1.6rem; font-weight: 700; }
.event-heading { min-width: 0; }
.event-heading h1 { font-size: clamp(1.4rem, 3vw, 1.9rem); overflow-wrap: anywhere; }
.event-facts { display: grid; gap: 0.6rem 2rem; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); margin: 0; padding-bottom: 1rem; border-bottom: 1px solid var(--sh-border-subtle); }
.event-facts dt { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; opacity: 0.65; }
.event-facts dd { margin: 0; overflow-wrap: anywhere; }
.event-rsvp { padding-top: 1rem; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem 1.5rem; }
.event-rsvp-label { font-weight: 600; }

/* Events: one compact row per event under a heading for its day, so a long list stays easy to scan. */
.event-day-title { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; opacity: 0.7; margin: 0 0 0.25rem 0.25rem; }
.event-list { list-style: none; margin: 0; padding: 0; background-color: var(--sh-surface); border: 1px solid var(--sh-border-subtle); border-radius: 10px; overflow: hidden; }
.event-list > li + li { border-top: 1px solid var(--sh-border-subtle); }
.event-row { display: flex; align-items: baseline; gap: 0.9rem; padding: 0.5rem 0.9rem; color: var(--sh-text); text-decoration: none; }
.event-row:hover { background-color: var(--sh-hover); }
.event-time { flex: 0 0 9.5rem; font-size: 0.85rem; opacity: 0.8; }
.event-main { flex: 1 1 auto; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 0.6rem; }
.event-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.event-group { font-size: 0.8rem; opacity: 0.65; white-space: nowrap; }
@media (max-width: 640.98px) { .event-time { flex-basis: 6.5rem; } }

/* Site staff pages: one row of tabs. Gaps and thin dividers separate what is waiting, the lookup tools and the settings. */
.staff-tabs {
    display: flex;
    align-items: center;
    gap: 0.25rem 1.1rem;
    margin: 0.5rem 0 1.25rem;
    border-bottom: 1px solid var(--sh-border-subtle);
    /* Scrolls sideways on a narrow screen, but never shows a scrollbar (and never scrolls up and down: that was the little arrows). */
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    white-space: nowrap;
}
.staff-tabs::-webkit-scrollbar { display: none; }
.staff-tabs .nav-link {
    padding: 0.5rem 0.1rem;
    color: var(--sh-text);
    opacity: 0.75;
    border-bottom: 2px solid transparent;
}
.staff-tabs .nav-link:hover { opacity: 1; }
.staff-tabs .nav-link.active { opacity: 1; font-weight: 600; border-bottom-color: var(--sh-accent); }
.staff-tabs-sep { flex: 0 0 auto; align-self: center; width: 1px; height: 1.2rem; background-color: var(--sh-border-strong); }

/* Profile page: a quiet line of counts and facts, and pills for groups and links. */
.profile-meta { display: flex; flex-wrap: wrap; gap: 0.15rem 1rem; margin-bottom: 1rem; }
.profile-section-title { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; opacity: 0.7; margin-bottom: 0.4rem; }
.pill-row { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.pill {
    display: inline-block;
    max-width: 100%;
    padding: 0.15rem 0.75rem;
    border: 1px solid var(--sh-border-strong);
    border-radius: 999px;
    background: none;
    color: var(--sh-text);
    font: inherit;
    font-size: 0.85rem;
    line-height: 1.5;
    text-decoration: none;
    cursor: pointer;
}
.pill:hover { background-color: var(--sh-hover); color: var(--sh-text); }
.pill-link { max-width: 22rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--bs-link-color); }
.pill-more { border-style: dashed; opacity: 0.85; }
.profile-groups-list { max-height: 60vh; overflow-y: auto; }

/* The manage-group lists: a row per member, ban or invite, with its action at the end. */
.manage-list { list-style: none; margin: 0; padding: 0; }
.manage-list > li { display: flex; align-items: center; gap: 0.75rem; padding: 0.55rem 0; border-top: 1px solid var(--sh-border-subtle); }
.manage-list > li:last-child { border-bottom: 1px solid var(--sh-border-subtle); }
.manage-name { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }

/* Settings pages: a few titled cards, each a stack of rows (label, value or hint, and an action or arrow). */
.settings-page { max-width: 44rem; display: flex; flex-direction: column; gap: 1.25rem; }
.settings-card { background-color: var(--sh-surface); border: 1px solid var(--sh-border-subtle); border-radius: 10px; overflow: hidden; }
.settings-title { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; opacity: 0.7; margin: 0; padding: 0.8rem 1rem 0.4rem; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.75rem 1rem; color: var(--sh-text); text-decoration: none; }
.setting-row + .setting-row { border-top: 1px solid var(--sh-border-subtle); }
.setting-main { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.setting-label { font-weight: 600; }
.setting-value { overflow-wrap: anywhere; }
.setting-hint { font-size: 0.85rem; opacity: 0.7; }
.setting-link:hover { background-color: var(--sh-hover); }
.setting-chevron { font-size: 1.5rem; line-height: 1; opacity: 0.5; }
@media (max-width: 575.98px) { .setting-row:not(.setting-link) { flex-wrap: wrap; } }

/* A group's header (name left, join and options right) with its tabs under it, and the paged member list. */
.group-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.group-title { flex: 1 1 auto; min-width: 0; }
.group-actions { display: flex; align-items: center; gap: 0.5rem; flex: 0 0 auto; }
.group-tabs { margin: 0.75rem 0 1rem; border-bottom: 1px solid var(--sh-border-subtle); gap: 0.25rem 1.1rem; flex-wrap: wrap; }
.group-tabs .nav-link { padding-inline: 0.1rem; color: var(--sh-text); opacity: 0.75; }
.group-tabs .nav-link:hover { opacity: 1; }
.group-tabs .nav-link.active { opacity: 1; font-weight: 600; }
.member-list { list-style: none; margin: 0 0 0.75rem; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 0.4rem 1.5rem; }
.member-list > li { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.member-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* A list of actions in a dialog: each is a row with a short label and a line of explanation under it. */
.option-list { list-style: none; margin: 0; padding: 0; }
.option-list > li + li { border-top: 1px solid var(--sh-border-subtle); }
.option-list a, .option-list summary, .option-danger {
    display: block;
    width: 100%;
    padding: 0.7rem 0.5rem;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--sh-text);
    font: inherit;
    text-align: start;
    text-decoration: none;
    cursor: pointer;
    list-style: none;
}
.option-list summary::-webkit-details-marker { display: none; }
.option-list a:hover, .option-list summary:hover, .option-danger:hover { background-color: var(--sh-hover); }
.option-danger { color: var(--sh-danger); }
.option-hint { display: block; margin-top: 0.1rem; font-size: 0.8rem; opacity: 0.7; color: var(--sh-text); font-weight: normal; }
.option-report[open] > summary { background-color: var(--sh-hover); }
.option-report form { padding: 0.5rem 0.5rem 0.25rem; }

/* Reactions: a small react button with a popup of choices, then chips for the reactions that exist. */
.reactions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; }
.react-picker { position: relative; }
.react-add {
    list-style: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.9rem;
    height: 1.9rem;
    border: 1px solid var(--sh-border-strong);
    border-radius: 999px;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}
.react-add::-webkit-details-marker { display: none; }
.react-add:hover, .react-picker[open] > .react-add { background-color: var(--sh-hover); }
.react-menu {
    position: absolute;
    z-index: 5;
    inset-block-end: calc(100% + 0.3rem);
    inset-inline-start: 0;
    display: flex;
    gap: 0.15rem;
    padding: 0.25rem;
    background-color: var(--sh-surface);
    border: 1px solid var(--sh-border-strong);
    border-radius: 999px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}
.react-choice {
    width: 2.1rem;
    height: 2.1rem;
    border: 0;
    border-radius: 50%;
    background: none;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.08s;
}
.react-choice:hover, .react-choice:focus-visible { background-color: var(--sh-hover); transform: scale(1.2); }
.react-choice.mine { background-color: var(--sh-hover); box-shadow: inset 0 0 0 2px var(--sh-accent); }
.react-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.1rem 0.5rem;
    border: 1px solid var(--sh-border-subtle);
    border-radius: 999px;
    font-size: 0.8rem;
}
.react-chip.mine { border-color: var(--sh-accent); background-color: var(--sh-hover); }

/* Home feed filter: Everything / Groups / People, and a search for one group or person (shown as a chip once picked). */
.feed-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.feed-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    max-width: 100%;
    padding: 0.2rem 0.3rem 0.2rem 0.7rem;
    background-color: var(--sh-surface);
    border: 1px solid var(--sh-border-strong);
    border-radius: 999px;
    font-size: 0.875rem;
}
.feed-chip-kind { font-size: 0.75rem; opacity: 0.65; }
.feed-chip-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-chip-clear { display: inline-flex; align-items: center; justify-content: center; width: 1.4rem; height: 1.4rem; border-radius: 50%; color: var(--sh-text); text-decoration: none; font-size: 1.1rem; line-height: 1; }
.feed-chip-clear:hover { background-color: var(--sh-hover); }


.composer-confirm-box { max-width: 24rem; padding: 1.25rem; border-radius: 10px; background-color: var(--sh-surface); border: 1px solid var(--sh-border-strong); }
