/* ── Theme variables ── */

[data-theme="dark"] {
    --bg-primary: #040e20;
    --bg-secondary: #0a1628;
    --bg-tertiary: #0f1d33;
    --bg-input: #060d1a;
    --bg-input-focus: #132440;
    --bg-hover: rgba(255,255,255,0.05);
    --bg-hover-subtle: rgba(255,255,255,0.03);
    --bg-hover-accent: rgba(93,173,251,0.08);
    --bg-active-accent: rgba(93,173,251,0.15);
    --bg-overlay: rgba(255,255,255,0.08);

    --text-primary: #d6e3ff;
    --text-secondary: rgba(214,227,255,0.65);
    --text-tertiary: rgba(214,227,255,0.5);
    --text-muted: rgba(214,227,255,0.35);
    --text-placeholder: rgba(214,227,255,0.25);
    --text-on-accent: #f7f9ff;

    --border-subtle: rgba(157,179,221,0.08);
    --border-light: rgba(157,179,221,0.05);
    --border-default: rgba(157,179,221,0.15);
    --border-input: rgba(157,179,221,0.12);
    --border-input-focus: #5dadfb;
    --border-context: rgba(157,179,221,0.08);

    --accent: #5dadfb;
    --accent-light: #74b8ff;
    --accent-secondary: #91c5ff;
    --accent-gradient: linear-gradient(135deg, #5dadfb, #91c5ff);
    --accent-logo-gradient: linear-gradient(135deg, #5dadfb, #91c5ff);

    --bubble-sent-bg: #0062a3;
    --bubble-sent-text: #f7f9ff;
    --bubble-recv-bg: #171f33;
    --bubble-recv-text: #dae2fd;
    --bubble-recv-shadow: none;

    --danger: #f56965;
    --danger-hover: #ff8a87;
    --danger-bg-hover: rgba(245,105,101,0.1);

    --shadow-popup: 0 8px 24px rgba(4,14,32,0.6);
    --shadow-card: 0 8px 32px rgba(4,14,32,0.4);
    --shadow-fab: 0 4px 15px rgba(4,14,32,0.5);
    --shadow-calendar: 0 12px 40px rgba(4,14,32,0.7);
    --fab-hover-shadow: 0 6px 20px rgba(93,173,251,0.4);

    --auth-feature-bg: rgba(214,227,255,0.08);
    --auth-feature-icon: rgba(214,227,255,0.7);
    --auth-tagline: rgba(214,227,255,0.55);
    --auth-dot: rgba(214,227,255,0.25);
    --auth-dot-active: rgba(214,227,255,0.85);
    --auth-error-bg: rgba(245,105,101,0.15);
    --auth-error-border: rgba(245,105,101,0.3);
    --auth-error-text: #f56965;
    --auth-success-bg: rgba(22,163,74,0.15);
    --auth-success-border: rgba(22,163,74,0.3);
    --auth-success-text: #86efac;

    --btn-close-filter: invert(1) grayscale(100%) brightness(200%);
    --reply-preview-bg: rgba(93,173,251,0.12);
    --focus-ring: 0 0 0 3px rgba(93,173,251,0.15);
    --overlay-bg: rgba(4,14,32,0.5);
    --overlay-bg-light: rgba(4,14,32,0.3);
}

[data-theme="light"] {
    /* M3 Kinship Blue: soft blue-tinted surfaces */
    --bg-primary: #f0f3ff;
    --bg-secondary: #f9f9ff;
    --bg-tertiary: #ffffff;
    --bg-input: #dfe8ff;
    --bg-input-focus: #ffffff;
    --bg-hover: rgba(28,51,85,0.04);
    --bg-hover-subtle: rgba(28,51,85,0.02);
    --bg-hover-accent: rgba(0,98,163,0.06);
    --bg-active-accent: rgba(0,98,163,0.10);
    --bg-overlay: rgba(28,51,85,0.05);

    --text-primary: #1c3355;
    --text-secondary: #4a6085;
    --text-tertiary: #667ba2;
    --text-muted: #9db3dd;
    --text-placeholder: #9db3dd;
    --text-on-accent: #f7f9ff;

    /* M3 ghost borders — outline-variant at low opacity */
    --border-subtle: rgba(157,179,221,0.15);
    --border-light: rgba(157,179,221,0.08);
    --border-default: rgba(157,179,221,0.25);
    --border-input: rgba(157,179,221,0.20);
    --border-input-focus: #0062a3;
    --border-context: rgba(157,179,221,0.12);

    --accent: #0062a3;
    --accent-light: #00568f;
    --accent-secondary: #5dadfb;
    --accent-gradient: linear-gradient(135deg, #0062a3, #00568f);
    --accent-logo-gradient: linear-gradient(135deg, #0062a3, #5dadfb);

    --bubble-sent-bg: #0062a3;
    --bubble-sent-text: #f7f9ff;
    --bubble-recv-bg: #d6e3ff;
    --bubble-recv-text: #1c3355;
    --bubble-recv-shadow: 0 1px 3px rgba(28,51,85,0.06);

    --danger: #ac3434;
    --danger-hover: #c94040;
    --danger-bg-hover: rgba(172,52,52,0.06);

    --shadow-popup: 0 4px 16px rgba(28,51,85,0.10);
    --shadow-card: 0 2px 12px rgba(28,51,85,0.06);
    --shadow-fab: 0 4px 12px rgba(28,51,85,0.12);
    --shadow-calendar: 0 8px 30px rgba(28,51,85,0.10);
    --fab-hover-shadow: 0 6px 20px rgba(0,98,163,0.30);

    --auth-feature-bg: rgba(28,51,85,0.04);
    --auth-feature-icon: #4a6085;
    --auth-tagline: #667ba2;
    --auth-dot: rgba(28,51,85,0.15);
    --auth-dot-active: rgba(0,98,163,0.7);
    --auth-error-bg: rgba(172,52,52,0.06);
    --auth-error-border: rgba(172,52,52,0.15);
    --auth-error-text: #ac3434;
    --auth-success-bg: rgba(22,163,74,0.06);
    --auth-success-border: rgba(22,163,74,0.15);
    --auth-success-text: #16a34a;

    --btn-close-filter: none;
    --reply-preview-bg: rgba(0,98,163,0.08);
    --focus-ring: 0 0 0 3px rgba(0,98,163,0.12);
    --overlay-bg: rgba(4,14,32,0.25);
    --overlay-bg-light: rgba(4,14,32,0.08);
}

/* ── Foundation ── */

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

h1, h2, h3, h4, h5, h6,
.auth-title,
.navbar-brand,
.notification-panel-title {
    font-family: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
}

/* ── Navbar ── */

.app-navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    background: rgba(249,249,255,0.80);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

[data-theme="dark"] .app-navbar {
    background: rgba(10,22,40,0.80);
}

.app-navbar .navbar-brand {
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 1.1rem;
}

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

.app-navbar .navbar-brand i {
    background: var(--accent-logo-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.app-navbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-navbar-user {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.notification-shell {
    position: relative;
}

.notification-bell {
    position: relative;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 999px;
    background: var(--bg-input);
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, transform 0.2s;
}

.notification-bell:hover {
    background: var(--bg-hover-accent);
    transform: translateY(-1px);
}

.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--accent-gradient);
    color: var(--text-on-accent);
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    box-shadow: var(--shadow-card);
}

.notification-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: min(380px, calc(100vw - 24px));
    background: var(--bg-secondary);
    border-radius: 18px;
    box-shadow: var(--shadow-popup);
    overflow: hidden;
    z-index: 1050;
}

.notification-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-tertiary);
}

.notification-panel-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.notification-panel-subtitle {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.notification-list {
    max-height: min(420px, calc(100dvh - 120px));
    overflow-y: auto;
}

.notification-item {
    width: 100%;
    border: none;
    background: transparent;
    color: inherit;
    text-align: left;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    transition: background-color 0.15s;
}

.notification-item:hover {
    background: var(--bg-hover-accent);
}

.notification-item.unread {
    background: var(--bg-hover-subtle);
}

.notification-item.unread .notification-item-message {
    color: var(--text-primary);
}

.notification-item-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 12px;
    background: var(--bg-input);
    color: var(--accent-light);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.notification-item-body {
    min-width: 0;
    flex: 1;
}

.notification-item-message {
    font-size: 0.88rem;
    line-height: 1.35;
    color: var(--text-secondary);
}

.notification-item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
    font-size: 0.74rem;
    color: var(--text-muted);
}

.notification-item-chat {
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--bg-input);
    color: var(--text-secondary);
}

.notification-empty {
    padding: 24px 18px;
    color: var(--text-secondary);
    font-size: 0.88rem;
    text-align: center;
}

.notification-empty-error {
    color: var(--danger);
}

/* ── Shared buttons ── */

.app-btn-outline {
    color: var(--text-secondary);
    border: 1px solid var(--border-default);
    background: transparent;
}

.app-btn-outline:hover {
    color: var(--text-primary);
    border-color: var(--border-input);
    background: var(--bg-hover);
}

.app-btn-accent {
    background: var(--accent);
    border: none;
    color: var(--text-on-accent);
}

.app-btn-accent:hover {
    opacity: 0.9;
    color: var(--text-on-accent);
}

/* ── Chat sidebar ── */

.chat-sidebar {
    height: 100%;
    overflow-y: auto;
    background: var(--bg-secondary);
    width: 300px;
    min-width: 260px;
    flex-shrink: 0;
}

.sidebar-wrapper {
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Sidebar nav header: hamburger + search pill */
.nav-header {
    display: flex;
    align-items: center;
    padding: 12px;
    gap: 10px;
    background: var(--bg-tertiary);
}

.hamburger-btn {
    color: var(--text-secondary);
    font-size: 1.25rem;
    padding: 4px 8px;
    border: none;
    background: transparent;
}

.hamburger-btn:hover {
    color: var(--accent-light);
    background: var(--bg-hover-accent);
    border-radius: 8px;
}

.search-pill {
    flex: 1;
    background: var(--bg-input);
    border-radius: 20px;
    border: 1px solid transparent;
    padding: 8px 15px;
    color: var(--text-primary);
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
}

.search-pill::placeholder {
    color: var(--text-placeholder);
}

.search-pill:focus {
    border-color: var(--border-input-focus);
}

/* Chat list */
.chat-list {
    flex: 1;
    overflow-y: auto;
}

.chat-item {
    cursor: pointer;
    padding: 10px 14px;
    border-left: 3px solid transparent;
    border-radius: 12px;
    margin: 2px 8px;
    transition: background-color 0.15s;
}

.chat-item:hover {
    background-color: var(--bg-hover-accent);
}

.chat-item.active {
    background-color: var(--bg-active-accent);
    border-left-color: var(--accent);
}

/* Chat item row layout: avatar + content + meta */
.chat-item-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-item-avatar {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
}

.chat-item-avatar-wrapper,
.chat-header-avatar-wrapper {
    position: relative;
    flex-shrink: 0;
}

.online-indicator {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 12px;
    height: 12px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid var(--bg-secondary);
}

.online-status-text {
    font-size: 0.75rem;
    color: #22c55e;
    line-height: 1;
}

.chat-item-content {
    flex: 1;
    min-width: 0;
}

.chat-item-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-preview {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.chat-item-preview-empty {
    color: var(--text-placeholder);
    font-style: italic;
}

.chat-item-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    min-width: fit-content;
}

.chat-item-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.chat-item-badge {
    background: #22c55e;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}

/* Chat header avatar */
.chat-header-avatar {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
}

.chat-item-avatar-img {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 50%;
    object-fit: cover;
}

.chat-header-avatar-img {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 50%;
    object-fit: cover;
}

.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.sidebar-user-avatar-placeholder {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Floating Action Button */
.fab-new {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 52px;
    height: 52px;
    background: var(--accent-gradient);
    border-radius: 50%;
    border: none;
    color: var(--text-on-accent);
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-fab);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 10;
}

.fab-new:hover {
    transform: scale(1.08);
    box-shadow: var(--fab-hover-shadow);
}

/* ── Chat main area ── */

.chat-main {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
}

.chat-header {
    background: var(--bg-secondary);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

/* ── Chat wallpaper ── */

.chat-wallpaper {
    background-color: var(--bg-primary);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Ctext x='20' y='30' font-size='16' fill='white' opacity='0.03'%3E%E2%9C%89%3C/text%3E%3Ctext x='90' y='70' font-size='14' fill='white' opacity='0.03'%3E%E2%AD%90%3C/text%3E%3Ctext x='150' y='40' font-size='12' fill='white' opacity='0.03'%3E%F0%9F%92%AC%3C/text%3E%3Ctext x='40' y='100' font-size='15' fill='white' opacity='0.03'%3E%E2%99%A5%3C/text%3E%3Ctext x='120' y='120' font-size='13' fill='white' opacity='0.03'%3E%E2%9C%A8%3C/text%3E%3Ctext x='10' y='160' font-size='14' fill='white' opacity='0.03'%3E%F0%9F%8C%99%3C/text%3E%3Ctext x='80' y='180' font-size='12' fill='white' opacity='0.03'%3E%E2%9C%89%3C/text%3E%3Ctext x='160' y='170' font-size='16' fill='white' opacity='0.03'%3E%E2%99%A5%3C/text%3E%3C/svg%3E");
    background-repeat: repeat;
}

[data-theme="light"] .chat-wallpaper {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Ctext x='20' y='30' font-size='16' fill='black' opacity='0.03'%3E%E2%9C%89%3C/text%3E%3Ctext x='90' y='70' font-size='14' fill='black' opacity='0.03'%3E%E2%AD%90%3C/text%3E%3Ctext x='150' y='40' font-size='12' fill='black' opacity='0.03'%3E%F0%9F%92%AC%3C/text%3E%3Ctext x='40' y='100' font-size='15' fill='black' opacity='0.03'%3E%E2%99%A5%3C/text%3E%3Ctext x='120' y='120' font-size='13' fill='black' opacity='0.03'%3E%E2%9C%A8%3C/text%3E%3Ctext x='10' y='160' font-size='14' fill='black' opacity='0.03'%3E%F0%9F%8C%99%3C/text%3E%3Ctext x='80' y='180' font-size='12' fill='black' opacity='0.03'%3E%E2%9C%89%3C/text%3E%3Ctext x='160' y='170' font-size='16' fill='black' opacity='0.03'%3E%E2%99%A5%3C/text%3E%3C/svg%3E");
}

/* Tonal layering — both themes use background shifts instead of borders */
.chat-sidebar {
    box-shadow: 2px 0 12px rgba(28,51,85,0.04);
}

.chat-header {
    box-shadow: 0 1px 6px rgba(28,51,85,0.04);
}

.app-navbar {
    box-shadow: 0 1px 6px rgba(28,51,85,0.04);
}

[data-theme="dark"] .chat-sidebar,
[data-theme="dark"] .chat-header,
[data-theme="dark"] .app-navbar {
    box-shadow: 0 1px 6px rgba(4,14,32,0.3);
}

/* ── Message bubbles ── */

.message {
    max-width: 70%;
    margin-bottom: 4px;
}

.message.sent {
    margin-left: auto;
}

/* Spacing: first message in a group gets more top margin */
.message:not(.msg-grouped) {
    margin-top: 10px;
}

.message:first-child {
    margin-top: 0;
}

/* ── Date separator ── */

.date-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 0;
}

.date-separator-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-tertiary);
    background: var(--bg-secondary);
    padding: 4px 14px;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(28,51,85,0.06);
}

.msg-bubble-wrap {
    position: relative;
}

.msg-bubble {
    position: relative;
    padding: 10px 16px;
    border-radius: 18px;
}

/* Sent bubble: flat primary, asymmetric corners */
.message.sent .msg-bubble {
    background: var(--bubble-sent-bg);
    color: var(--bubble-sent-text);
    border-bottom-right-radius: 18px;
}

.message.sent.msg-tail .msg-bubble {
    border-bottom-right-radius: 4px;
}

/* Received bubble: pink/rose, asymmetric corners */
.message.received .msg-bubble {
    background: var(--bubble-recv-bg);
    color: var(--bubble-recv-text);
    border-bottom-left-radius: 18px;
    box-shadow: var(--bubble-recv-shadow);
}

.message.received.msg-tail .msg-bubble {
    border-bottom-left-radius: 4px;
}

.msg-sender {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-light);
    margin-bottom: 2px;
}

.msg-time {
    font-size: 0.7rem;
    text-align: right;
    opacity: 0.5;
    margin-top: 2px;
}

/* ── Chat input ── */

.chat-input {
    padding: 0.75rem;
    background: var(--bg-secondary);
}

.chat-input-field {
    background: var(--bg-primary) !important;
    border: 1px solid var(--border-input) !important;
    color: var(--text-primary) !important;
}

.chat-input-field:focus {
    background: var(--bg-input-focus) !important;
    border-color: var(--border-input-focus) !important;
    box-shadow: var(--focus-ring) !important;
    color: var(--text-primary) !important;
}

.chat-input-field::placeholder {
    color: var(--text-placeholder) !important;
}

/* ── Typing indicator ── */

.typing-indicator {
    background: var(--bg-secondary);
    color: var(--text-muted);
}

/* ── Context menu (three-dot dropdown) ── */

.context-menu {
    background-color: var(--bg-tertiary);
    border-radius: 8px;
    box-shadow: var(--shadow-popup);
    padding: 8px 0;
    min-width: 180px;
    border: 1px solid var(--border-context);
}

.menu-item {
    padding: 10px 16px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 0.875rem;
}

.menu-item:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.menu-item-danger {
    color: var(--danger) !important;
}

.menu-item-danger:hover {
    background-color: var(--danger-bg-hover) !important;
    color: var(--danger-hover) !important;
}

/* ── Header icon buttons ── */

.header-icon-btn {
    color: var(--text-secondary);
    border: none;
    background: transparent;
    padding: 6px 8px;
    border-radius: 8px;
    font-size: 1rem;
}

.header-icon-btn:hover {
    color: var(--text-primary);
    background: var(--bg-overlay);
}

/* ── Search header mode (Telegram-style) ── */

.search-header-input {
    flex: 1;
    background: transparent;
    border: none;
    border-bottom: 2px solid var(--accent);
    color: var(--text-primary);
    padding: 4px 8px;
    font-size: 0.9rem;
    outline: none;
    margin: 0 10px;
}

.search-header-input::placeholder {
    color: var(--text-muted);
}

.chat-search-count {
    color: var(--text-muted);
    font-size: 0.75rem;
    white-space: nowrap;
}

/* ── Calendar popup ── */

.calendar-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    z-index: 100;
}

.calendar-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-tertiary);
    border-radius: 12px;
    padding: 20px;
    color: var(--text-primary);
    z-index: 101;
    box-shadow: var(--shadow-calendar);
    min-width: 300px;
}

.calendar-selected-label {
    font-size: 0.85rem;
    color: var(--text-tertiary);
    margin-bottom: 12px;
}

.calendar-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.calendar-month-label {
    font-weight: 600;
    font-size: 0.95rem;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    text-align: center;
}

.calendar-weekday {
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 6px 0;
    font-weight: 600;
}

.calendar-day {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.85rem;
    cursor: pointer;
    margin: 1px auto;
    transition: background 0.15s;
}

.calendar-day:hover:not(.other-month) {
    background: var(--bg-overlay);
}

.calendar-day.other-month {
    cursor: default;
}

.calendar-day.today {
    border: 1px solid var(--accent);
}

.calendar-day.selected {
    background-color: var(--accent);
    color: var(--text-on-accent);
    font-weight: 600;
}

.calendar-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 16px;
}

.calendar-btn-cancel {
    color: var(--text-tertiary);
    font-weight: 600;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
}

.calendar-btn-cancel:hover {
    color: var(--text-primary);
}

.calendar-btn-jump {
    color: var(--accent-light);
    font-weight: 600;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
}

.calendar-btn-jump:hover:not(:disabled) {
    color: var(--accent-secondary);
}

.calendar-btn-jump:disabled {
    color: var(--text-placeholder);
}

/* ── Message context menu (right-click) ── */

.msg-menu-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-bg-light);
    z-index: 200;
}

.msg-context-menu {
    position: fixed;
    background: var(--bg-tertiary);
    border-radius: 10px;
    box-shadow: var(--shadow-popup);
    border: 1px solid var(--border-context);
    padding: 6px 0;
    min-width: 170px;
    z-index: 201;
}

.msg-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    text-align: left;
}

.msg-menu-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.msg-menu-item-danger {
    color: var(--danger) !important;
}

.msg-menu-item-danger:hover {
    background: var(--danger-bg-hover) !important;
    color: var(--danger-hover) !important;
}

/* ── Reaction quick-pick row in context menu ── */
.msg-menu-reactions {
    display: flex;
    gap: 2px;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    justify-content: center;
}

.msg-menu-reaction-btn {
    background: none;
    border: none;
    font-size: 1.25rem;
    padding: 4px 6px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
    line-height: 1;
}

.msg-menu-reaction-btn:hover {
    background: var(--surface-hover);
    transform: scale(1.2);
}

/* ── Bottom sheet (mobile context menu) ── */
.msg-menu-overlay.mobile {
    background: rgba(0, 0, 0, 0.5);
}

.msg-context-menu.bottom-sheet {
    top: auto !important;
    left: 0 !important;
    right: 0;
    bottom: 0;
    border-radius: 16px 16px 0 0;
    min-width: 100%;
    max-height: 70vh;
    overflow-y: auto;
    padding-bottom: env(safe-area-inset-bottom, 8px);
    animation: slideUp 0.25s ease-out;
}

.msg-context-menu.bottom-sheet .msg-menu-item {
    padding: 14px 20px;
    font-size: 0.95rem;
}

.msg-context-menu.bottom-sheet .msg-menu-reactions {
    padding: 12px 8px;
    gap: 4px;
}

.msg-context-menu.bottom-sheet .msg-menu-reaction-btn {
    font-size: 1.5rem;
    padding: 8px 10px;
}

.bottom-sheet-handle {
    width: 36px;
    height: 4px;
    background: var(--text-tertiary);
    border-radius: 2px;
    margin: 8px auto 4px;
    opacity: 0.5;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* Disable text selection on long-press for messages */
.message {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* ── Chevron dropdown button on message bubble ── */
.msg-chevron-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 50%;
    font-size: 0.65rem;
    color: var(--text-tertiary);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 2;
    padding: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.message:hover .msg-chevron-btn,
.msg-chevron-btn:focus {
    opacity: 1;
}

/* Always show chevron on touch devices */
@media (hover: none) {
    .msg-chevron-btn {
        opacity: 0.7;
    }
}

.message.sent .msg-chevron-btn {
    background: color-mix(in srgb, var(--bubble-sent-bg) 70%, black);
    color: var(--bubble-sent-text);
}

.message.received .msg-chevron-btn {
    background: color-mix(in srgb, var(--bubble-recv-bg) 70%, black);
    color: var(--bubble-recv-text);
}

/* ── Reaction pills overlapping bubble bottom ── */
.msg-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    position: relative;
    margin-top: -10px;
    padding-left: 4px;
    z-index: 1;
}

/* Sent messages: reactions on the right */
.message.sent .msg-reactions {
    justify-content: flex-end;
    padding-right: 4px;
    padding-left: 0;
}

/* Add bottom margin on messages with reactions so pills don't overlap next message */
.message.has-reactions {
    margin-bottom: 14px;
}

.msg-reaction-pill {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.15s, border-color 0.15s;
    line-height: 1.4;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.msg-reaction-pill:hover {
    background: var(--surface-hover);
}

.msg-reaction-pill.mine {
    border-color: var(--primary);
    background: color-mix(in srgb, var(--primary) 12%, transparent);
}

.msg-reaction-emoji {
    font-size: 0.95rem;
}

.msg-reaction-count {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.msg-reaction-pill.mine .msg-reaction-count {
    color: var(--primary);
}

/* ── Message meta (time + ticks) ── */

.msg-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 2px;
}

.msg-meta .msg-time {
    font-size: 0.7rem;
    opacity: 0.5;
}

.msg-tick {
    font-size: 0.8rem;
    opacity: 0.5;
}

.msg-tick-read {
    color: var(--accent-light);
    opacity: 1;
}

/* ── Pulse highlight (jump-to-date) ── */

@keyframes msg-pulse {
    0% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.5); }
    50% { box-shadow: 0 0 0 6px rgba(99, 102, 241, 0.25); }
    100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}

.msg-pulse .msg-bubble {
    animation: msg-pulse 0.8s ease-in-out 2;
}

/* ── Image messages ── */

.msg-image-wrapper {
    cursor: pointer;
    margin: 4px -8px;
    overflow: hidden;
    border-radius: 12px;
}

.msg-image-wrapper:first-child {
    margin-top: -2px;
}

.msg-image {
    display: block;
    max-width: 280px;
    max-height: 320px;
    width: 100%;
    height: auto;
    object-fit: cover;
    border-radius: 12px;
    background: var(--bg-tertiary);
    transition: transform 0.15s;
}

.msg-image-wrapper:hover .msg-image {
    transform: scale(1.02);
}

.msg-file-attachment {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin: 4px -4px;
    background: var(--bg-overlay);
    border-radius: 10px;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.msg-file-attachment i {
    font-size: 1.1rem;
    color: var(--accent);
}

.msg-file-size {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* ── Chat attachment button ── */

.chat-attach-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    border: none;
    background: transparent;
    transition: color 0.15s;
}

.chat-attach-btn:hover {
    color: var(--accent);
}

.chat-input-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    color: var(--text-secondary);
    font-size: 1.15rem;
    border: none;
    background: transparent;
    transition: color 0.15s;
}

.chat-input-icon-btn:hover {
    color: var(--accent);
}

.chat-input-icon-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.compose-bar-image-preview {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
}

/* ── Image lightbox ── */

.lightbox-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}

.lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    z-index: 1;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.lightbox-image {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    cursor: default;
    border-radius: 8px;
}

/* ── Pinned message bar ── */

.pinned-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
    cursor: pointer;
}

.pinned-bar:hover {
    background: var(--bg-hover-subtle);
}

.pinned-icon {
    color: var(--accent);
    font-size: 0.9rem;
}

.pinned-content {
    flex: 1;
    min-width: 0;
}

.pinned-sender {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-light);
}

.pinned-text {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Reply preview in message bubble ── */

.msg-reply-preview {
    background: var(--reply-preview-bg);
    border-left: 3px solid var(--accent);
    border-radius: 4px;
    padding: 4px 8px;
    margin-bottom: 4px;
    font-size: 0.78rem;
}

.msg-reply-name {
    display: block;
    font-weight: 600;
    color: var(--accent-light);
}

.msg-reply-text {
    display: block;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

/* ── Forwarded label ── */

.msg-forwarded {
    font-size: 0.75rem;
    color: var(--accent-light);
    font-style: italic;
    margin-bottom: 2px;
}

/* ── Edited label ── */

.msg-edited {
    font-size: 0.65rem;
    opacity: 0.4;
    font-style: italic;
}

/* ── Deleted message ── */

.msg-deleted-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
}

/* ── Compose bar (reply / edit indicator above input) ── */

.compose-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-subtle);
}

.compose-bar-accent {
    width: 3px;
    height: 32px;
    background: var(--accent);
    border-radius: 2px;
}

.compose-bar-edit .compose-bar-accent {
    background: var(--accent-light);
}

.compose-bar-content {
    flex: 1;
    min-width: 0;
}

.compose-bar-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-light);
}

.compose-bar-text {
    display: block;
    font-size: 0.8rem;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Forward chat picker avatar ── */

.chat-avatar-sm {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-active-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-light);
    font-size: 0.9rem;
}

/* ── Bootstrap theme overrides for our palette ── */

[data-theme] .modal-content {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-context);
}

[data-theme] .modal-header {
    border-bottom-color: var(--border-subtle);
}

[data-theme] .btn-close {
    filter: var(--btn-close-filter);
}

[data-theme] .form-control {
    background: var(--bg-primary);
    border-color: var(--border-input);
    color: var(--text-primary);
}

[data-theme] .form-control:focus {
    background: var(--bg-input-focus);
    border-color: var(--border-input-focus);
    box-shadow: var(--focus-ring);
    color: var(--text-primary);
}

[data-theme] .form-check-input {
    background-color: var(--bg-primary);
    border-color: var(--border-default);
}

[data-theme] .form-check-input:checked {
    background-color: var(--accent);
    border-color: var(--accent);
}

/* ── Dropdown menu overrides ── */

[data-theme] .dropdown-menu {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-context);
    box-shadow: var(--shadow-popup);
}

[data-theme] .dropdown-item {
    color: var(--text-secondary);
}

[data-theme] .dropdown-item:hover,
[data-theme] .dropdown-item:focus {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

[data-theme] .dropdown-item-text {
    color: var(--text-muted) !important;
}

[data-theme] .dropdown-divider {
    border-color: var(--border-subtle);
}

/* ── Auth page (login / register) ── */

.auth-page {
    display: flex;
    min-height: 100vh;
    background: var(--bg-primary);
}

/* Left branding panel */
.auth-brand {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-brand-content {
    text-align: center;
    color: var(--text-primary);
    max-width: 360px;
}

.auth-logo i {
    font-size: 4rem;
    background: var(--accent-logo-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-tagline {
    margin-top: 1rem;
    font-weight: 300;
    color: var(--auth-tagline);
    font-size: 1.05rem;
}

/* Feature carousel */
.auth-features {
    position: relative;
    height: 120px;
    margin-top: 3rem;
}

.auth-feature {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.6s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.auth-feature.active {
    opacity: 1;
}

.auth-feature-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--auth-feature-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.75rem;
}

.auth-feature-icon i {
    font-size: 1.25rem;
    color: var(--auth-feature-icon);
}

.auth-feature h5 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

.auth-feature p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
}

/* Dot indicators */
.auth-dots {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 1.5rem;
}

.auth-dots .dot {
    width: 8px;
    height: 8px;
    border-radius: 4px;
    background: var(--auth-dot);
    cursor: pointer;
    transition: all 0.3s ease;
}

.auth-dots .dot.active {
    background: var(--auth-dot-active);
    width: 24px;
}

/* Right auth panel */
.auth-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--bg-secondary);
}

.auth-card {
    background: var(--bg-tertiary);
    border-radius: 16px;
    padding: 2.5rem;
    width: 400px;
    max-width: 100%;
    box-shadow: var(--shadow-card);
}

.auth-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

.auth-subtitle {
    color: var(--text-tertiary);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.auth-field {
    margin-bottom: 1rem;
}

.auth-field label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
    text-transform: uppercase;
}

.auth-field input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border-input);
    border-radius: 8px;
    font-size: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.auth-field input:focus {
    outline: none;
    border-color: var(--border-input-focus);
    box-shadow: var(--focus-ring);
    background: var(--bg-input-focus);
}

.auth-field input::placeholder {
    color: var(--text-placeholder);
}

.auth-btn {
    width: 100%;
    padding: 0.85rem;
    border: none;
    border-radius: 9999px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-on-accent);
    background: var(--accent-gradient);
    cursor: pointer;
    transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
    margin-top: 0.5rem;
    box-shadow: 0 2px 8px rgba(0,98,163,0.2);
}

.auth-btn:hover:not(:disabled) {
    box-shadow: var(--fab-hover-shadow);
    transform: translateY(-1px);
}

.auth-btn:active:not(:disabled) {
    transform: scale(0.98);
    box-shadow: none;
}

.auth-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.auth-error {
    background: var(--auth-error-bg);
    border: 1px solid var(--auth-error-border);
    color: var(--auth-error-text);
    padding: 0.625rem 0.875rem;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.auth-success {
    background: var(--auth-success-bg);
    border: 1px solid var(--auth-success-border);
    color: var(--auth-success-text);
    padding: 0.625rem 0.875rem;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.auth-switch {
    text-align: center;
    margin-top: 1.5rem;
    margin-bottom: 0;
    color: var(--text-tertiary);
    font-size: 0.875rem;
}

.auth-switch a {
    color: var(--accent-light);
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.auth-switch a:hover {
    text-decoration: underline;
}

.auth-card-brand {
    text-align: center;
    margin-bottom: 1.5rem;
}

.auth-card-icon {
    font-size: 2rem;
    background: var(--accent-logo-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: block;
    margin-bottom: 0.5rem;
}

.auth-card-brand .auth-title {
    margin-bottom: 0.25rem;
}

.auth-card-brand .auth-subtitle {
    margin-bottom: 0;
}

.auth-encrypted {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    letter-spacing: 0.02em;
}

.auth-encrypted i {
    color: var(--accent);
}

.auth-input-mono {
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

/* Responsive: hide branding panel below 900px */
@media (max-width: 900px) {
    .auth-brand {
        display: none;
    }

    .auth-page {
        min-height: 0;
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
        background: var(--bg-secondary);
    }

    .auth-panel {
        height: 100%;
        padding: 1rem;
    }

    .auth-card {
        width: 100%;
        box-shadow: none;
        background: transparent;
        padding: 1.5rem;
    }
}

/* ── End auth page ── */

/* ── App Shell Layout ── */

.app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

@media (min-width: 768px) {
    .app-shell {
        flex-direction: row;
    }
}

.app-nav-rail-wrapper {
    flex-shrink: 0;
}

.app-content {
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.app-bottom-bar-wrapper {
    flex-shrink: 0;
}

/* ── Chat Page Layout ── */

.chat-page {
    display: flex;
    height: 100%;
    overflow: hidden;
}

.chat-main-wrapper {
    flex: 1;
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* ── NavRail (desktop side nav) ── */

.nav-rail {
    display: flex;
    flex-direction: column;
    width: 68px;
    height: 100%;
    background: var(--bg-secondary);
    padding: 12px 0;
    box-shadow: 1px 0 8px rgba(28,51,85,0.04);
}

[data-theme="dark"] .nav-rail {
    box-shadow: 1px 0 8px rgba(4,14,32,0.3);
}

.nav-rail-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

/* Mood Board */
.nav-rail-mood-board {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 2px;
    margin-top: auto;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 40vh;
}

.nav-rail-mood-board::-webkit-scrollbar {
    width: 3px;
}

.nav-rail-mood-board::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}

.nav-rail-mood-title {
    font-size: 0.5rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-align: center;
    width: 100%;
    padding: 0 4px;
    word-spacing: 2px;
}

.nav-rail-mood-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px;
}

.nav-rail-mood-emoji {
    font-size: 1.1rem;
}

.nav-rail-mood-name {
    font-size: 0.6rem;
    color: var(--text-secondary);
    max-width: 56px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
}

.nav-rail-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 0 8px;
    margin-top: auto;
    flex-shrink: 0;
}

.nav-rail-avatar-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-decoration: none;
    color: var(--text-secondary);
    padding: 6px;
    border-radius: 14px;
    transition: background 0.15s, color 0.15s;
}

.nav-rail-avatar-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-rail-avatar-link.active {
    background: var(--bg-active-accent);
    color: var(--accent);
}

.nav-rail-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin-bottom: 12px;
    text-decoration: none;
    font-size: 1.4rem;
}

.nav-rail-brand i {
    background: var(--accent-logo-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-rail-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 52px;
    border-radius: 14px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    transition: background 0.15s, color 0.15s;
    position: relative;
}

.nav-rail-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-rail-item.active {
    background: var(--bg-active-accent);
    color: var(--accent);
}

.nav-rail-label {
    font-size: 0.6rem;
    font-weight: 600;
    margin-top: 2px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.nav-rail-badge {
    position: absolute;
    top: 4px;
    right: 6px;
    background: var(--danger);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.nav-rail-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
}

.nav-rail-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.nav-rail-avatar-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: var(--text-on-accent);
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 50%;
}

/* ── BottomTabBar (mobile) ── */

.bottom-tab-bar {
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: 56px;
    background: var(--bg-secondary);
    box-shadow: 0 -1px 8px rgba(28,51,85,0.04);
    padding: 0 8px;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

[data-theme="dark"] .bottom-tab-bar {
    box-shadow: 0 -1px 8px rgba(4,14,32,0.3);
}

.bottom-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 100%;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 1.15rem;
    transition: color 0.15s;
    position: relative;
}

.bottom-tab:hover {
    color: var(--text-primary);
}

.bottom-tab.active {
    color: var(--accent);
}

.bottom-tab-label {
    font-size: 0.6rem;
    font-weight: 600;
    margin-top: 2px;
    letter-spacing: 0.02em;
}

.bottom-tab-icon-wrapper {
    position: relative;
    display: inline-flex;
}

.bottom-tab-badge {
    position: absolute;
    top: -6px;
    right: -10px;
    background: var(--danger);
    color: #fff;
    font-size: 0.55rem;
    font-weight: 700;
    min-width: 14px;
    height: 14px;
    padding: 0 3px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* ── Settings Page ── */

.settings-page {
    height: 100%;
    overflow-y: auto;
    background: var(--bg-primary);
}

.settings-header {
    padding: 24px 24px 12px;
}

.settings-title {
    font-family: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.settings-content {
    padding: 0 16px 24px;
    max-width: 600px;
}

.settings-section {
    margin-bottom: 24px;
}

.settings-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    padding: 0 8px 8px;
    margin: 0;
}

.settings-profile-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 16px;
}

.settings-avatar-wrapper {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    border-radius: 50%;
    overflow: hidden;
}

.settings-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.settings-avatar-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: var(--text-on-accent);
    font-size: 1.25rem;
    font-weight: 700;
    border-radius: 50%;
}

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

.settings-profile-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.settings-profile-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.settings-btn {
    font-size: 0.8rem;
    border-radius: 999px;
    padding: 4px 12px;
}

.settings-hint {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: 6px;
}

.settings-error {
    color: var(--danger);
    font-size: 0.8rem;
    margin-top: 6px;
}

.settings-success {
    color: var(--accent);
    font-size: 0.8rem;
    margin-bottom: 8px;
    font-weight: 500;
}

/* ---- Status Chips Row (Chat List top) ---- */
.status-chips-row {
    display: flex;
    gap: 8px;
    padding: 8px 16px;
    overflow-x: auto;
    flex-shrink: 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.status-chips-row::-webkit-scrollbar {
    display: none;
}

.status-chips-item {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    border-radius: 20px;
    background: var(--tertiary-container, var(--primary-dim));
    white-space: nowrap;
    font-size: 0.82rem;
    flex-shrink: 0;
    cursor: default;
}

.status-chips-emoji {
    font-size: 0.95rem;
}

.status-chips-label {
    color: var(--text-primary);
    font-weight: 500;
}

.status-chips-mine {
    background: var(--bg-active-accent);
    border: 1px solid var(--accent);
}

/* ---- Status Chip (inline) ---- */
.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 6px;
    border-radius: 10px;
    background: var(--primary-dim);
    font-size: 0.7rem;
    line-height: 1.2;
    max-width: 120px;
    overflow: hidden;
    white-space: nowrap;
    vertical-align: middle;
    margin-left: 4px;
}

.status-chip-emoji {
    font-size: 0.75rem;
    flex-shrink: 0;
}

.status-chip-text {
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

/* ---- Status Selector (Settings) ---- */
.status-selector {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.status-current {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: 10px;
}

.status-current .status-chip {
    font-size: 0.85rem;
    padding: 3px 10px;
    max-width: none;
}

.status-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.status-preset-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.status-preset-btn:hover {
    background: var(--primary-dim);
    border-color: var(--primary);
}

.status-preset-btn.active {
    background: var(--primary);
    color: var(--on-primary);
    border-color: var(--primary);
}

.status-preset-check {
    font-size: 0.75rem;
    margin-left: 2px;
}

.status-presets-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-bottom: 6px;
    margin-top: 4px;
}

.status-preset-emoji {
    font-size: 0.95rem;
}

.status-preset-text {
    font-size: 0.82rem;
}

.status-custom {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-custom-input {
    flex: 1;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.85rem;
    outline: none;
}

.status-custom-input:focus {
    border-color: var(--primary);
}

.status-custom-emoji {
    width: 48px;
    padding: 8px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
    text-align: center;
    outline: none;
}

.status-custom-emoji:focus {
    border-color: var(--primary);
}

.settings-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border: none;
    border-radius: 14px;
    cursor: pointer;
    transition: background 0.15s;
    color: var(--text-primary);
    text-align: left;
    margin-bottom: 4px;
}

.settings-row:hover {
    background: var(--bg-hover);
}

.settings-row-icon {
    font-size: 1.1rem;
    color: var(--text-secondary);
    width: 28px;
    text-align: center;
}

.settings-row-content {
    flex: 1;
    min-width: 0;
}

.settings-row-label {
    font-size: 0.95rem;
    font-weight: 500;
}

.settings-row-value {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.settings-row-chevron {
    color: var(--text-tertiary);
    font-size: 0.85rem;
}

.settings-row-danger {
    color: var(--danger);
}

.settings-row-danger .settings-row-icon {
    color: var(--danger);
}

/* ── Notifications Page ── */

.notifications-page {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    overflow: hidden;
}

.notifications-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 24px 12px;
    flex-shrink: 0;
}

.notifications-title {
    font-family: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.notifications-header-actions {
    display: flex;
    gap: 8px;
}

.notifications-tabs {
    display: flex;
    gap: 4px;
    padding: 0 20px 12px;
    flex-shrink: 0;
}

.notifications-tab {
    padding: 6px 14px;
    border-radius: 999px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.notifications-tab:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.notifications-tab.active {
    background: var(--bg-active-accent);
    color: var(--accent);
}

.notifications-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    margin-left: 6px;
    vertical-align: middle;
}

.notifications-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px 16px;
}

.notification-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border: none;
    border-radius: 14px;
    cursor: pointer;
    transition: background 0.15s, transform 0.2s ease;
    text-align: left;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.notification-card:hover {
    background: var(--bg-hover);
}

.notification-card:active {
    transform: scale(0.98);
}

.notification-card.unread {
    background: var(--bg-hover-accent);
}

.notification-card-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-active-accent);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.notification-card-body {
    flex: 1;
    min-width: 0;
}

.notification-card-message {
    font-size: 0.9rem;
    color: var(--text-primary);
    line-height: 1.4;
}

.notification-card-meta {
    display: flex;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.notification-card-chat {
    color: var(--accent);
}

.notification-card-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
    margin-top: 6px;
}

/* Notification icon color variants */
.notification-card-icon.icon-message {
    background: var(--bg-active-accent);
    color: var(--accent);
}

.notification-card-icon.icon-group {
    background: rgba(46, 196, 134, 0.15);
    color: #2ec486;
}

.notification-card-icon.icon-warning {
    background: rgba(251, 146, 60, 0.15);
    color: #fb923c;
}

/* Notification action buttons */
.notification-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.notification-action-btn {
    padding: 5px 14px;
    border-radius: 999px;
    border: none;
    background: var(--bg-active-accent);
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
}

.notification-action-btn:hover {
    background: var(--accent);
    color: #fff;
}

.notification-action-btn:active {
    transform: scale(0.96);
}

.notifications-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
    text-align: center;
}

.notifications-empty-error {
    color: var(--danger);
}

/* ── Mobile layout ── */

@media (max-width: 767.98px) {
    .chat-sidebar {
        height: 100%;
        width: 100%;
    }

    .chat-main {
        height: 100%;
    }

    .chat-page {
        flex-direction: column;
    }

    .chat-main-wrapper {
        flex: 1;
    }

    .hide-mobile {
        display: none !important;
    }
}

/* ── No-chats / empty state helper ── */

.text-empty-state {
    color: var(--text-muted);
}

.text-last-message {
    color: var(--text-muted);
}

.text-no-messages {
    color: var(--text-placeholder);
}

#blazor-error-ui {
    display: none;
}

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
}
