/* ============================================================================
   DESIGN SYSTEM TOKENS — See DESIGN_SYSTEM.md for documentation
   ============================================================================ */

:root {
    /* Typography scale */
    --ts-text-display: 2rem;
    --ts-text-hero: 1.4rem;
    --ts-text-heading: 1.2rem;
    --ts-text-title: 1rem;
    --ts-text-body: 0.9rem;
    --ts-text-label: 0.82rem;
    --ts-text-caption: 0.75rem;
    --ts-text-tiny: 0.65rem;

    /* Text colors */
    --ts-text-primary: #ffffff;
    --ts-text-secondary: rgba(255, 255, 255, 0.75);
    --ts-text-muted: rgba(255, 255, 255, 0.5);
    --ts-text-faint: rgba(255, 255, 255, 0.35);
    --ts-text-accent: #667eea;
    --ts-text-error: #ff6b6b;
    --ts-text-success: #51cf66;

    /* Background colors */
    --ts-bg-page: #000000;
    --ts-bg-card: rgba(18, 18, 32, 0.85);
    --ts-bg-card-hover: rgba(24, 24, 42, 0.90);
    --ts-bg-elevated: rgba(18, 18, 32, 0.95);
    --ts-bg-input: rgba(255, 255, 255, 0.05);
    --ts-bg-input-focus: rgba(102, 126, 234, 0.08);
    --ts-bg-overlay: rgba(0, 0, 0, 0.6);
    --ts-bg-subtle: rgba(255, 255, 255, 0.03);

    /* Border colors */
    --ts-border-default: rgba(255, 255, 255, 0.08);
    --ts-border-hover: rgba(255, 255, 255, 0.15);
    --ts-border-focus: rgba(102, 126, 234, 0.5);
    --ts-border-accent: rgba(102, 126, 234, 0.25);

    /* Accent / brand */
    --ts-accent-primary: #667eea;
    --ts-accent-secondary: #764ba2;
    --ts-gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --ts-accent-error: #ff6b6b;
    --ts-accent-success: #51cf66;

    /* Extended theme tokens (defaults — overridden per-theme in themes.css) */
    --ts-bg-header: rgba(6, 6, 18, 0.88);
    --ts-bg-deep: #060612;
    --ts-accent-glow: rgba(102, 126, 234, 0.3);
    --ts-accent-subtle: rgba(102, 126, 234, 0.15);
    --ts-accent-faint: rgba(102, 126, 234, 0.08);
    --ts-shadow-color: rgba(0, 0, 0, 0.3);
    --ts-divider: rgba(255, 255, 255, 0.06);
    --ts-highlight: rgba(255, 255, 255, 0.1);
    --ts-scrollbar-thumb: rgba(255, 255, 255, 0.15);
    --ts-scrollbar-track: transparent;
    --ts-particle-color: 255, 255, 255;

    /* Celestial / Star Wishes tokens */
    --ts-accent-star: #ffd475;
    --ts-accent-star-glow: rgba(255, 212, 117, 0.4);
    --ts-accent-star-subtle: rgba(255, 212, 117, 0.15);
    --ts-accent-star-faint: rgba(255, 212, 117, 0.08);

    /* Spacing */
    --ts-space-xs: 4px;
    --ts-space-sm: 8px;
    --ts-space-md: 16px;
    --ts-space-lg: 24px;
    --ts-space-xl: 32px;

    /* Radii */
    --ts-radius-sm: 8px;
    --ts-radius-md: 12px;
    --ts-radius-lg: 14px;
    --ts-radius-xl: 16px;
    --ts-radius-round: 50%;

    /* Component-level variables (Semantic) */
    --ts-card-shadow: 0 4px 16px var(--ts-shadow-color);
    --ts-card-shadow-hover: 0 8px 32px var(--ts-shadow-color);
    --ts-text-glow: 0 0 20px rgba(255, 255, 255, 0.4);
    --ts-glass-bg: rgba(18, 18, 32, 0.65);
    --ts-glass-border: rgba(255, 255, 255, 0.08);

    /* Button shadows */
    --ts-shadow-primary: 0 10px 24px rgba(102, 126, 234, 0.24);
    --ts-shadow-primary-hover: 0 12px 30px rgba(102, 126, 234, 0.34);
    --ts-shadow-danger: 0 10px 24px rgba(255, 65, 108, 0.22);
    --ts-shadow-danger-hover: 0 12px 30px rgba(255, 65, 108, 0.30);
}

/* ============================================================================
   GLOBAL UTILITIES & SHARED COMPONENTS
   ============================================================================ */

/* --- Modern Buttons (.ts-btn) --- */
.ts-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--ts-radius-md);
    font-size: var(--ts-text-body);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
    font-family: inherit;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    min-height: 48px;
    text-decoration: none !important;
}

.ts-btn:hover {
    transform: translateY(-2px);
}

.ts-btn:active {
    transform: translateY(0) scale(0.98);
}

.ts-btn-primary {
    background: var(--ts-gradient-primary);
    color: var(--ts-text-primary);
    box-shadow: var(--ts-shadow-primary);
}

.ts-btn-primary:hover {
    box-shadow: var(--ts-shadow-primary-hover);
    filter: brightness(1.1);
}

.ts-btn-secondary {
    background: var(--ts-bg-input);
    color: var(--ts-text-primary);
    border-color: var(--ts-border-default);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.ts-btn-secondary:hover {
    background: var(--ts-bg-card-hover);
    border-color: var(--ts-border-hover);
}

.ts-btn-outline {
    background: transparent;
    color: var(--ts-text-primary);
    border: 2px solid var(--ts-border-focus);
}

.ts-btn-outline:hover {
    background: var(--ts-accent-faint);
    border-color: var(--ts-accent-primary);
    box-shadow: 0 4px 15px var(--ts-accent-glow);
}

.ts-btn-danger {
    background: linear-gradient(135deg, #ff416c 0%, #ff4b2b 100%);
    color: var(--ts-text-primary);
    box-shadow: var(--ts-shadow-danger);
}

.ts-btn-danger:hover {
    box-shadow: var(--ts-shadow-danger-hover);
    filter: brightness(1.1);
}

.ts-btn-sm {
    padding: 8px 16px;
    min-height: 38px;
    font-size: var(--ts-text-label);
    border-radius: var(--ts-radius-sm);
}

.ts-btn-lg {
    padding: 16px 32px;
    min-height: 56px;
    font-size: var(--ts-text-title);
    border-radius: var(--ts-radius-lg);
}

/* --- Modern Cards (.ts-card) --- */
.ts-card {
    background: var(--ts-bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--ts-border-default);
    border-radius: var(--ts-radius-lg);
    padding: 24px;
    transition: all 0.3s ease;
    box-shadow: var(--ts-card-shadow);
}

.ts-card-hover:hover {
    background: var(--ts-bg-card-hover);
    border-color: var(--ts-border-hover);
    transform: translateY(-4px);
    box-shadow: var(--ts-card-shadow-hover);
}

/* --- Input Normalization --- */
.ts-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--ts-bg-input);
    border: 1px solid var(--ts-border-default);
    border-radius: var(--ts-radius-md);
    color: var(--ts-text-primary);
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.2s ease;
    outline: none;
}

.ts-input:focus {
    border-color: var(--ts-border-focus);
    background: var(--ts-bg-input-focus);
    box-shadow: 0 0 0 4px var(--ts-accent-faint);
}

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

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* Remove blue tap highlight on all elements for native feel */
    -webkit-tap-highlight-color: transparent;
}

/* ============================================================================
   NATIVE APP FEEL — Global styles that make the webapp indistinguishable
   from a native iOS/Android app
   ============================================================================ */

html {
    /* Prevent rubber-band overscroll (web-only giveaway) */
    overscroll-behavior: none;
    /* Smooth font rendering like native apps */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    /* Prevent text selection on non-content elements (native apps don't allow this) */
    -webkit-user-select: none;
    user-select: none;
}

body {
    /* Prevent rubber-band overscroll on body too */
    overscroll-behavior: none;
    /* Prevent callout on long-press (iOS Safari shows "Copy/Define/Share") */
    -webkit-touch-callout: none;
}

/* Allow text selection ONLY in content areas where users need to copy text */
p,
.thought-content,
.message-text,
.dm-message-text,
.comment-text,
.bio-text,
.entry-notes,
.ai-message-content,
.thought-body,
[contenteditable="true"],
.selectable-text {
    -webkit-user-select: text;
    user-select: text;
    -webkit-touch-callout: default;
}

/* Allow selection in inputs/textareas (obviously needed for editing) */
input,
textarea,
select,
[contenteditable="true"] {
    -webkit-user-select: text;
    user-select: text;
    -webkit-touch-callout: default;
}

/* Hide scrollbars on touch/mobile devices for native look (content still scrollable).
   Desktop keeps scrollbars for usability. */
@media (hover: none) and (pointer: coarse) {
    * {
        scrollbar-width: none;
        /* Firefox */
        -ms-overflow-style: none;
        /* IE/Edge */
    }

    *::-webkit-scrollbar {
        display: none;
        /* Chrome/Safari/Opera */
    }
}

/* Page transition: very subtle fade-in on navigation.
   Kept ultra-short (80ms) so it smooths the paint without adding perceived delay. */
body {
    animation: nativeFadeIn 0.08s ease-out backwards;
}

@keyframes nativeFadeIn {
    from {
        opacity: 0.6;
        /* Start mostly visible — just enough to hide the raw paint flash */
    }

    to {
        opacity: 1;
    }
}

/* Smooth momentum scrolling for all scrollable containers */
.scroll-container,
.feed-container,
.messages-list,
.chat-messages,
.entries-container,
.thoughts-list,
.notifications-list {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Active state for tappable elements (native-style press feedback) */
@media (hover: none) and (pointer: coarse) {

    button:active,
    a:active,
    .clickable:active,
    .nav-item:active,
    .face-icon:active,
    .card:active,
    .thought-card:active,
    .entry-card:active,
    .notification-item:active {
        opacity: 0.7;
        transition: opacity 0.1s ease;
    }
}

/* ============================================================================
   MOBILE ZOOM PREVENTION
   Prevents iOS Safari from auto-zooming when focusing on inputs
   ============================================================================ */

/* Prevent text size adjustment on orientation change */
html {
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* Base input styles - ensure minimum 16px for iOS */
@supports (-webkit-touch-callout: none) {

    /* iOS specific: ensure all inputs are at least 16px */
    input,
    textarea,
    select {
        font-size: max(16px, 1rem);
    }
}

/* ============================================================================
   ADA ACCESSIBILITY STYLES
   ============================================================================ */

/* Skip to main content link - hidden until focused */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--ts-bg-page);
    color: var(--ts-text-primary);
    padding: 8px 16px;
    text-decoration: none;
    z-index: 1000000;
    border-radius: 4px;
}

.skip-link:focus {
    top: 0;
    outline: 3px solid var(--ts-accent-primary);
    outline-offset: 2px;
}

/* Focus indicators - ensure all interactive elements have visible focus */
*:focus {
    outline: 2px solid var(--ts-accent-primary);
    outline-offset: 2px;
}

/* Enhanced focus for buttons */
button:focus,
a:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--ts-accent-primary);
    outline-offset: 2px;
}

/* Remove outline for mouse users but keep for keyboard users */
.js-focus-visible :focus:not(.focus-visible) {
    outline: none;
}

/* High contrast focus indicator for better visibility */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid var(--ts-accent-primary);
    outline-offset: 3px;
    box-shadow: 0 0 0 3px var(--ts-accent-glow);
}

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Screen reader only content that should be visible on focus */
.sr-only-focusable:focus {
    position: static;
    width: auto;
    height: auto;
    padding: inherit;
    margin: inherit;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* Live region for announcements */
.live-region {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Ensure sufficient color contrast for text */
/* All text should meet WCAG AA standards (4.5:1 for normal text, 3:1 for large text) */
/* White on dark background typically meets this, but we'll enhance where needed */

/* Better focus indicators for custom elements */
.face-icon:focus-visible {
    outline: 3px solid var(--ts-text-primary);
    outline-offset: 4px;
    box-shadow: 0 0 0 3px var(--ts-border-focus);
}

/* Focus indicators for feed tabs */
.feed-tab:focus-visible {
    outline: 3px solid var(--ts-accent-primary);
    outline-offset: 3px;
}

/* Focus indicators for auth buttons */
.auth-button:focus-visible,
.oauth-button:focus-visible {
    outline: 3px solid var(--ts-accent-primary);
    outline-offset: 3px;
    box-shadow: 0 0 0 3px var(--ts-accent-glow);
}

/* Ensure buttons and links have minimum touch target size (44x44px) */
button,
a,
input[type="button"],
input[type="submit"],
input[type="reset"] {
    min-height: 44px;
    min-width: 44px;
}

/* Reduce motion for users who prefer it */
@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;
    }
}

/* Performance tier: suppress heavy CSS animations on weak devices */
/* data-perf-tier is set by device-performance.js */
:root[data-perf-tier="minimal"] *,
:root[data-perf-tier="minimal"] *::before,
:root[data-perf-tier="minimal"] *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
}

:root[data-perf-tier="minimal"] #backgroundCanvas,
:root[data-perf-tier="minimal"] #worldCanvas,
:root[data-perf-tier="minimal"] #portalCanvas {
    display: none !important;
}

:root[data-perf-tier="low"] *,
:root[data-perf-tier="low"] *::before,
:root[data-perf-tier="low"] *::after {
    animation-iteration-count: 1 !important;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    * {
        border-color: currentColor !important;
    }

    button,
    a,
    input,
    select,
    textarea {
        border-width: 2px !important;
    }
}

/* Dark mode support (already supported but ensuring consistency) */
@media (prefers-color-scheme: dark) {
    /* Styles already optimized for dark mode */
}

/* Ensure form errors are accessible (only when shown) */
.error-message[role="alert"].show {
    display: block;
}

/* ARIA live regions for dynamic content */
[aria-live] {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Override ARIA live hiding for visible error messages (only when shown) */
.error-message[aria-live].show,
.error-message[role="alert"][aria-live].show {
    position: static !important;
    left: auto !important;
    width: auto !important;
    height: auto !important;
    overflow: visible !important;
}

[aria-live="polite"] {
    /* Polite announcements don't interrupt */
}

[aria-live="assertive"] {
    /* Assertive announcements interrupt immediately */
}

/* Ensure modal dialogs trap focus */
[role="dialog"] {
    /* Focus trap is handled in JavaScript */
}

[role="dialog"]:focus {
    outline: none;
}

/* Better visibility for disabled states */
button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

/* Ensure all images have alt text (visual indicator) */
img:not([alt]) {
    border: 2px dashed var(--ts-accent-error);
}

/* Loading states should be announced to screen readers */
.loading[aria-busy="true"],
[aria-busy="true"] {
    /* Loading indicator */
}

/* Ensure headings are in proper hierarchy */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 700;
}

/* Better link visibility */
a {
    text-decoration: underline;
    text-underline-offset: 2px;
}

a:focus {
    text-decoration: none;
}

/* Ensure form labels are properly associated */
label {
    display: block;
    margin-bottom: 0.5rem;
}

/* Required field indicators */
[required]::after {
    content: " *";
    color: var(--ts-accent-error);
}

/* Focus trap for modals */
.modal-focus-trap {
    /* Handled in JavaScript */
}

/* Ensure all interactive elements are keyboard accessible */
[tabindex="-1"]:focus {
    outline: none;
}

/* Better contrast for placeholder text */
::placeholder {
    color: var(--ts-text-muted);
    opacity: 1;
}

/* Ensure icons used as buttons have proper labels */
.icon-button {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Ensure navigation landmarks are properly styled */
nav[aria-label],
nav[aria-labelledby] {
    /* Navigation styling */
}

/* Main content landmark */
main {
    /* Main content styling */
}

/* Ensure error states are clearly visible */
.error-state {
    border-color: var(--ts-accent-error) !important;
    background-color: rgba(255, 107, 107, 0.1) !important;
}

/* Success states */
.success-state {
    border-color: #4caf50 !important;
    background-color: rgba(76, 175, 80, 0.1) !important;
}

/* Warning states */
.warning-state {
    border-color: #ffc107 !important;
    background-color: rgba(255, 193, 7, 0.1) !important;
}

/* Make text cursor (caret) smaller for better visibility */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="color"],
textarea,
.form-input {
    caret-color: var(--ts-text-primary);
    caret-width: 1px;
    /* Smaller cursor width - note: limited browser support */
    line-height: 1.4;
    /* Tighter line height makes cursor appear smaller */
}

/* Additional optimization for cursor appearance */
input:focus,
textarea:focus,
.form-input:focus {
    caret-color: var(--ts-accent-primary);
    /* Use theme color for focused cursor */
    outline: 2px solid var(--ts-accent-primary);
    /* Keep outline for accessibility */
    outline-offset: 2px;
}

/* For textarea and large inputs, reduce font size slightly to make cursor smaller */
textarea,
input[type="text"],
input[type="email"],
.form-input {
    font-size: 0.95em;
    /* Slightly smaller font = smaller cursor */
}

/* Base cursor styling - use default cursor */

/* Buttons MUST be clickable */
button.face-icon {
    cursor: pointer !important;
    pointer-events: auto !important;
    z-index: 999999 !important;
    position: relative !important;
}

/* Child elements should not block clicks on button */
button.face-icon * {
    pointer-events: none !important;
}

/* Icons row must allow pointer events */
.icons-row {
    pointer-events: auto !important;
    z-index: 999999 !important;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--ts-bg-page);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: var(--ts-text-primary);
    overflow-x: hidden;
    position: relative;
}

/* -----------------------------------------------------------------------------
   AppDialog (in-app modal + toast)
----------------------------------------------------------------------------- */
/* iOS-proof scroll lock. overflow:hidden alone doesn't work on iOS Safari
   because the scroll target is <html>, not <body>. We need:
   1. position: fixed — takes body out of scroll flow entirely
   2. inset: 0 + width:100% — keeps it filling the viewport
   3. JS saves/restores scrollY via --scroll-lock-y so position doesn't jump */
.ts-scroll-locked {
    position: fixed !important;
    top: var(--scroll-lock-y, 0) !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    overflow: hidden !important;
}

/* Note: the old .ts-dialog-open class was replaced by .ts-scroll-locked.
   AppDialog now uses TSScrollLock.lock()/unlock() instead. */

#ts-dialog-root {
    position: relative;
    z-index: 1000000;
    /* above cursor overlay */
}

.ts-dialog-backdrop {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(0, 0, 0, 0.6);
    animation: tsFadeIn 140ms ease-out;
    /* Allow cursor to track through backdrop, but still capture clicks */
    pointer-events: auto;
    overscroll-behavior: contain;
}

.ts-dialog {
    width: min(520px, 92vw);
    border-radius: 16px;
    border: 1px solid var(--ts-border-hover);
    background: radial-gradient(1200px 600px at 10% 10%, rgba(102, 126, 234, 0.20), rgba(0, 0, 0, 0) 60%),
        radial-gradient(900px 500px at 90% 0%, rgba(240, 147, 251, 0.14), rgba(0, 0, 0, 0) 55%),
        rgba(10, 12, 20, 0.92);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    transform: translateY(8px) scale(0.98);
    animation: tsPopIn 160ms ease-out forwards;
}

.ts-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
}

.ts-dialog-title {
    font-weight: 800;
    letter-spacing: 0.2px;
    color: var(--ts-text-primary);
    font-size: 1.05rem;
}

.ts-dialog-x {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    border: 1px solid var(--ts-highlight);
    background: var(--ts-divider);
    color: var(--ts-text-secondary);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease;
}

.ts-dialog-x:hover {
    transform: translateY(-1px);
    background: var(--ts-highlight);
}

.ts-dialog-body {
    padding: 16px 18px 10px;
}

.ts-dialog-message {
    color: var(--ts-text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 12px;
    white-space: pre-wrap;
}

.ts-dialog-input {
    width: 100%;
    padding: 12px 12px;
    border-radius: 12px;
    border: 1px solid var(--ts-highlight);
    background: var(--ts-bg-input);
    color: var(--ts-text-primary);
    outline: none;
    font-size: 0.95rem;
}

.ts-dialog-input:focus {
    border-color: var(--ts-border-focus);
    box-shadow: 0 0 0 3px var(--ts-accent-subtle);
}

.ts-dialog-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 14px 18px 18px;
}

.ts-dialog-btn {
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid var(--ts-highlight);
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.ts-dialog-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--ts-accent-subtle);
}

.ts-dialog-btn-secondary {
    background: var(--ts-bg-input);
    color: var(--ts-text-secondary);
}

.ts-dialog-btn-secondary:hover {
    background: var(--ts-highlight);
    transform: translateY(-1px);
}

.ts-dialog-btn-primary {
    border: none;
    color: var(--ts-text-primary);
    background: var(--ts-gradient-primary);
    box-shadow: var(--ts-shadow-primary);
}

.ts-dialog-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--ts-shadow-primary-hover);
}

.ts-dialog-btn-danger {
    border: none;
    color: var(--ts-text-primary);
    background: linear-gradient(135deg, #ff416c 0%, #ff4b2b 100%);
    box-shadow: var(--ts-shadow-danger);
}

.ts-dialog-btn-danger:hover {
    transform: translateY(-1px);
    box-shadow: var(--ts-shadow-danger-hover);
}

.ts-toast-container {
    position: fixed;
    top: calc(env(safe-area-inset-top, 18px) + 18px);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    z-index: 1000001;
    pointer-events: none;
    width: auto;
    max-width: 92vw;
}

.ts-toast {
    pointer-events: none;
    padding: 14px 20px;
    border-radius: 14px;
    border: 1px solid var(--ts-highlight);
    background: rgba(15, 18, 30, 0.95);
    color: var(--ts-text-primary);
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.50);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: tsSlideIn 160ms ease-out;
    max-width: min(360px, 92vw);
}

.ts-toast-success {
    border-color: rgba(76, 175, 80, 0.35);
}

.ts-toast-info {
    border-color: rgba(102, 126, 234, 0.35);
}

.ts-toast-warning {
    border-color: rgba(255, 152, 0, 0.4);
}

.ts-toast-error {
    border-color: rgba(244, 67, 54, 0.4);
}

.ts-toast-hide {
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 220ms ease, transform 220ms ease;
}

@keyframes tsFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes tsPopIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.97);
    }

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

@keyframes tsSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

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

body.world-active {
    overflow: hidden;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

.world-container {
    scroll-behavior: smooth;
}


/* Background Canvas - Galaxy/Universe Effect */
.background-canvas {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 0 !important;
    pointer-events: none !important;
    opacity: 1;
    /* Removed !important to allow JavaScript control */
    display: block !important;
    background: var(--ts-bg-page) !important;
    transition: opacity 0.3s ease;
}

/* Transparent background for world modules (public profile) - particles overlay on colored backgrounds */
.world-container.active~.background-canvas {
    background: transparent !important;
}

/* When world container is active, make canvas transparent so colored backgrounds show through */
body:has(.world-container.active) .background-canvas {
    background: transparent !important;
}

/* Ensure proper z-index layering: 
   - background-canvas (z-index 0) - particles at base
   - world-background (z-index 1) - colored overlay
   - world-canvas (z-index 1) - world particle canvas
   - world-content (z-index 100) - actual content on top
*/
.world-content {
    z-index: 100 !important;
    position: relative;
}

/* Hide navigation and buttons when world module is active */
.world-container.active~nav.nav-bar,
body:has(.world-container.active) nav.nav-bar {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

.world-container.active~.container header .icons-row,
body:has(.world-container.active) .container header .icons-row {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

.container {
    max-width: 1200px;
    width: 100%;
    position: relative;
    z-index: 1;
    /* Above the background canvas */
}

header {
    text-align: center;
    margin-bottom: 0;
    color: var(--ts-text-primary);
    text-shadow: 0 0 20px var(--ts-accent-glow);
    /* Fill viewport so name/bio/filter sit near the bottom */
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 70px);
    /* 70px = bottom nav height */
    min-height: calc(100dvh - 70px);
    /* dynamic viewport for mobile */
    /* Clear the fixed back button - needs to clear ~50px button height plus gap */
    padding-top: 70px;
}

.headshot-container {
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    position: relative;
    gap: 20px;
    pointer-events: none !important;
    z-index: 100;
    /* Take up all remaining vertical space so the headshot
       has maximum room to float around freely */
    flex: 1 1 auto;
    min-height: 250px;
    overflow: visible;
    /* Allow headshots to float outside */
}

.headshot-container>* {
    pointer-events: auto !important;
}

/* Icons row above headshot */
.icons-row {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    position: relative;
    animation: iconsFadeIn 1s ease-out 0.3s both;
}

@keyframes iconsFadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

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

.headshot-wrapper {
    position: relative;
    width: 200px;
    height: 200px;
    perspective: 1000px;
    /* Floating is now handled by JavaScript */
    will-change: transform;
    z-index: 50;
    /* Ensure headshots are above background but below buttons */
}

/* Headshot stays in normal flow */
#headshotWrapper {
    position: relative;
    margin: 0 auto;
}

.headshot-3d {
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.1s ease-out;
}

.headshot {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    object-fit: cover;
    border: 6px solid var(--ts-text-primary);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.1) 100%);
    display: block;
    transform-style: preserve-3d;
    will-change: transform;
}

.headshot-glow {
    position: absolute;
    top: -10px;
    left: -10px;
    width: calc(100% + 20px);
    height: calc(100% + 20px);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.4) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: -1;
    animation: pulseGlow 3s ease-in-out infinite;
}

@keyframes pulseGlow {

    0%,
    100% {
        opacity: 0;
        transform: scale(1);
    }

    50% {
        opacity: 0.6;
        transform: scale(1.1);
    }
}

.headshot-wrapper:hover .headshot-glow {
    opacity: 0.8;
}

.headshot-placeholder {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    border: 6px solid var(--ts-text-primary);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0.1) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: absolute;
    top: 0;
    left: 0;
}

.headshot-wrapper:hover .headshot-placeholder {
    transform: scale(1.05);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
}

.placeholder-icon {
    font-size: 80px;
    opacity: 0.7;
}

/* Loading spinner for profile picture */
.headshot-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: var(--ts-bg-input);
    border: 6px solid var(--ts-highlight);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

/* Show loading spinner only when explicitly displayed */
.headshot-loading[style*="display: flex"],
.headshot-loading[style*="display:block"] {
    display: flex !important;
}

/* Ensure loading spinner is hidden when placeholder is shown */
.headshot-placeholder[style*="display: flex"]~.headshot-loading,
.headshot-placeholder[style*="display:block"]~.headshot-loading {
    display: none !important;
    visibility: hidden !important;
}

/* ── Standard Loading Indicator ──
   Used across all pages for consistent loading states.
   Structure: <div class="loading" aria-busy="true">
                <div class="loading-spinner"></div>
                <div class="loading-text">Loading...</div>
              </div>
*/
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 20px;
}

.loading-spinner {
    width: 44px;
    height: 44px;
    border: 4px solid var(--ts-border-default);
    border-top-color: var(--ts-accent-primary);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

.loading-text {
    color: var(--ts-text-secondary);
    font-size: 1rem;
    font-weight: 500;
}

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

/* Loading skeleton for username and bio */
.loading-skeleton {
    display: inline-block;
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0.1) 0%,
            rgba(255, 255, 255, 0.2) 50%,
            rgba(255, 255, 255, 0.1) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
    height: 1.2em;
    min-width: 150px;
}

.username-loading .loading-skeleton {
    width: 200px;
    height: 2rem;
}

.bio-loading .loading-skeleton {
    width: 300px;
    height: 1.2rem;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

.username-text,
.bio-text {
    display: none;
}

/* Show text when loading is hidden */
#publicUsername:has(.username-loading[style*="display: none"]) .username-text,
#publicBio:has(.bio-loading[style*="display: none"]) .bio-text {
    display: inline;
}

/* Fallback for browsers without :has() support */
.username-text.show,
.bio-text.show {
    display: inline !important;
}

/* Interactive icons above headshot - Easy to click */
.face-icon {
    position: relative;
    cursor: pointer !important;
    z-index: 10000 !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    background: var(--ts-highlight);
    backdrop-filter: blur(12px);
    border-radius: 14px;
    padding: 16px 20px;
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.2),
        inset 0 1px 0 var(--ts-highlight);
    border: 2px solid rgba(255, 255, 255, 0.3);
    min-width: 90px;
    overflow: visible;
    transform-style: preserve-3d;
    pointer-events: auto !important;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    touch-action: manipulation;
    /* Button reset */
    margin: 0;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    text-decoration: none;
}

.face-icon svg {
    width: 32px;
    height: 32px;
    margin-bottom: 6px;
    pointer-events: none;
    position: relative;
    z-index: 1;
    transition: all 0.3s ease;
    filter: drop-shadow(0 0 5px currentColor);
}

.icon-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ts-text-primary);
    text-align: center;
    margin-top: 4px;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    pointer-events: none;
    position: relative;
    z-index: 1;
    transition: all 0.3s ease;
    letter-spacing: 0.5px;
}

.icon-pulse {
    pointer-events: none !important;
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 14px;
    border: 2px solid currentColor;
    opacity: 0;
    animation: iconPulse 2s ease-in-out infinite;
    z-index: 0;
}

@keyframes iconPulse {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }

    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* SVG sizing handled above */

.face-icon:hover {
    transform: scale(1.2) translateY(-8px) rotateX(5deg) !important;
    box-shadow: 0 12px 40px rgba(255, 255, 255, 0.5),
        0 0 50px rgba(255, 255, 255, 0.3),
        inset 0 2px 10px rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.25);
}

.face-icon:hover svg {
    animation: iconFloat 2s ease-in-out infinite;
    filter: drop-shadow(0 0 10px currentColor);
}

@keyframes iconFloat {

    0%,
    100% {
        transform: translateY(0) scale(1);
    }

    50% {
        transform: translateY(-3px) scale(1.1);
    }
}

.face-icon:active {
    transform: scale(1.1) translateY(-4px) rotateX(2deg) !important;
    transition: transform 0.1s ease;
}

/* Ripple effect on click */
.face-icon::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s, opacity 0.6s;
    pointer-events: none;
    z-index: 0;
}

.face-icon:active::before {
    width: 300px;
    height: 300px;
    opacity: 0;
}

/* Animated gradient background */
.face-icon::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg,
            transparent 30%,
            rgba(255, 255, 255, 0.1) 50%,
            transparent 70%);
    transform: rotate(45deg);
    animation: shimmerGlow 3s linear infinite;
    pointer-events: none;
    z-index: 1;
}

@keyframes shimmerGlow {
    0% {
        transform: translateX(-100%) translateY(-100%) rotate(45deg);
    }

    100% {
        transform: translateX(100%) translateY(100%) rotate(45deg);
    }
}

/* Focus states for accessibility */
.face-icon:focus {
    outline: 2px solid var(--ts-text-secondary);
    outline-offset: 4px;
}

.world-close-btn:focus {
    outline: 2px solid var(--ts-text-secondary);
    outline-offset: 4px;
}

/* Eye icon styling - Watching theme (warm red/crimson for cinema/movies) */
.eye-icon-face {
    color: #e74c3c;
    border-color: rgba(231, 76, 60, 0.5);
}

.eye-icon-face:hover {
    background: rgba(231, 76, 60, 0.25);
    border-color: #e74c3c;
    box-shadow: 0 12px 40px rgba(231, 76, 60, 0.6),
        0 0 50px rgba(231, 76, 60, 0.4),
        inset 0 2px 10px rgba(231, 76, 60, 0.2);
    transform: translateY(-8px) scale(1.2) rotateX(5deg) !important;
}

.eye-icon-face:hover .icon-label {
    color: #e74c3c;
    text-shadow: 0 0 20px rgba(231, 76, 60, 1),
        0 0 30px rgba(231, 76, 60, 0.6);
    transform: scale(1.1);
}

.eye-icon-face:hover svg {
    animation: iconPulseHover 1.5s ease-in-out infinite;
    filter: drop-shadow(0 0 15px #e74c3c);
}

@keyframes iconPulseHover {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.15);
        opacity: 0.9;
    }
}

/* Ear icon styling - Listening theme (bright cyan-blue to match ocean blue gradient) */
.ear-icon-face {
    color: #52c9f2;
    border-color: rgba(82, 201, 242, 0.5);
}

.ear-icon-face:hover {
    background: rgba(82, 201, 242, 0.25);
    border-color: #52c9f2;
    box-shadow: 0 12px 40px rgba(82, 201, 242, 0.6),
        0 0 50px rgba(82, 201, 242, 0.4),
        inset 0 2px 10px rgba(82, 201, 242, 0.2);
    transform: translateY(-8px) scale(1.2) rotateX(5deg) !important;
}

.ear-icon-face:hover .icon-label {
    color: #52c9f2;
    text-shadow: 0 0 20px rgba(82, 201, 242, 1),
        0 0 30px rgba(82, 201, 242, 0.6);
    transform: scale(1.1);
}

.ear-icon-face:hover svg {
    animation: iconRotate 2s ease-in-out infinite;
    filter: drop-shadow(0 0 15px #52c9f2);
}

@keyframes iconRotate {

    0%,
    100% {
        transform: rotate(0deg) scale(1);
    }

    25% {
        transform: rotate(-5deg) scale(1.1);
    }

    75% {
        transform: rotate(5deg) scale(1.1);
    }
}

/* Head icon styling - Reading theme (vibrant purple to match purple-green gradient) */
.head-icon-face {
    color: #a569bd;
    border-color: rgba(165, 105, 189, 0.5);
}

.head-icon-face:hover {
    background: rgba(165, 105, 189, 0.25);
    border-color: #a569bd;
    box-shadow: 0 12px 40px rgba(165, 105, 189, 0.6),
        0 0 50px rgba(165, 105, 189, 0.4),
        inset 0 2px 10px rgba(165, 105, 189, 0.2);
    transform: translateY(-8px) scale(1.2) rotateX(5deg) !important;
}

.head-icon-face:hover .icon-label {
    color: #a569bd;
    text-shadow: 0 0 20px rgba(165, 105, 189, 1),
        0 0 30px rgba(165, 105, 189, 0.6);
    transform: scale(1.1);
}

.head-icon-face:hover svg {
    animation: iconBounce 1.8s ease-in-out infinite;
    filter: drop-shadow(0 0 15px #a569bd);
}

.brain-icon-face {
    color: #6c5ce7;
    border-color: rgba(108, 92, 231, 0.5);
}

.brain-icon-face:hover {
    background: rgba(108, 92, 231, 0.25);
    border-color: #6c5ce7;
    box-shadow: 0 12px 40px rgba(108, 92, 231, 0.6),
        0 0 50px rgba(108, 92, 231, 0.4),
        inset 0 2px 10px rgba(108, 92, 231, 0.2);
    transform: translateY(-8px) scale(1.2) rotateX(5deg) !important;
}

.brain-icon-face:hover .icon-label {
    color: #6c5ce7;
    text-shadow: 0 0 20px rgba(108, 92, 231, 1),
        0 0 30px rgba(108, 92, 231, 0.6);
    transform: scale(1.1);
}

.brain-icon-face:hover svg {
    animation: iconBounce 1.8s ease-in-out infinite;
    filter: drop-shadow(0 0 15px #6c5ce7);
}

@keyframes iconBounce {

    0%,
    100% {
        transform: translateY(0) scale(1);
    }

    25% {
        transform: translateY(-4px) scale(1.1);
    }

    50% {
        transform: translateY(0) scale(1.05);
    }

    75% {
        transform: translateY(-2px) scale(1.08);
    }
}

header h1 {
    font-size: 3rem;
    margin-bottom: 10px;
    margin-top: auto;
    /* pushes name + everything below it to the bottom */
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    font-weight: 700;
    animation: titleFadeIn 1s ease-out 0.2s both;
    letter-spacing: -0.02em;
}

@keyframes titleFadeIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.9);
    }

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

.subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
    font-weight: 300;
    color: var(--ts-text-secondary);
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
    animation: subtitleFadeIn 1.5s ease-out 0.5s both;
    margin-bottom: 4px;
}

@keyframes subtitleFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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


/* Portal overlay for transition effect */
.portal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.5s ease;
    background: radial-gradient(circle at center, transparent 0%, rgba(0, 0, 0, 0.8) 100%);
}

.portal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

/* Safety net: on weak tiers, portal overlay should never capture touches */
:root[data-perf-tier="low"] .portal-overlay.active,
:root[data-perf-tier="minimal"] .portal-overlay.active {
    pointer-events: none !important;
}

.portal-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Glitch Effect */
.glitch-effect {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    pointer-events: none;
    z-index: 1;
}

.glitch-effect.active {
    opacity: 1;
    animation: glitch 0.3s;
}

.glitch-line {
    position: absolute;
    width: 100%;
    height: 2px;
    background: var(--ts-text-primary);
    opacity: 0.8;
    animation: glitchLine 0.3s;
}

.glitch-line:nth-child(1) {
    top: 20%;
    animation-delay: 0s;
}

.glitch-line:nth-child(2) {
    top: 50%;
    animation-delay: 0.1s;
}

.glitch-line:nth-child(3) {
    top: 80%;
    animation-delay: 0.2s;
}

@keyframes glitch {

    0%,
    100% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-2px);
    }

    40% {
        transform: translateX(2px);
    }

    60% {
        transform: translateX(-1px);
    }

    80% {
        transform: translateX(1px);
    }
}

@keyframes glitchLine {
    0% {
        opacity: 0;
        transform: translateX(-100%);
    }

    50% {
        opacity: 0.8;
    }

    100% {
        opacity: 0;
        transform: translateX(100%);
    }
}

.portal-ripple {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.8) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    animation: portalRipple 1s ease-out;
}

@keyframes portalRipple {
    0% {
        width: 0;
        height: 0;
        opacity: 1;
    }

    100% {
        width: 200vw;
        height: 200vw;
        opacity: 0;
    }
}

.portal-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--ts-text-primary);
    border-radius: 50%;
    opacity: 0.8;
    animation: particleFloat 3s infinite ease-in-out;
}

@keyframes particleFloat {

    0%,
    100% {
        transform: translateY(0) translateX(0);
        opacity: 0;
    }

    50% {
        opacity: 0.8;
    }
}

/* Immersive world container */
.world-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    /* Above world-background (1) and particles (0) */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.6s ease, visibility 0.6s ease;
    overflow-y: auto;
    overflow-x: hidden;
    background: transparent;
    /* Transparent so world-background shows through */
}

.world-container.active {
    opacity: 1;
    visibility: visible;
}

/* Hide navigation and buttons when world module is active */
/* Using both :has() selector and body class for maximum browser compatibility */
body:has(.world-container.active) .nav-bar,
body.world-module-active .nav-bar {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Hide watching/listening/reading buttons when module is active */
body:has(.world-container.active) .icons-row,
body.world-module-active .icons-row {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Also hide the entire headshot container when module is active */
body:has(.world-container.active) .headshot-container,
body.world-module-active .headshot-container {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Hide header text when module is active */
body:has(.world-container.active) .container header h1,
body:has(.world-container.active) .container header .subtitle,
body.world-module-active .container header h1,
body.world-module-active .container header .subtitle {
    opacity: 0 !important;
    visibility: hidden !important;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.world-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.6s ease;
    background: transparent;
}

.world-canvas.active {
    opacity: 1;
}

.world-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: all 1s ease;
    opacity: 0;
    visibility: hidden;
    z-index: 1;
    /* Above particles (0) but below world-container (2) */
    pointer-events: none;
    /* Don't block clicks */
    /* Semi-transparent backgrounds allow particles to show through */
}

.world-background.active {
    opacity: 1;
    /* Element opacity - actual transparency is in the rgba colors */
    visibility: visible;
}

/* Themed backgrounds - semi-transparent so particles show through from behind */
.world-background[data-theme="watching"] {
    background: linear-gradient(135deg, rgba(139, 0, 0, 0.7) 0%, rgba(165, 42, 42, 0.7) 30%, rgba(192, 57, 43, 0.7) 60%, rgba(231, 76, 60, 0.7) 100%);
    animation: watchingPulse 4s ease-in-out infinite;
}

.world-background[data-theme="listening"] {
    background: linear-gradient(135deg, rgba(26, 84, 144, 0.7) 0%, rgba(41, 128, 185, 0.7) 30%, rgba(52, 152, 219, 0.7) 60%, rgba(82, 201, 242, 0.7) 100%);
    animation: listeningWave 6s ease-in-out infinite;
}

.world-background[data-theme="reading"] {
    background: linear-gradient(135deg, rgba(106, 27, 154, 0.7) 0%, rgba(142, 36, 170, 0.7) 30%, rgba(165, 105, 189, 0.7) 60%, rgba(186, 104, 200, 0.7) 100%);
    animation: readingGlow 5s ease-in-out infinite;
}

.world-background[data-theme="thinking"] {
    background: linear-gradient(135deg, rgba(76, 81, 191, 0.7) 0%, rgba(95, 39, 205, 0.7) 30%, rgba(108, 92, 231, 0.7) 60%, rgba(129, 118, 255, 0.7) 100%);
    animation: thinkingPulse 5s ease-in-out infinite;
}

@keyframes watchingPulse {

    0%,
    100% {
        filter: brightness(1) hue-rotate(0deg);
    }

    50% {
        filter: brightness(1.2) hue-rotate(10deg);
    }
}

@keyframes listeningWave {

    0%,
    100% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }
}

@keyframes readingGlow {

    0%,
    100% {
        filter: brightness(1) saturate(1);
    }

    50% {
        filter: brightness(1.3) saturate(1.2);
    }
}

@keyframes thinkingPulse {

    0%,
    100% {
        filter: brightness(1) hue-rotate(0deg);
    }

    50% {
        filter: brightness(1.2) hue-rotate(5deg);
    }
}

.world-content {
    position: relative;
    z-index: 100;
    max-width: 900px;
    margin: 0 auto;
    padding: 80px 40px 40px 40px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    animation: worldEnter 1s ease-out;
    pointer-events: auto;
    transform-origin: center center;
    left: 0;
    right: 0;
    transform: translateZ(0) translateX(0);
}

@keyframes worldEnter {
    0% {
        opacity: 0;
        transform: translateZ(0) translateX(0) translateY(30px);
    }

    100% {
        opacity: 1;
        transform: translateZ(0) translateX(0) translateY(0);
    }
}

.world-close-btn {
    position: fixed;
    top: 30px;
    right: 30px;
    background: var(--ts-border-default);
    backdrop-filter: blur(12px);
    color: var(--ts-text-secondary);
    border: 1px solid var(--ts-border-hover);
    font-size: 1.5rem;
    cursor: pointer;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    transition: all 0.2s ease;
    z-index: 1001;
}

.world-close-btn:hover {
    background: var(--ts-border-hover);
    border-color: var(--ts-border-hover);
    color: var(--ts-text-primary);
}

.world-header {
    text-align: center;
    margin-bottom: 50px;
    color: var(--ts-text-primary);
    padding-top: 20px;
    position: relative;
    z-index: 100;
    background: var(--ts-bg-overlay);
    backdrop-filter: blur(12px);
    padding: 30px 20px;
    border-radius: 20px;
    margin: 0 auto 50px;
    max-width: 800px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    transform: translateZ(0) translateX(0);
    backface-visibility: hidden;
    left: 0;
    right: 0;
    margin-left: auto;
    margin-right: auto;
    opacity: 0;
    visibility: hidden;
}

.world-container.active .world-header {
    opacity: 1 !important;
    visibility: visible !important;
    animation: fadeInUp 0.5s ease-out 0.1s both;
    animation-fill-mode: both;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translate3d(0, 20px, 0);
    }

    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

.world-header h2 {
    font-size: 3.5rem;
    margin-bottom: 15px;
    text-shadow: 0 0 30px rgba(255, 255, 255, 0.8),
        0 0 60px rgba(255, 255, 255, 0.4),
        0 4px 10px rgba(0, 0, 0, 0.8);
    font-weight: 700;
    background: linear-gradient(135deg, var(--ts-text-primary) 0%, rgba(255, 255, 255, 0.9) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    position: relative;
    z-index: 101;
    transform: translateZ(0) translateX(0) !important;
    will-change: auto;
    display: block;
    width: 100%;
    text-align: center;
    color: var(--ts-text-primary) !important;
    /* Fallback color - always visible */
    min-height: 1.2em;
    /* Prevent layout shift */
    opacity: 1 !important;
    /* Ensure text is always visible */
    visibility: visible !important;
}

/* Fallback for browsers that don't support background-clip */
@supports not (-webkit-background-clip: text) {
    .world-header h2 {
        -webkit-text-fill-color: var(--ts-text-primary);
        color: var(--ts-text-primary);
    }
}

.world-subtitle {
    font-size: 1.3rem;
    opacity: 0.95;
    font-weight: 300;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8),
        0 0 20px rgba(255, 255, 255, 0.3);
    position: relative;
    z-index: 101;
    color: var(--ts-text-primary);
}

/* Public Profile Filter - Landing Page */
.public-profile-filter-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin-top: 8px;
    margin-bottom: 20px;
    /* breathing room above bottom nav */
    position: relative !important;
    z-index: 10000 !important;
    animation: fadeInUp 1s ease-out 0.5s both;
    width: 100%;
}

/* Simple inline date range toggle */
.date-range-toggle {
    display: inline-flex;
    gap: 0;
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid var(--ts-border-hover);
    background: var(--ts-border-default);
    backdrop-filter: blur(8px);
}

.date-range-btn {
    padding: 5px 14px;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--ts-text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
    letter-spacing: 0.2px;
    position: relative;
    opacity: 0.6;
}

.date-range-btn:first-child {
    border-right: 1px solid var(--ts-border-hover);
}

.date-range-btn.active {
    background: var(--ts-highlight);
    color: var(--ts-text-primary);
    font-weight: 600;
    opacity: 1;
    box-shadow: inset 0 1px 4px rgba(255, 255, 255, 0.08);
}

.date-range-btn:not(.active):hover {
    opacity: 0.85;
    color: var(--ts-text-secondary);
    background: rgba(255, 255, 255, 0.04);
}

@media (max-width: 768px) {
    .date-range-btn {
        padding: 4px 12px;
        font-size: 0.65rem;
    }
}

/* Year/Month Filter Styles - Public Profile Only */
.year-month-filter-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 30px;
    position: relative;
    z-index: 102;
    animation: fadeInUp 1s ease-out 0.4s both;
}

.public-filter-toggle-btn,
.filter-toggle-btn {
    background: var(--ts-border-default);
    backdrop-filter: blur(10px);
    border: 1px solid var(--ts-border-hover);
    border-radius: 50px;
    padding: 6px 14px;
    color: var(--ts-text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0.6;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}

.public-filter-toggle-btn::before,
.filter-toggle-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.public-filter-toggle-btn:hover::before,
.filter-toggle-btn:hover::before {
    left: 100%;
}

.public-filter-toggle-btn:hover,
.filter-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    color: var(--ts-text-primary);
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.4);
}

.public-filter-toggle-btn.active,
.filter-toggle-btn.active {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.6);
    color: var(--ts-text-primary);
    opacity: 1;
}

.public-filter-toggle-btn .filter-icon,
.filter-toggle-btn .filter-icon {
    font-size: 0.8rem;
    filter: none;
}

.public-filter-toggle-btn .filter-text,
.filter-toggle-btn .filter-text {
    font-weight: 500;
    text-shadow: none;
}

.public-filter-toggle-btn .filter-arrow,
.filter-toggle-btn .filter-arrow {
    font-size: 0.55rem;
    transition: transform 0.3s ease;
}

.public-filter-toggle-btn.active .filter-arrow,
.filter-toggle-btn.active .filter-arrow {
    transform: rotate(180deg);
}

/* Filter modal backdrop */
.filter-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--ts-bg-overlay);
    /* backdrop-filter removed — Android/iOS WebView overlay bug */
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.filter-modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

/* Filter dropdown — compact centered modal */
.public-filter-dropdown,
.filter-dropdown {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    background: rgba(10, 12, 20, 0.96) !important;
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 16px;
    padding: 18px 20px;
    min-width: 240px;
    max-width: 300px;
    width: calc(100vw - 80px);
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, -50%) scale(0.9);
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        visibility 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.7),
        0 0 0 1px var(--ts-border-default) inset;
    z-index: 10001 !important;
    pointer-events: none;
    display: block !important;
}

.public-filter-dropdown.active,
.filter-dropdown.active,
#publicFilterDropdown.active,
.public-profile-filter-container .public-filter-dropdown.active {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translate(-50%, -50%) scale(1) !important;
    pointer-events: auto !important;
    display: block !important;
    z-index: 10001 !important;
}

/* Force override any conflicting styles */
#publicFilterDropdown.active {
    opacity: 1 !important;
    visibility: visible !important;
    display: block !important;
}

/* Modal close button */
.filter-modal-close {
    position: absolute;
    top: 10px;
    right: 12px;
    background: none;
    border: none;
    color: var(--ts-text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 2px 6px;
    line-height: 1;
    transition: color 0.2s ease, transform 0.2s ease;
    z-index: 1;
}

.filter-modal-close:hover {
    color: var(--ts-text-primary);
    transform: scale(1.1);
}

/* Modal title */
.filter-modal-title {
    text-align: center;
    color: var(--ts-text-primary);
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 14px;
    letter-spacing: 0.3px;
}

.filter-section {
    margin-bottom: 12px;
}

.filter-section:last-of-type {
    margin-bottom: 0;
}

.filter-label {
    display: block;
    color: var(--ts-text-secondary);
    font-size: 0.7rem;
    font-weight: 600;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    text-shadow: none;
}

.filter-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 150px;
    overflow-y: auto;
    padding: 2px;
    scrollbar-width: thin;
    scrollbar-color: var(--ts-scrollbar-thumb) var(--ts-scrollbar-track);
}

.filter-options::-webkit-scrollbar {
    width: 6px;
}

.filter-options::-webkit-scrollbar-track {
    background: transparent;
}

.filter-options::-webkit-scrollbar-thumb {
    background: var(--ts-scrollbar-thumb);
    border-radius: 3px;
}

.filter-options::-webkit-scrollbar-thumb:hover {
    background: var(--ts-border-hover);
}

.filter-option {
    background: var(--ts-highlight);
    border: 1px solid var(--ts-border-hover);
    border-radius: 20px;
    padding: 5px 12px;
    color: var(--ts-text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.filter-option::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

.filter-option:hover::before {
    width: 200px;
    height: 200px;
}

.filter-option:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.filter-option.active {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
    color: var(--ts-text-primary);
    font-weight: 600;
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.2),
        0 2px 8px rgba(0, 0, 0, 0.3);
}

.filter-option.active::after {
    content: '✓';
    margin-left: 5px;
    font-size: 0.65rem;
    font-weight: bold;
    display: inline-block;
    animation: checkmark 0.3s ease;
}

@keyframes checkmark {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }

    50% {
        transform: scale(1.2) rotate(10deg);
    }

    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.filter-actions {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--ts-border-hover);
    display: flex;
    justify-content: center;
}

.filter-clear-btn {
    background: rgba(244, 67, 54, 0.15);
    border: 1px solid rgba(244, 67, 54, 0.3);
    border-radius: 20px;
    padding: 5px 14px;
    color: var(--ts-text-secondary);
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.filter-clear-btn:hover {
    background: rgba(244, 67, 54, 0.3);
    border-color: rgba(244, 67, 54, 0.6);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(244, 67, 54, 0.4);
}

.filter-clear-btn:active {
    transform: translateY(0);
}

/* Mobile responsive styles for filter */
@media (max-width: 768px) {

    .public-profile-filter-container,
    .year-month-filter-container {
        margin-top: 8px;
    }

    .public-filter-toggle-btn,
    .filter-toggle-btn {
        padding: 5px 12px;
        font-size: 0.7rem;
    }

    .public-filter-dropdown,
    .filter-dropdown {
        width: calc(100vw - 60px);
        min-width: unset;
        max-width: 280px;
        padding: 14px 16px;
    }

    .filter-options {
        max-height: 120px;
    }

    .filter-option {
        padding: 4px 10px;
        font-size: 0.7rem;
    }

    .filter-modal-title {
        font-size: 0.8rem;
        margin-bottom: 10px;
    }

    .filter-label {
        font-size: 0.65rem;
        margin-bottom: 6px;
    }

    .filter-clear-btn {
        padding: 4px 12px;
        font-size: 0.65rem;
    }

    .filter-actions {
        margin-top: 10px;
        padding-top: 10px;
    }
}

.world-list {
    display: grid;
    gap: 25px;
    animation: fadeInUp 1s ease-out 0.5s both;
    transform: translateZ(0) translateX(0);
    transform-origin: center center;
    left: 0;
    right: 0;
    margin-left: auto;
    margin-right: auto;
    position: relative;
    z-index: 101;
}

.world-item {
    background: var(--ts-bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 30px;
    border-radius: 14px;
    border: 1px solid var(--ts-border-default);
    transition: all 0.4s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    opacity: 0;
    animation: fadeInUp 0.6s ease-out forwards;
    height: auto;
    display: flex;
    flex-direction: column;
    transform: translateZ(0) translateX(0);
    transform-origin: center center;
    left: 0;
    right: 0;
    margin-left: auto;
    margin-right: auto;
}

/* Content wrapper for horizontal layout */
.world-item-content-wrapper {
    display: flex;
    gap: 25px;
    align-items: flex-start;
    flex: 1;
    min-height: 0;
}

/* Image container on the left */
.world-item-image {
    flex-shrink: 0;
    width: 150px;
    min-width: 150px;
    transform: translateZ(0) translateX(0);
    transform-origin: center center;
}

.world-item-image img,
.world-item-image video {
    width: 100%;
    max-width: 150px;
    height: auto;
    max-height: 225px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    object-fit: cover;
    transform: translateZ(0) translateX(0);
    transform-origin: center center;
    display: block;
}

.world-item-image video {
    max-height: 225px;
    object-fit: contain;
}

/* Text content on the right */
.world-item-text-content {
    flex: 1;
    min-width: 0;
    /* Allows text to shrink and wrap */
    display: flex;
    flex-direction: column;
    overflow: visible;
}

.world-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s;
}

.world-item:hover::before {
    left: 100%;
}

.world-item:hover {
    background: var(--ts-bg-card-hover);
    border-color: var(--ts-border-hover);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.world-item:active {
    background: var(--ts-bg-card-hover);
}

.world-item-text-content h3 {
    font-size: 1.5rem;
    margin-bottom: 12px;
    color: var(--ts-text-primary);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.world-item-text-content p {
    color: var(--ts-text-secondary);
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 10px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* "Read full" link — hidden by default, shown via JS when text is truncated (webview only) */
.world-item-read-full {
    display: none;
    color: var(--ts-text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    margin-top: 6px;
    transition: color 0.2s ease;
}

.world-item-read-full.visible {
    display: inline-block;
}

/* Hide "Read full" on mobile screens and native apps */
@media (max-width: 768px) {
    .world-item-read-full {
        display: none !important;
    }
}

body.capacitor-native .world-item-read-full {
    display: none !important;
}

.world-item-read-full:hover {
    color: var(--ts-text-primary);
    text-decoration: underline;
}

.world-item-text-content .meta {
    margin-top: 15px;
    font-size: 0.9rem;
    color: var(--ts-text-secondary);
    font-style: italic;
    transition: color 0.3s ease;
}

.world-item:hover .world-item-text-content .meta {
    color: var(--ts-text-secondary);
    font-style: italic;
}

/* Link styling */
.world-item-link {
    color: var(--ts-text-secondary);
    text-decoration: underline;
    display: inline-block;
    margin-top: 10px;
    transition: color 0.3s ease;
}

.world-item-link:hover {
    color: var(--ts-text-primary);
}

/* Thoughtful button */
.entry-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    align-items: center;
    pointer-events: auto;
}

.like-btn {
    background: transparent;
    border: 1px solid var(--ts-border-hover);
    color: var(--ts-text-primary);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    pointer-events: auto;
}

.like-btn:hover {
    background: rgba(108, 92, 231, 0.2);
    border-color: #6c5ce7;
    transform: scale(1.05);
}

.like-btn.active {
    background: rgba(108, 92, 231, 0.3);
    border-color: #6c5ce7;
}

.like-count {
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}


/* Mobile: Show default cursor */
@media (max-width: 768px) {

    /* Prevent horizontal overflow and stretching */
    html,
    body {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100vw !important;
        position: relative !important;
    }

    /* Keep background canvas visible on mobile, just ensure it doesn't block content */
    .background-canvas {
        opacity: 0.7;
    }

    /* Ensure world container doesn't stretch */
    .world-container {
        width: 100% !important;
        max-width: 100vw !important;
        left: 0 !important;
        right: 0 !important;
        transform: none !important;
        overflow-x: hidden !important;
        position: fixed !important;
    }

    /* Prevent nav-bar from causing stretching when world is active */
    body:has(.world-container.active) .nav-bar,
    body.world-module-active .nav-bar {
        transform: none !important;
        width: auto !important;
        max-width: none !important;
        left: auto !important;
        right: auto !important;
    }

    body:has(.world-container.active) .nav-bar-right,
    body.world-module-active .nav-bar-right {
        transform: none !important;
        position: static !important;
        right: auto !important;
        left: auto !important;
        width: auto !important;
        max-width: none !important;
    }

    body:has(.world-container.active) #logoutButton,
    body.world-module-active #logoutButton {
        transform: none !important;
        width: auto !important;
        max-width: none !important;
        position: static !important;
        left: auto !important;
        right: auto !important;
    }

    /* Responsive design */
    .world-header {
        transform: none !important;
        position: relative !important;
        opacity: 0 !important;
        visibility: hidden !important;
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        left: auto !important;
        right: auto !important;
    }

    .world-container.active .world-header {
        opacity: 1 !important;
        visibility: visible !important;
        animation: fadeInUpMobile 0.3s ease-out both !important;
        animation-fill-mode: both !important;
    }

    .world-header h2 {
        font-size: 2.5rem;
        transform: none !important;
        transform-origin: center center !important;
        will-change: auto !important;
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        text-align: center !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        left: auto !important;
        right: auto !important;
        position: relative !important;
        color: var(--ts-text-primary) !important;
        /* Ensure text is visible */
        min-height: 1.2em !important;
        /* Prevent layout shift */
    }

    @keyframes fadeInUpMobile {
        from {
            opacity: 0;
            transform: translateY(10px);
        }

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

    .world-subtitle {
        font-size: 1.1rem;
    }

    .world-content {
        padding: 40px 20px;
        transform: none !important;
        transform-origin: center center !important;
        width: 100% !important;
        max-width: 100vw !important;
        left: 0 !important;
        right: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        box-sizing: border-box !important;
        position: relative !important;
        overflow-x: hidden !important;
    }

    .world-list {
        transform: none !important;
        transform-origin: center center !important;
        width: 100% !important;
        max-width: 100vw !important;
        left: 0 !important;
        right: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        box-sizing: border-box !important;
        position: relative !important;
        overflow-x: hidden !important;
    }

    .world-item {
        transform: none !important;
        transform-origin: center center !important;
        width: 100% !important;
        max-width: 100% !important;
        left: 0 !important;
        right: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        box-sizing: border-box !important;
        position: relative !important;
        overflow-x: hidden !important;
        padding: 25px 20px !important;
    }

    .world-item:hover {
        background: var(--ts-bg-card-hover) !important;
        border-color: var(--ts-border-hover) !important;
    }

    .world-item:active {
        background: var(--ts-bg-card-hover) !important;
    }

    .world-close-btn {
        top: 20px !important;
        right: 20px !important;
        left: auto !important;
        width: 38px !important;
        height: 38px !important;
        font-size: 1.3rem !important;
        position: fixed !important;
        transform: none !important;
        margin: 0 !important;
        max-width: 38px !important;
        flex-shrink: 0 !important;
        border-radius: 10px !important;
    }

    /* Stack world-item content vertically on mobile */
    .world-item-content-wrapper {
        flex-direction: column;
        gap: 15px;
    }

    .world-item-image {
        width: 100%;
        min-width: 100%;
        max-width: 200px;
        margin: 0 auto;
    }

    .world-item-image img,
    .world-item-image video {
        max-width: 100%;
        width: 100%;
    }

    .world-item-text-content h3 {
        font-size: 1.3rem;
    }

    .headshot-wrapper {
        width: 150px;
        height: 150px;
    }

    .headshot,
    .headshot-placeholder {
        width: 150px;
        height: 150px;
        border-width: 4px;
    }

    .placeholder-icon {
        font-size: 60px;
    }

    /* Adjust icons row for mobile — single row */
    .icons-row {
        gap: 8px;
        flex-wrap: nowrap;
    }

    .face-icon {
        min-width: 0;
        padding: 10px 12px;
        flex: 1 1 0;
    }

    .face-icon svg {
        width: 26px;
        height: 26px;
    }

    .icon-label {
        font-size: 0.65rem;
    }

    header h1 {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

}

/* Welcome Overlay */
.welcome-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--ts-bg-deep);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.8s ease-out, visibility 0.8s ease-out;
    pointer-events: auto;
}

.welcome-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.welcome-content {
    position: relative;
    text-align: center;
    padding: 40px;
    z-index: 1;
    animation: welcomeFadeIn 1.2s ease-out;
}

.welcome-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    border-radius: 50%;
    animation: welcomePulse 3s ease-in-out infinite;
    z-index: -1;
}

.welcome-title {
    font-size: 3.5rem;
    font-weight: 700;
    color: var(--ts-text-primary);
    margin: 0 0 20px 0;
    text-shadow: var(--ts-text-glow);
    letter-spacing: -0.02em;
    animation: welcomeTitleSlide 1s ease-out 0.3s both;
    background: linear-gradient(135deg, var(--ts-text-primary) 0%, #e0e0e0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-subtitle {
    font-size: 1.3rem;
    color: var(--ts-text-secondary);
    margin: 0;
    font-weight: 300;
    letter-spacing: 0.05em;
    animation: welcomeSubtitleFade 1s ease-out 0.6s both;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

.welcome-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

.welcome-particles::before,
.welcome-particles::after {
    content: '';
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.6),
        0 0 20px rgba(255, 255, 255, 0.4);
    animation: welcomeParticleFloat 4s ease-in-out infinite;
}

.welcome-particles::before {
    top: 20%;
    left: 20%;
    animation-delay: 0s;
}

.welcome-particles::after {
    top: 60%;
    right: 25%;
    animation-delay: 2s;
}

@keyframes welcomeFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes welcomePulse {

    0%,
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.3;
    }

    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 0.5;
    }
}

@keyframes welcomeTitleSlide {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }

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

@keyframes welcomeSubtitleFade {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

@keyframes welcomeParticleFloat {

    0%,
    100% {
        transform: translateY(0) translateX(0);
        opacity: 0.6;
    }

    25% {
        transform: translateY(-20px) translateX(10px);
        opacity: 1;
    }

    50% {
        transform: translateY(-10px) translateX(-15px);
        opacity: 0.8;
    }

    75% {
        transform: translateY(-30px) translateX(5px);
        opacity: 1;
    }
}

/* Welcome Headshot Blackboard Eraser Effect */
.welcome-headshot {
    position: absolute;
    top: 50%;
    right: 10%;
    transform: translateY(-50%);
    width: 180px;
    height: 180px;
    border-radius: 50%;
    z-index: 10001;
    pointer-events: none;
    opacity: 0;
    animation: headshotAppearRight 0.6s ease-out 2s forwards, headshotEraseLeft 3s linear 2.6s forwards;
    overflow: visible;
    border: 3px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 40px rgba(255, 255, 255, 0.3);
}

.welcome-headshot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    filter: brightness(1.1) contrast(1.05);
    border-radius: 50%;
}

/* Dust particles effect */
.welcome-headshot::before,
.welcome-headshot::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    opacity: 0;
    animation: dustParticles 2.5s ease-in-out 2.6s infinite;
}

.welcome-headshot::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
    border-radius: 50%;
    opacity: 0;
    animation: dustCloud 2.5s ease-in-out 2.6s forwards;
    pointer-events: none;
}

.welcome-headshot::after {
    display: none;
}

@keyframes headshotAppearRight {
    0% {
        opacity: 0;
        right: 5%;
        transform: translateY(-50%) scale(0.3);
    }

    100% {
        opacity: 1;
        right: 5%;
        transform: translateY(-50%) scale(1);
    }
}

@keyframes headshotEraseLeft {
    0% {
        right: 5%;
        left: auto;
        transform: translateY(-50%) scale(1);
        opacity: 1;
    }

    10% {
        right: 0%;
        left: auto;
        transform: translateY(-50%) scale(1.05);
        opacity: 1;
    }

    25% {
        right: auto;
        left: 80%;
        transform: translateY(-50%) scale(1.1);
        opacity: 1;
    }

    40% {
        right: auto;
        left: 50%;
        transform: translateY(-50%) scale(1.2);
        opacity: 1;
    }

    55% {
        right: auto;
        left: 30%;
        transform: translateY(-50%) scale(1.3);
        opacity: 1;
    }

    70% {
        right: auto;
        left: 10%;
        transform: translateY(-50%) scale(1.4);
        opacity: 1;
    }

    85% {
        right: auto;
        left: -5%;
        transform: translateY(-50%) scale(1.3);
        opacity: 1;
    }

    100% {
        right: auto;
        left: -30%;
        transform: translateY(-50%) scale(1.2);
        opacity: 0.8;
    }
}

@keyframes dustParticles {
    0% {
        opacity: 0;
        transform: translate(0, 0) scale(0.5);
    }

    20% {
        opacity: 1;
        transform: translate(-30px, -20px) scale(1);
    }

    40% {
        opacity: 0.8;
        transform: translate(-60px, -40px) scale(0.8);
    }

    60% {
        opacity: 0.6;
        transform: translate(-90px, -30px) scale(0.6);
    }

    100% {
        opacity: 0;
        transform: translate(-120px, -50px) scale(0.3);
    }
}

/* Blackboard eraser effect - text disappears as headshot passes */
.welcome-overlay.wiping .welcome-content {
    position: relative;
    z-index: 10000;
}

.welcome-overlay.wiping .welcome-title,
.welcome-overlay.wiping .welcome-subtitle {
    position: relative;
    z-index: 1;
    animation: textEraseDuster 2.5s ease-in-out 2.6s forwards;
}

@keyframes textEraseDuster {
    0% {
        clip-path: inset(0 0% 0 0%);
        -webkit-clip-path: inset(0 0% 0 0%);
        opacity: 1;
        filter: blur(0px);
    }

    15% {
        clip-path: inset(0 20% 0 0%);
        -webkit-clip-path: inset(0 20% 0 0%);
        opacity: 0.9;
        filter: blur(0.5px);
    }

    30% {
        clip-path: inset(0 40% 0 0%);
        -webkit-clip-path: inset(0 40% 0 0%);
        opacity: 0.7;
        filter: blur(1px);
    }

    50% {
        clip-path: inset(0 60% 0 0%);
        -webkit-clip-path: inset(0 60% 0 0%);
        opacity: 0.5;
        filter: blur(1.5px);
    }

    70% {
        clip-path: inset(0 80% 0 0%);
        -webkit-clip-path: inset(0 80% 0 0%);
        opacity: 0.3;
        filter: blur(2px);
    }

    85% {
        clip-path: inset(0 90% 0 0%);
        -webkit-clip-path: inset(0 90% 0 0%);
        opacity: 0.1;
        filter: blur(2.5px);
    }

    100% {
        clip-path: inset(0 100% 0 0%);
        -webkit-clip-path: inset(0 100% 0 0%);
        opacity: 0;
        filter: blur(3px);
    }
}

/* Responsive welcome overlay */
@media (max-width: 768px) {
    .welcome-title {
        font-size: 2.5rem;
    }

    .welcome-subtitle {
        font-size: 1.1rem;
    }

    .welcome-glow {
        width: 300px;
        height: 300px;
    }

    .welcome-headshot {
        animation: headshotWipe 1.2s ease-in-out 2s forwards;
    }
}

/* ============================================================================
   NOTIFICATION SYSTEM
   ============================================================================ */

/* Notification Container */
.notification-container {
    position: relative !important;
    display: inline-block !important;
    z-index: auto !important;
    isolation: auto !important;
}

.notification-btn {
    position: relative;
    background: var(--ts-highlight);
    border: 1px solid var(--ts-border-hover);
    color: var(--ts-text-secondary);
    padding: 10px 16px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.notification-btn:hover {
    background: var(--ts-border-hover);
    border-color: var(--ts-border-hover);
    transform: translateY(-1px);
}

.notification-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: linear-gradient(135deg, var(--ts-accent-error) 0%, #ee5a6f 100%);
    color: var(--ts-text-primary);
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 20px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(255, 107, 107, 0.4);
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        box-shadow: 0 2px 8px rgba(255, 107, 107, 0.4);
    }

    50% {
        transform: scale(1.1);
        box-shadow: 0 4px 12px rgba(255, 107, 107, 0.6);
    }
}

/* Notification Dropdown */
.notification-dropdown {
    position: fixed !important;
    /* Use fixed to escape any parent stacking contexts */
    top: auto !important;
    bottom: auto !important;
    left: auto !important;
    right: 20px !important;
    width: 400px;
    max-width: 90vw;
    max-height: 600px;
    background: rgba(10, 12, 20, 0.98) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border: 1px solid var(--ts-border-hover) !important;
    border-radius: 16px !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5) !important;
    z-index: 99999999 !important;
    /* Highest z-index - above everything including modals */
    overflow: hidden !important;
    display: none;
    /* Start hidden - inline style will override */
    flex-direction: column !important;
    animation: slideDown 0.3s ease-out;
    pointer-events: auto !important;
    isolation: isolate !important;
    /* Create new stacking context */
    visibility: hidden;
    /* Ensure it's hidden initially */
    opacity: 0;
    /* Start with opacity 0 */
    transition: opacity 0.3s ease-out, visibility 0.3s ease-out !important;
    transform: none !important;
    /* Ensure no transform creates stacking context issues */
    will-change: transform, opacity;
    /* Optimize for animation */
}

/* When shown via inline style */
.notification-dropdown[style*="display: flex"],
.notification-dropdown[style*="display:flex"] {
    visibility: visible !important;
    opacity: 1 !important;
}

/* Ensure parent containers don't clip the dropdown */
.dashboard-actions,
.notification-container {
    overflow: visible !important;
    position: relative !important;
}

/* Nav-bar should be fixed at top for feed/discover pages */
.nav-bar {
    overflow: visible !important;
}

/* Particle Toggle Button Styles - Redesigned */
#particleOpacityBtn,
#particleToggleBtn {
    position: fixed;
    bottom: 100px;
    /* Positioned above chatbot with consistent spacing */
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 12px;
    background: var(--ts-border-default);
    border: 1px solid var(--ts-border-hover);
    color: var(--ts-text-primary);
    font-size: 1.4rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15), inset 0 1px 0 var(--ts-highlight);
}

#particleOpacityBtn:hover,
#particleToggleBtn:hover {
    background: var(--ts-border-hover);
    border-color: var(--ts-border-hover);
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2), inset 0 1px 0 var(--ts-border-hover);
}

#particleOpacityBtn:active,
#particleToggleBtn:active {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Hide button on auth pages (but JavaScript controls visibility based on login state) */
.auth-page #particleOpacityBtn,
.auth-page #particleToggleBtn {
    display: none !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {

    /* Hide particle opacity button on mobile - it's in burger menu */
    #particleOpacityBtn,
    #particleToggleBtn {
        display: none !important;
    }
}

/* Update chatbot icon container to work with new design */
.chatbot-icon-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
    overflow: hidden;
}

.chatbot-icon-container svg,
.chatbot-icon-container>div {
    transform: scale(1);
    transform-origin: center;
}

/* No need for 480px breakpoint - button is hidden on mobile */

/* Ensure dashboard container doesn't clip */
.dashboard-container {
    overflow: visible !important;
    display: flex !important;
    flex-direction: column !important;
}

/* Ensure category sections don't create stacking contexts that interfere */
/* Also allow reordering with CSS order property */
.category-section {
    isolation: auto !important;
    flex-shrink: 0;
}

/* Notification container should not create stacking context */
.notification-container {
    z-index: auto !important;
    position: relative !important;
    isolation: auto !important;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

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

.notification-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--ts-accent-subtle);
}

.notification-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--ts-text-primary);
    margin: 0;
}

.mark-all-read-btn {
    background: transparent;
    border: 1px solid var(--ts-border-hover);
    color: var(--ts-text-secondary);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mark-all-read-btn:hover {
    background: var(--ts-bg-input);
    border-color: var(--ts-border-hover);
}

.notification-list {
    overflow-y: auto;
    max-height: 500px;
    padding: 8px;
}

.notification-list::-webkit-scrollbar {
    width: 6px;
}

.notification-list::-webkit-scrollbar-track {
    background: var(--ts-bg-input);
    border-radius: 3px;
}

.notification-list::-webkit-scrollbar-thumb {
    background: var(--ts-scrollbar-thumb);
    border-radius: 3px;
}

.notification-list::-webkit-scrollbar-thumb:hover {
    background: var(--ts-border-hover);
}

.notification-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 4px;
    border: 1px solid transparent;
}

.notification-item:hover {
    background: var(--ts-bg-card-hover);
    border-color: var(--ts-border-default);
}

.notification-item.unread {
    background: var(--ts-accent-subtle);
    border-left: 3px solid var(--ts-accent-primary);
}

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

.notification-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--ts-border-hover);
    flex-shrink: 0;
}

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

.notification-text {
    color: var(--ts-text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 4px;
    line-height: 1.4;
}

.notification-entry-title {
    color: var(--ts-text-muted);
    font-size: 0.85rem;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notification-time {
    color: var(--ts-text-faint);
    font-size: 0.75rem;
}

.loading-notifications,
.empty-notifications {
    padding: 40px 20px;
    text-align: center;
    color: var(--ts-text-muted);
    font-size: 0.9rem;
}

/* Notification Page Styles */
.notifications-page {
    min-height: 100vh;
    padding: 40px 20px;
    max-width: 800px;
    margin: 0 auto;
}

.notifications-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
}

.notifications-page-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--ts-text-primary);
    margin: 0;
}

.notification-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.filter-btn {
    padding: 8px 16px;
    background: var(--ts-bg-input);
    border: 1px solid var(--ts-border-default);
    border-radius: 20px;
    color: var(--ts-text-muted);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
    line-height: 1.3;
}

.filter-btn:hover:not(.active) {
    background: var(--ts-border-default);
}

.filter-btn.active {
    background: var(--ts-accent-subtle);
    color: var(--ts-accent-primary);
    border-color: var(--ts-border-accent);
}

.notifications-list-page {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.notification-item-page {
    display: flex;
    gap: 16px;
    padding: 16px;
    background: var(--ts-bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--ts-border-default);
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.notification-item-page:hover {
    background: var(--ts-bg-card-hover);
    border-color: var(--ts-border-hover);
}

.notification-item-page.unread {
    background: var(--ts-accent-subtle);
    border-left: 4px solid var(--ts-accent-primary);
}

.notification-avatar-page {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--ts-border-hover);
    flex-shrink: 0;
}

.notification-content-page {
    flex: 1;
}

.notification-text-page {
    color: var(--ts-text-primary);
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 6px;
    line-height: 1.5;
}

.notification-entry-title-page {
    color: var(--ts-text-secondary);
    font-size: 0.9rem;
    margin-bottom: 6px;
}

.notification-time-page {
    color: var(--ts-text-muted);
    font-size: 0.85rem;
}

.notification-actions {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    padding-top: 4px;
}

.notification-action-btn {
    background: transparent;
    border: 1px solid var(--ts-border-hover);
    color: var(--ts-text-secondary);
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.notification-action-btn:hover {
    background: var(--ts-bg-input);
    border-color: var(--ts-border-hover);
    color: var(--ts-text-primary);
}

.notification-action-btn.delete:hover {
    background: rgba(244, 67, 54, 0.2);
    border-color: rgba(244, 67, 54, 0.4);
    color: #f44336;
}

@media (max-width: 768px) {
    .notification-dropdown {
        width: 320px;
        right: -50px;
    }

    .notifications-page-title {
        font-size: 1.2rem;
    }

    .notification-item-page {
        padding: 12px;
    }
}

/* ============================================================================
   GLOBAL MOBILE OPTIMIZATIONS
   Centralized mobile styles to reduce button sizes, fonts, and spacing
   throughout the entire application for better mobile UX
   ============================================================================ */

@media (max-width: 768px) {

    /* Prevent iOS zoom on input focus and double-tap zoom */
    html {
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }

    * {
        touch-action: manipulation;
        /* Disable double-tap zoom */
    }

    /* HIDE TOP NAVBAR ON MOBILE - use bottom nav instead */
    .nav-bar {
        display: none !important;
    }

    /* Reduce all button padding and font sizes globally */
    button,
    .btn,
    .btn-primary,
    .btn-secondary,
    .auth-button,
    .oauth-button,
    input[type="button"],
    input[type="submit"] {
        padding: 6px 10px !important;
        font-size: 0.85rem !important;
        line-height: 1.3 !important;
    }

    /* Reduce font sizes for headings */
    h1 {
        font-size: 1.8rem !important;
        margin-bottom: 10px !important;
    }

    h2 {
        font-size: 1.4rem !important;
        margin-bottom: 12px !important;
    }

    h3 {
        font-size: 1.2rem !important;
        margin-bottom: 10px !important;
    }

    /* Reduce general text font sizes - be selective to avoid breaking layouts */
    body {
        font-size: 0.9rem !important;
    }

    /* Only reduce font size for common text elements, not all divs */
    p,
    label,
    .text,
    .description {
        font-size: 0.9rem !important;
    }

    /* IMPORTANT: Keep input font-size at 16px to prevent iOS auto-zoom on focus */
    /* iOS Safari zooms in when input font-size is less than 16px */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    input[type="tel"],
    input[type="url"],
    input[type="number"],
    textarea,
    select,
    .form-input,
    .search-input,
    .ai-textarea {
        padding: 10px 12px !important;
        font-size: 16px !important;
        /* Must be 16px to prevent iOS zoom */
        -webkit-appearance: none;
        /* Remove iOS default styling */
        border-radius: 8px !important;
    }

    /* Reduce spacing in containers */
    .container,
    .section,
    .content-section {
        padding: 15px 12px !important;
    }

    /* Reduce gaps in flex/grid containers - be selective */
    .flex-container,
    .grid-container {
        gap: 8px !important;
    }

    /* Reduce margins between sections */
    section,
    .section,
    .category-section {
        margin-bottom: 15px !important;
    }

    /* Reduce card/box padding - be selective */
    .card,
    .box {
        padding: 12px !important;
        margin-bottom: 12px !important;
    }

    /* Reduce navigation spacing */
    nav,
    .nav,
    .navigation {
        padding: 8px 10px !important;
        gap: 6px !important;
    }

    /* Reduce header spacing */
    header,
    .header {
        padding: 10px 12px !important;
        margin-bottom: 12px !important;
    }

    /* Reduce list item spacing */
    li,
    .list-item {
        padding: 6px 8px !important;
        margin-bottom: 6px !important;
    }

    /* Reduce modal/dialog padding - be selective */
    .modal,
    .dialog {
        padding: 15px !important;
    }

    /* Reduce table cell padding */
    td,
    th {
        padding: 6px 8px !important;
        font-size: 0.85rem !important;
    }
}

/* Extra small screens - further reductions */
@media (max-width: 480px) {

    button,
    .btn,
    .btn-primary,
    .btn-secondary,
    .auth-button,
    .oauth-button {
        padding: 5px 8px !important;
        font-size: 0.8rem !important;
    }

    /* Keep face-icon compact on small screens */
    .face-icon {
        padding: 8px 8px !important;
    }

    .face-icon svg {
        width: 22px !important;
        height: 22px !important;
    }

    .icon-label {
        font-size: 0.6rem !important;
    }

    h1 {
        font-size: 1.6rem !important;
    }

    h2 {
        font-size: 1.2rem !important;
    }

    .container,
    .section {
        padding: 12px 10px !important;
    }

    /* IMPORTANT: Keep input font-size at 16px to prevent iOS auto-zoom */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    input[type="tel"],
    input[type="url"],
    input[type="number"],
    textarea,
    select,
    .form-input,
    .search-input,
    .ai-textarea {
        font-size: 16px !important;
        padding: 10px 12px !important;
    }
}

@media (max-width: 375px) {

    button,
    .btn,
    .btn-primary,
    .btn-secondary {
        padding: 4px 6px !important;
        font-size: 0.75rem !important;
    }

    h1 {
        font-size: 1.4rem !important;
    }

    /* IMPORTANT: Keep input font-size at 16px to prevent iOS auto-zoom */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    input[type="tel"],
    input[type="url"],
    input[type="number"],
    textarea,
    select,
    .form-input,
    .search-input,
    .ai-textarea {
        font-size: 16px !important;
        padding: 8px 10px !important;
    }

    h2 {
        font-size: 1.1rem !important;
    }
}

/* ============================================================================
   MOBILE KEYBOARD HANDLING - Capacitor Native Apps
   ============================================================================ */

/* Ensure body can resize when keyboard appears */
html,
body {
    height: 100%;
    overflow-x: hidden;
}

/* When keyboard is visible, adjust content */
.keyboard-visible {
    /* Class added via JavaScript when keyboard opens */
}

/* For iOS, use safe area insets */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .mobile-bottom-nav {
        padding-bottom: env(safe-area-inset-bottom);
    }

    /* Chat input areas should have bottom padding */
    .ai-chat-input-container,
    .chat-input-wrapper,
    .message-input-container {
        padding-bottom: calc(env(safe-area-inset-bottom) + 10px);
    }
}

/* AI Chat overlay - ensure input is above keyboard */
.ai-chat-overlay {
    display: flex;
    flex-direction: column;
    max-height: 100vh;
    max-height: 100dvh;
    /* Dynamic viewport height - accounts for keyboard */
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    /* Allow flex shrinking */
}

.ai-chat-input-container {
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    background: var(--card-bg, #1a1a2e);
    z-index: 10;
}

/* Ensure inputs scroll into view on focus */
input:focus,
textarea:focus,
[contenteditable="true"]:focus {
    scroll-margin-bottom: 300px;
    /* Space for keyboard */
}

/* Hide bottom nav when keyboard is visible on mobile */
@media (max-width: 768px) {
    body.keyboard-open .mobile-bottom-nav {
        display: none !important;
    }

    /* Give more space for content when keyboard is open */
    body.keyboard-open .ai-chat-overlay,
    body.keyboard-open .chat-container {
        padding-bottom: 0 !important;
    }
}

/* ============================================================================
   PERFORMANCE OPTIMIZATIONS
   GPU compositing hints, CSS containment, and content-visibility
   ============================================================================ */

/* GPU-composited backdrop-filter: promote these layers so blur doesn't
   trigger full repaint of underlying content */
.burger-drawer-backdrop,
.mobile-bottom-nav,
.desktop-top-nav,
.dropdown-menu,
.notification-dropdown,
.ai-chat-overlay,
.sync-room-header,
.overlay,
.modal-backdrop {
    will-change: transform;
    contain: layout style;
}

/* ── Scroll bleed-through prevention for ALL overlays (iOS + Android) ─────────
   overscroll-behavior:contain traps scroll inside the overlay so it never
   chains to <body>.  Combined with TSScrollLock (position:fixed on body)
   this fully prevents background scroll bleed-through.
   NOTE: Do NOT use touch-action:none here — it would prevent scrolling
   inside the overlay's own children (e.g., comments list, chat messages). */
.burger-drawer-backdrop,
.comments-modal,
.modal-overlay,
.follow-modal-overlay,
.action-sheet-overlay,
.donate-modal-overlay,
.new-msg-overlay,
.dm-call-overlay,
.dm-call-incoming,
.call-overlay,
.audience-picker-overlay,
.portal-overlay,
.filter-modal-backdrop,
.trance-overlay,
.gcall-overlay,
.sw-modal-backdrop,
.photo-lightbox,
.ai-chat-overlay,
.login-overlay,
.quick-add-overlay,
.request-popup {
    overscroll-behavior: contain;
}

/* Isolated UI components: tell the browser these are self-contained.
   Note: avoid `contain: paint` on animated elements — it clips transforms
   that extend beyond bounds (e.g., the dialog pop-in animation). */
.ts-dialog {
    contain: layout style;
}

.burger-drawer {
    contain: layout style;
}

.ts-toast-container {
    contain: layout style;
}

/* Long scrollable lists: defer rendering of off-screen items.
   content-visibility: auto lets the browser skip layout & paint for
   items outside the viewport, dramatically speeding up long feeds. */
.world-list .world-item,
.feed-item,
.entry-card,
.thought-card,
.notification-item,
.dm-conversation-item,
.suggestion-item {
    content-visibility: auto;
    contain-intrinsic-size: auto 200px;
    /* estimated height — generous to prevent scrollbar jumps */
}

/* Prevent layout shift for dynamically loaded images */
img {
    max-width: 100%;
    height: auto;
}

/* Avatar images: reserve 1:1 space to prevent CLS when loading */
.profile-avatar img,
.avatar img {
    aspect-ratio: 1 / 1;
    object-fit: cover;
    background: var(--ts-bg-input, rgba(255, 255, 255, 0.05));
}

/* Optimize animations: only promote when actually animating */
@media (prefers-reduced-motion: no-preference) {

    .burger-drawer,
    .ts-dialog,
    .dropdown-menu,
    .notification-dropdown {
        will-change: transform, opacity;
    }
}

/* Reduce paint complexity on scroll-heavy containers */
.feed-container,
.messages-list,
.chat-messages,
.entries-container,
.thoughts-list,
.notifications-list,
.conversations-list {
    contain: layout style;
}

/* ============================================================================
   SHARED COMPONENTS — Media Search & Results
   Used in dashboard.html and add-thought.html
   ============================================================================ */
.media-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--ts-bg-elevated);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--ts-border-hover);
    border-radius: var(--ts-radius-md);
    margin-top: 8px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 12px 48px var(--ts-shadow-color);
    animation: dropdownFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

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

.media-search-item,
.media-result-item {
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.2s ease;
    border-bottom: 1px solid var(--ts-divider);
}

.media-search-item:last-child,
.media-result-item:last-child {
    border-bottom: none;
}

.media-search-item:hover,
.media-result-item:hover {
    background: var(--ts-bg-input);
}

.media-search-item img,
.media-result-cover {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: var(--ts-radius-sm);
    flex-shrink: 0;
    box-shadow: 0 4px 12px var(--ts-shadow-color);
}

.media-search-item-content,
.media-result-info {
    flex: 1;
    min-width: 0;
}

.media-search-item-title,
.media-result-title {
    color: var(--ts-text-primary);
    font-weight: 600;
    font-size: var(--ts-text-title);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.media-search-item-meta,
.media-result-meta {
    color: var(--ts-text-muted);
    font-size: var(--ts-text-caption);
}

.media-search-loading,
.media-search-empty {
    padding: 30px;
    text-align: center;
    color: var(--ts-text-secondary);
    font-size: var(--ts-text-body);
}

.no-image-placeholder {
    width: 60px;
    height: 60px;
    background: var(--ts-bg-subtle);
    border-radius: var(--ts-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ts-text-faint);
    font-size: 0.7rem;
    text-align: center;
    line-height: 1.2;
}