/* ============================================================
   ToonBook — Custom Theme
   Bootstrap 5 augmentation layer. All custom classes use tb- prefix.

   Token model (two-layer):
     * Palette tokens (--tb-primary, --tb-secondary, etc.) carry the
       brand identity and stay constant across light/dark.
     * Semantic tokens (--tb-surface, --tb-text, --tb-border, etc.)
       are consumed everywhere and swap values under [data-theme="dark"].
   ============================================================ */

/* --- Variables (light defaults) --- */
:root {
    color-scheme: light;

    /* Brand palette */
    --tb-primary: #667eea;
    --tb-primary-dark: #5a67d8;
    --tb-primary-light: #a3bffa;
    --tb-secondary: #764ba2;
    --tb-accent: #f093fb;
    --tb-gradient: linear-gradient(135deg, var(--tb-primary) 0%, var(--tb-secondary) 100%);

    /* Brand-tinted overlays (used for hovers, soft fills, focus rings) */
    --tb-primary-soft: rgba(102, 126, 234, 0.08);
    --tb-primary-softer: rgba(102, 126, 234, 0.04);
    --tb-primary-tint: rgba(102, 126, 234, 0.10);
    --tb-focus-ring: rgba(102, 126, 234, 0.15);

    /* Status / role colors (semantic, stay constant across modes) */
    --tb-status-active: #28a745;
    --tb-status-inactive: #6c757d;
    --tb-status-retired: #ffc107;
    --tb-status-pending: #17a2b8;
    --tb-status-accepted: #28a745;

    --tb-role-leader: #ffc107;
    --tb-role-officer: #17a2b8;
    --tb-role-member: #6c757d;

    --tb-role-leader-text: #856404;
    --tb-role-leader-bg: rgba(255, 193, 7, 0.15);
    --tb-role-officer-text: #0c5460;
    --tb-role-officer-bg: rgba(23, 162, 184, 0.15);
    --tb-role-member-text: #495057;
    --tb-role-member-bg: rgba(108, 117, 125, 0.10);

    /* Surfaces */
    --tb-surface: #fff;             /* base page bg */
    --tb-surface-raised: #fff;      /* cards, modals, auth card */
    --tb-surface-overlay: #fff;     /* nav, dropdowns */
    --tb-surface-soft: #f8f9fa;     /* soft accent fields (search input) */
    --tb-surface-sunken: #fafafa;   /* sunken footer-ish */
    --tb-surface-tinted: rgba(0, 0, 0, 0.01); /* very faint accent (card footer) */
    --tb-surface-muted: rgba(0, 0, 0, 0.02);  /* row hover background */
    --tb-surface-hover: rgba(0, 0, 0, 0.05);  /* button-style hover */

    /* Text */
    --tb-text: #212529;
    --tb-text-strong: #1f2937;
    --tb-text-emphasis: #374151;
    --tb-text-muted: #6c757d;
    --tb-text-subtle: #718096;
    --tb-text-quiet: #a0aec0;
    --tb-text-on-brand: #fff;       /* on gradient / primary fills */
    --tb-text-on-overlay: #fff;     /* on media dark overlays */

    /* Borders / dividers */
    --tb-border: rgba(0, 0, 0, 0.05);
    --tb-divider: rgba(0, 0, 0, 0.06);
    --tb-border-soft: rgba(0, 0, 0, 0.08);
    --tb-border-strong: #d1d5db;

    /* Icon shades */
    --tb-icon-muted: #9ca3af;
    --tb-empty-icon: #cbd5e0;
    --tb-empty-title: #4a5568;

    /* Avatar placeholders */
    --tb-avatar-placeholder-from: #e2e8f0;
    --tb-avatar-placeholder-to: #cbd5e0;
    --tb-avatar-placeholder-text: #718096;
    --tb-avatar-placeholder-from-alt: #e5e7eb;
    --tb-avatar-placeholder-to-alt: #d1d5db;
    --tb-avatar-placeholder-text-alt: #6b7280;

    /* Auth backdrop */
    --tb-auth-bg: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);

    /* Spacing */
    --tb-space-xs: 0.25rem;
    --tb-space-sm: 0.5rem;
    --tb-space-md: 1rem;
    --tb-space-lg: 1.5rem;
    --tb-space-xl: 2rem;
    --tb-space-2xl: 3rem;

    /* Avatar sizes */
    --tb-avatar-sm: 32px;
    --tb-avatar-md: 48px;
    --tb-avatar-lg: 80px;
    --tb-avatar-xl: 120px;

    /* Shadows (revalued in dark) */
    --tb-shadow-card: 0 2px 8px rgba(0, 0, 0, 0.08);
    --tb-shadow-card-hover: 0 4px 16px rgba(0, 0, 0, 0.12);
    --tb-shadow-nav: 0 2px 4px rgba(0, 0, 0, 0.04);
    --tb-shadow-auth-card: 0 20px 60px rgba(0, 0, 0, 0.10);

    /* Motion */
    --tb-transition-fast: 150ms ease;
    --tb-transition-normal: 300ms ease;

    /* Radius */
    --tb-radius-sm: 0.375rem;
    --tb-radius-md: 0.5rem;
    --tb-radius-lg: 1rem;
    --tb-radius-full: 50%;

    /* Type */
    --tb-font-heading: 'Inter', system-ui, -apple-system, sans-serif;
    --tb-font-body: 'Inter', system-ui, -apple-system, sans-serif;
}

/* --- Dark mode overrides (semantic tokens only) --- */
[data-theme="dark"] {
    color-scheme: dark;

    /* Brand-tinted overlays — use the lighter primary stop for visibility on dark */
    --tb-primary-soft: rgba(163, 191, 250, 0.12);
    --tb-primary-softer: rgba(163, 191, 250, 0.06);
    --tb-primary-tint: rgba(163, 191, 250, 0.15);
    --tb-focus-ring: rgba(163, 191, 250, 0.25);

    /* Role badge contrast pairs */
    --tb-role-leader-text: #fbbf24;
    --tb-role-leader-bg: rgba(251, 191, 36, 0.18);
    --tb-role-officer-text: #67e8f9;
    --tb-role-officer-bg: rgba(103, 232, 249, 0.15);
    --tb-role-member-text: #cbd5e0;
    --tb-role-member-bg: rgba(148, 163, 184, 0.15);

    /* Surfaces — slate scale */
    --tb-surface: #0f172a;
    --tb-surface-raised: #1e293b;
    --tb-surface-overlay: #1e293b;
    --tb-surface-soft: #1e293b;
    --tb-surface-sunken: #0b1120;
    --tb-surface-tinted: rgba(255, 255, 255, 0.02);
    --tb-surface-muted: rgba(255, 255, 255, 0.04);
    --tb-surface-hover: rgba(255, 255, 255, 0.08);

    /* Text */
    --tb-text: #e2e8f0;
    --tb-text-strong: #f1f5f9;
    --tb-text-emphasis: #cbd5e0;
    --tb-text-muted: #94a3b8;
    --tb-text-subtle: #94a3b8;
    --tb-text-quiet: #64748b;
    --tb-text-on-brand: #fff;
    --tb-text-on-overlay: #fff;

    /* Borders */
    --tb-border: rgba(255, 255, 255, 0.08);
    --tb-divider: rgba(255, 255, 255, 0.08);
    --tb-border-soft: rgba(255, 255, 255, 0.12);
    --tb-border-strong: #475569;

    /* Icons */
    --tb-icon-muted: #64748b;
    --tb-empty-icon: #475569;
    --tb-empty-title: #cbd5e0;

    /* Avatar placeholders */
    --tb-avatar-placeholder-from: #334155;
    --tb-avatar-placeholder-to: #1e293b;
    --tb-avatar-placeholder-text: #94a3b8;
    --tb-avatar-placeholder-from-alt: #334155;
    --tb-avatar-placeholder-to-alt: #1e293b;
    --tb-avatar-placeholder-text-alt: #94a3b8;

    /* Auth backdrop */
    --tb-auth-bg: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);

    /* Shadows — deeper on dark */
    --tb-shadow-card: 0 2px 8px rgba(0, 0, 0, 0.30);
    --tb-shadow-card-hover: 0 4px 16px rgba(0, 0, 0, 0.40);
    --tb-shadow-nav: 0 2px 4px rgba(0, 0, 0, 0.30);
    --tb-shadow-auth-card: 0 20px 60px rgba(0, 0, 0, 0.60);
}

/* Pull Bootstrap's body color/bg from our tokens so the entire page reacts. */
body {
    background-color: var(--tb-surface);
    color: var(--tb-text);
    transition: background-color var(--tb-transition-normal), color var(--tb-transition-normal);
}

/* --- Alpine.js cloak (hide until hydrated) --- */
[x-cloak] { display: none !important; }

/* --- Layout --- */
.tb-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.tb-main {
    flex: 1;
    padding-top: var(--tb-space-xl);
    padding-bottom: var(--tb-space-2xl);
}

.tb-section {
    margin-bottom: var(--tb-space-xl);
}

.tb-section__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--tb-space-lg);
}

.tb-section__title {
    font-family: var(--tb-font-heading);
    font-weight: 700;
    font-size: 1.25rem;
    margin: 0;
    color: var(--tb-text);
}

/* --- Navigation --- */
.tb-nav {
    background: var(--tb-surface-overlay);
    box-shadow: var(--tb-shadow-nav);
    border-bottom: 1px solid var(--tb-border);
}

.tb-nav__brand {
    font-family: var(--tb-font-heading);
    font-weight: 800;
    font-size: 1.5rem;
    background: var(--tb-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-decoration: none;
}

.tb-nav__badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: var(--tb-radius-full);
    background: var(--tb-primary);
    color: var(--tb-text-on-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* --- Cards --- */
.tb-card {
    background: var(--tb-surface-raised);
    color: var(--tb-text);
    border: none;
    border-radius: var(--tb-radius-md);
    box-shadow: var(--tb-shadow-card);
    transition: box-shadow var(--tb-transition-normal), transform var(--tb-transition-normal);
    overflow: hidden;
}

.tb-card:hover {
    box-shadow: var(--tb-shadow-card-hover);
    transform: translateY(-2px);
}

.tb-card__header {
    padding: var(--tb-space-lg);
    border-bottom: 1px solid var(--tb-border);
}

.tb-card__body {
    padding: var(--tb-space-lg);
}

.tb-card__footer {
    padding: var(--tb-space-md) var(--tb-space-lg);
    border-top: 1px solid var(--tb-border);
    background: var(--tb-surface-tinted);
}

.tb-card__avatar {
    flex-shrink: 0;
}

.tb-card__title {
    font-family: var(--tb-font-heading);
    font-weight: 600;
    font-size: 1rem;
    margin: 0;
    color: var(--tb-text);
}

.tb-card__meta {
    font-size: 0.85rem;
    color: var(--tb-text-muted);
    margin-top: var(--tb-space-xs);
}

.tb-card__actions {
    display: flex;
    gap: var(--tb-space-sm);
    align-items: center;
}

.tb-card--game .tb-card__header {
    background: var(--tb-gradient);
    color: var(--tb-text-on-brand);
}

.tb-card--toon {
    border-left: 3px solid var(--tb-primary);
}

.tb-card--guild {
    border-left: 3px solid var(--tb-secondary);
}

.tb-card--compact {
    box-shadow: none;
    border: 1px solid var(--tb-border-soft);
}

.tb-card--compact:hover {
    transform: none;
    border-color: var(--tb-primary-light);
}

/* --- Avatars --- */
.tb-avatar {
    border-radius: var(--tb-radius-full);
    object-fit: cover;
    background: linear-gradient(135deg, var(--tb-avatar-placeholder-from) 0%, var(--tb-avatar-placeholder-to) 100%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--tb-avatar-placeholder-text);
    font-weight: 600;
    overflow: hidden;
}

.tb-avatar--sm { width: var(--tb-avatar-sm); height: var(--tb-avatar-sm); font-size: 0.75rem; }
.tb-avatar--md { width: var(--tb-avatar-md); height: var(--tb-avatar-md); font-size: 1rem; }
.tb-avatar--lg { width: var(--tb-avatar-lg); height: var(--tb-avatar-lg); font-size: 1.5rem; }
.tb-avatar--xl { width: var(--tb-avatar-xl); height: var(--tb-avatar-xl); font-size: 2rem; }

/* --- Status Badges --- */
.tb-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    padding: 2px 8px;
    border-radius: var(--tb-radius-sm);
}

.tb-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: var(--tb-radius-full);
    background: currentColor;
}

.tb-status--active   { color: var(--tb-status-active);   background: rgba(40, 167, 69, 0.12); }
.tb-status--inactive { color: var(--tb-status-inactive); background: rgba(108, 117, 125, 0.12); }
.tb-status--retired  { color: var(--tb-status-retired);  background: rgba(255, 193, 7, 0.15); }
.tb-status--pending  { color: var(--tb-status-pending);  background: rgba(23, 162, 184, 0.12); }
.tb-status--accepted { color: var(--tb-status-accepted); background: rgba(40, 167, 69, 0.12); }

/* --- Role Badges --- */
.tb-role {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 6px;
    border-radius: var(--tb-radius-sm);
}

.tb-role--leader  { color: var(--tb-role-leader-text);  background: var(--tb-role-leader-bg); }
.tb-role--officer { color: var(--tb-role-officer-text); background: var(--tb-role-officer-bg); }
.tb-role--member  { color: var(--tb-role-member-text);  background: var(--tb-role-member-bg); }

/* --- Forms --- */
.tb-form__group {
    margin-bottom: var(--tb-space-lg);
}

.tb-form__label {
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: var(--tb-space-xs);
    color: var(--tb-text-emphasis);
}

.tb-form__input {
    background: var(--tb-surface-raised);
    color: var(--tb-text);
    border-radius: var(--tb-radius-sm);
    border: 1px solid var(--tb-border-strong);
    padding: 0.625rem 0.875rem;
    transition: border-color var(--tb-transition-fast), box-shadow var(--tb-transition-fast), background-color var(--tb-transition-fast);
}

.tb-form__input:focus {
    border-color: var(--tb-primary);
    box-shadow: 0 0 0 3px var(--tb-focus-ring);
}

.tb-form__error {
    font-size: 0.8rem;
    margin-top: var(--tb-space-xs);
}

.tb-form__actions {
    display: flex;
    gap: var(--tb-space-md);
    align-items: center;
    margin-top: var(--tb-space-xl);
}

/* --- Empty States --- */
.tb-empty {
    text-align: center;
    padding: var(--tb-space-2xl) var(--tb-space-lg);
}

.tb-empty__icon {
    font-size: 3rem;
    color: var(--tb-empty-icon);
    margin-bottom: var(--tb-space-lg);
}

.tb-empty__title {
    font-family: var(--tb-font-heading);
    font-weight: 600;
    font-size: 1.25rem;
    color: var(--tb-empty-title);
    margin-bottom: var(--tb-space-sm);
}

.tb-empty__text {
    color: var(--tb-text-subtle);
    font-size: 0.95rem;
    margin-bottom: var(--tb-space-lg);
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.tb-empty__action {
    display: inline-block;
}

/* --- Notifications --- */
.tb-notification {
    display: flex;
    align-items: flex-start;
    gap: var(--tb-space-md);
    padding: var(--tb-space-md) var(--tb-space-lg);
    border-bottom: 1px solid var(--tb-border);
    transition: background var(--tb-transition-fast);
}

.tb-notification:hover {
    background: var(--tb-surface-muted);
}

.tb-notification--unread {
    background: var(--tb-primary-softer);
    border-left: 3px solid var(--tb-primary);
}

.tb-notification__icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: var(--tb-radius-full);
    background: var(--tb-primary-tint);
    color: var(--tb-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.tb-notification__content {
    flex: 1;
    min-width: 0;
    color: var(--tb-text);
}

.tb-notification__time {
    font-size: 0.75rem;
    color: var(--tb-text-quiet);
    white-space: nowrap;
}

/* --- Messages --- */
.tb-message {
    display: flex;
    align-items: center;
    gap: var(--tb-space-md);
    padding: var(--tb-space-md) var(--tb-space-lg);
    border-bottom: 1px solid var(--tb-border);
    cursor: pointer;
    transition: background var(--tb-transition-fast);
}

.tb-message:hover {
    background: var(--tb-surface-muted);
}

.tb-message--unread {
    background: var(--tb-primary-softer);
}

.tb-message--unread .tb-message__subject {
    font-weight: 700;
}

.tb-message__sender {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--tb-text);
}

.tb-message__subject {
    font-size: 0.9rem;
    color: var(--tb-text-emphasis);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.tb-message__time {
    font-size: 0.75rem;
    color: var(--tb-text-quiet);
    white-space: nowrap;
    margin-left: auto;
}

/* --- Profile --- */
.tb-profile {
    text-align: center;
    padding: var(--tb-space-xl) 0;
}

.tb-profile__avatar {
    margin-bottom: var(--tb-space-lg);
}

.tb-profile__name {
    font-family: var(--tb-font-heading);
    font-weight: 700;
    font-size: 1.75rem;
    color: var(--tb-text);
    margin-bottom: var(--tb-space-xs);
}

.tb-profile__bio {
    color: var(--tb-text-muted);
    font-size: 1rem;
    max-width: 500px;
    margin: 0 auto var(--tb-space-lg);
}

.tb-profile__stats {
    display: flex;
    justify-content: center;
    gap: var(--tb-space-xl);
}

.tb-profile__stat {
    text-align: center;
}

.tb-profile__stat-value {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--tb-primary);
}

.tb-profile__stat-label {
    font-size: 0.8rem;
    color: var(--tb-text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* --- Media --- */
.tb-media {
    position: relative;
    border-radius: var(--tb-radius-md);
    overflow: hidden;
    aspect-ratio: 1;
}

.tb-media__thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--tb-transition-normal);
}

.tb-media:hover .tb-media__thumbnail {
    transform: scale(1.05);
}

.tb-media__overlay {
    position: absolute;
    inset: 0;
    /* Intentionally hard-coded: media overlays sit on top of arbitrary images,
       so contrast must hold regardless of theme. */
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7) 0%, transparent 50%);
    display: flex;
    align-items: flex-end;
    padding: var(--tb-space-md);
    opacity: 0;
    transition: opacity var(--tb-transition-normal);
}

.tb-media:hover .tb-media__overlay {
    opacity: 1;
}

.tb-media__caption {
    color: var(--tb-text-on-overlay);
    font-size: 0.85rem;
    font-weight: 500;
}

/* --- Timestamps --- */
.tb-timestamp {
    font-size: 0.8rem;
    color: var(--tb-text-quiet);
}

/* --- Buttons (augment Bootstrap) --- */
.btn-tb-primary {
    background: var(--tb-gradient);
    border: none;
    color: var(--tb-text-on-brand);
    font-weight: 600;
    transition: opacity var(--tb-transition-fast), transform var(--tb-transition-fast);
}

.btn-tb-primary:hover {
    opacity: 0.9;
    color: var(--tb-text-on-brand);
    transform: translateY(-1px);
}

.btn-tb-primary:active {
    transform: translateY(0);
}

.btn-tb-outline {
    border: 2px solid var(--tb-primary);
    color: var(--tb-primary);
    font-weight: 600;
    background: transparent;
    transition: background var(--tb-transition-fast), color var(--tb-transition-fast);
}

.btn-tb-outline:hover {
    background: var(--tb-primary);
    color: var(--tb-text-on-brand);
}

/* --- Auth Pages --- */
.tb-auth {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--tb-auth-bg);
}

.tb-auth__card {
    width: 100%;
    max-width: 440px;
    border-radius: var(--tb-radius-lg);
    box-shadow: var(--tb-shadow-auth-card);
    background: var(--tb-surface-raised);
    color: var(--tb-text);
    padding: var(--tb-space-2xl);
}

.tb-auth__header {
    text-align: center;
    margin-bottom: var(--tb-space-xl);
}

.tb-auth__title {
    font-family: var(--tb-font-heading);
    font-weight: 800;
    font-size: 1.75rem;
    background: var(--tb-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: var(--tb-space-xs);
}

.tb-auth__subtitle {
    color: var(--tb-text-subtle);
    font-size: 0.95rem;
}

/* --- Loading --- */
.tb-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--tb-space-2xl);
    color: var(--tb-text-muted);
}

/* --- Skip Link (Accessibility) --- */
.tb-skip-link {
    position: absolute;
    top: -100%;
    left: 0;
    background: var(--tb-primary);
    color: var(--tb-text-on-brand);
    padding: var(--tb-space-sm) var(--tb-space-md);
    z-index: 9999;
    font-weight: 600;
    text-decoration: none;
    border-radius: 0 0 var(--tb-radius-sm) 0;
}

.tb-skip-link:focus {
    top: 0;
    color: var(--tb-text-on-brand);
}

/* --- Bootstrap dropdown alignment with our tokens ---
   Bootstrap 5.3 already swaps its own colors when [data-bs-theme="dark"] is
   set on <html> (the theme store mirrors data-theme into that attribute).
   These rules tie the dropdown surface + item text to our semantic tokens
   so navbar/user/notification dropdowns share the same palette as the rest
   of the page rather than relying on Bootstrap's defaults. */
.dropdown-menu {
    background-color: var(--tb-surface-overlay);
    color: var(--tb-text);
    border-color: var(--tb-border-soft);
}

.dropdown-menu .dropdown-header {
    color: var(--tb-text-muted);
}

.dropdown-menu .dropdown-divider {
    border-top-color: var(--tb-divider);
}

.dropdown-menu .dropdown-item {
    color: var(--tb-text-muted);
    transition: background-color var(--tb-transition-fast), color var(--tb-transition-fast);
}

.dropdown-menu .dropdown-item:hover,
.dropdown-menu .dropdown-item:focus {
    color: var(--tb-text);
    background-color: var(--tb-surface-hover);
}

.dropdown-menu .dropdown-item.active,
.dropdown-menu .dropdown-item:active {
    color: var(--tb-text-on-brand);
    background-color: var(--tb-primary);
}

/* Preserve the destructive accent on logout. */
.dropdown-menu .dropdown-item.text-danger,
.dropdown-menu .dropdown-item.text-danger:hover,
.dropdown-menu .dropdown-item.text-danger:focus {
    color: #dc3545 !important;
}

.dropdown-menu .dropdown-item.text-danger:hover,
.dropdown-menu .dropdown-item.text-danger:focus {
    background-color: rgba(220, 53, 69, 0.10);
}

/* Notification rows are dropdown-items in disguise; make sure their
   content reads at full strength while the hover row tint stays subtle. */
.dropdown-menu .dropdown-item.tb-notification,
.dropdown-menu .dropdown-item.tb-notification:hover,
.dropdown-menu .dropdown-item.tb-notification:focus {
    color: var(--tb-text);
}

/* --- Theme Toggle (navbar / settings control) --- */
.tb-theme-toggle {
    display: inline-flex;
    gap: 2px;
    padding: 2px;
    border-radius: var(--tb-radius-sm);
    background: var(--tb-surface-muted);
}

.tb-theme-toggle__btn {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--tb-text-muted);
    font-size: 0.85rem;
    line-height: 1;
    padding: 0.35rem 0.55rem;
    border-radius: calc(var(--tb-radius-sm) - 2px);
    cursor: pointer;
    transition: background var(--tb-transition-fast), color var(--tb-transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.tb-theme-toggle__btn:hover {
    color: var(--tb-text);
}

.tb-theme-toggle__btn--active {
    background: var(--tb-surface-raised);
    color: var(--tb-primary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .tb-theme-toggle__btn--active {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* --- Responsive --- */
@media (max-width: 767.98px) {
    .tb-profile__stats {
        gap: var(--tb-space-lg);
    }

    .tb-auth__card {
        margin: var(--tb-space-md);
        padding: var(--tb-space-lg);
    }

    .tb-section__header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--tb-space-sm);
    }
}

@media (max-width: 575.98px) {
    .tb-card__actions {
        flex-direction: column;
        align-items: stretch;
    }
}

/* --- Quick Search (navbar widget) --- */
.tb-quick-search {
    position: relative;
    flex: 1 1 auto;
    align-self: center;
    max-width: 360px;
    margin: 0 var(--tb-space-md);
}

.tb-quick-search__field {
    position: relative;
}

.tb-quick-search__icon {
    position: absolute;
    top: 50%;
    left: 0.75rem;
    transform: translateY(-50%);
    color: var(--tb-icon-muted);
    pointer-events: none;
    font-size: 0.9rem;
}

.tb-quick-search__input {
    width: 100%;
    padding-left: 2.25rem;
    padding-right: 2.25rem;
    background: var(--tb-surface-soft);
    color: var(--tb-text);
    border-color: transparent;
    transition: background var(--tb-transition-fast), box-shadow var(--tb-transition-fast), border-color var(--tb-transition-fast), color var(--tb-transition-fast);
}

.tb-quick-search__input:focus {
    background: var(--tb-surface-raised);
    border-color: var(--tb-primary);
    box-shadow: 0 0 0 3px var(--tb-focus-ring);
}

.tb-quick-search__clear {
    position: absolute;
    top: 50%;
    right: 0.5rem;
    transform: translateY(-50%);
    background: transparent;
    border: 0;
    padding: 0.25rem 0.4rem;
    color: var(--tb-icon-muted);
    line-height: 1;
    border-radius: var(--tb-radius-sm);
    cursor: pointer;
}

.tb-quick-search__clear:hover {
    color: var(--tb-text-emphasis);
    background: var(--tb-surface-hover);
}

.tb-quick-search__dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    z-index: 1050;
    background: var(--tb-surface-overlay);
    color: var(--tb-text);
    border: 1px solid var(--tb-border-soft);
    border-radius: var(--tb-radius-md);
    box-shadow: var(--tb-shadow-card);
    max-height: 420px;
    overflow-y: auto;
    padding: 0.25rem 0;
}

.tb-quick-search__state {
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    color: var(--tb-text-muted);
}

.tb-quick-search__result {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.85rem;
    text-decoration: none;
    color: var(--tb-text);
    transition: background var(--tb-transition-fast);
}

.tb-quick-search__result:hover,
.tb-quick-search__result--active {
    background: var(--tb-primary-soft);
    color: var(--tb-text);
    text-decoration: none;
}

.tb-quick-search__avatar {
    flex: 0 0 auto;
}

.tb-quick-search__avatar--placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--tb-avatar-placeholder-from-alt) 0%, var(--tb-avatar-placeholder-to-alt) 100%);
    color: var(--tb-avatar-placeholder-text-alt);
}

.tb-quick-search__info {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    min-width: 0;
}

.tb-quick-search__name {
    font-weight: 600;
    color: var(--tb-text-strong);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tb-quick-search__meta {
    font-size: 0.8rem;
    color: var(--tb-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tb-quick-search__footer {
    display: block;
    padding: 0.6rem 0.85rem;
    border-top: 1px solid var(--tb-divider);
    background: var(--tb-surface-sunken);
    text-decoration: none;
    color: var(--tb-primary);
    font-size: 0.875rem;
    font-weight: 500;
}

.tb-quick-search__footer:hover {
    background: var(--tb-primary-soft);
    color: var(--tb-primary);
    text-decoration: none;
}

@media (max-width: 767.98px) {
    .tb-quick-search {
        max-width: none;
        margin: 0.5rem 0;
        width: 100%;
    }
}
