:root {
    --bg-color: #343541;
    --sidebar-bg: #202123;
    --input-bg: #40414f;
    --text-primary: #ececf1;
    --text-secondary: #c5c5d2;
    --user-msg-bg: #343541;
    --ai-msg-bg: #444654;
    --accent: #10a37f;
    --border: #565869;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    height: 100vh;
    /* overflow: hidden; Removed to allow panning/scrolling on mobile if zoomed */
    transition: background-color 0.3s, color 0.3s;
}

/* Light Theme Overrides */
[data-theme="light"] {
    --bg-color: #ffffff;
    --sidebar-bg: #f7f7f8;
    --input-bg: #ffffff;
    --text-primary: #343541;
    --text-secondary: #6e6e80;
    --user-msg-bg: #ffffff;
    --ai-msg-bg: #f7f7f8;
    --border: #d9d9e3;
}

/* Specific Light Theme Adjustments */
[data-theme="light"] {
    --bg-color: #ffffff;
    --sidebar-bg: #f7f7f8;
    --input-bg: #ffffff;
    --text-primary: #343541;
    --text-secondary: #6e6e80;
    --user-msg-bg: #ffffff;
    --ai-msg-bg: #f7f7f8;
    --border: #d9d9e3;
}

[data-theme="light"] .input-wrapper {
    background: #ffffff;
    border: 1px solid var(--border);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
[data-theme="light"] textarea {
    color: var(--text-primary);
}
[data-theme="light"] .modal-panel,
[data-theme="light"] .users-panel {
    background: #ffffff;
    border: 1px solid var(--border);
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
}
[data-theme="light"] .language-list-scroll {
    background: #f9f9f9;
    border: 1px solid var(--border);
}
[data-theme="light"] .language-item:hover {
    background: rgba(0,0,0,0.05);
}
[data-theme="light"] .persona-item:hover {
    background: rgba(16,163,127,0.08);
}
[data-theme="light"] .message-row {
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

/* Make language search input white with dark text in light theme */
[data-theme="light"] #language-search {
    background: #ffffff !important;
    color: #000000 !important;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px;
}

/* Placeholder color for the language search input in light theme */
[data-theme="light"] #language-search::placeholder {
    color: #6e6e80;
}

/* Intro Screen */
#intro-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

#intro-text-container {
    text-align: center;
    margin-bottom: 3rem;
}

#intro-text {
    font-size: 3.2rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.02em;
    opacity: 0;
    animation: fadeInText 0.9s ease-in forwards;
    margin-bottom: 0.25rem;
    text-align: center;
}

/* Subtitle shown after the main headline */
#intro-subtitle {
    font-size: 1.05rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.85);
    opacity: 0;
    animation: fadeInText 0.9s ease-in 0.9s forwards;
}

#intro-media-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 300px;
    height: 300px;
}

#intro-logo {
    width: 200px;
    opacity: 0;
    position: absolute;
    z-index: 2;
}

#intro-explosion {
    position: absolute;
    width: 300px;
    height: 300px;
    opacity: 0;
    pointer-events: none;
    z-index: 1;
}

@keyframes fadeInText {
    0% {
        opacity: 0;
        transform: translateY(-20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

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

#app-container {
    display: flex;
    height: 100%;
    width: 100%;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    border-right: 1px solid #4d4d4f;
}

.sidebar-header h2 {
    font-size: 1rem;
    margin-bottom: 5px;
}

.status-badge {
    font-size: 0.7rem;
    background: var(--accent);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-block;
}

.stats-container {
    background: rgba(255,255,255,0.05);
    padding: 10px;
    border-radius: 6px;
}

.stat-item {
    margin-bottom: 10px;
}

.stat-item label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.secondary-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: auto;
}

.secondary-btn:hover {
    background: var(--input-bg);
}

/* Chat Interface */
.chat-interface {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background-color: var(--bg-color);
}

.chat-header {
    padding: 10px 20px;
    border-bottom: 1px solid rgba(0,0,0,0.1);
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.messages-scroll {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 20px;
}

.message-row {
    display: flex;
    padding: 20px;
    gap: 15px;
    border-bottom: 1px solid rgba(0,0,0,0.1);
}

.message-row.ai {
    background-color: var(--ai-msg-bg); /* This is YOU (The Player) */
}

.message-row.user {
    background-color: var(--user-msg-bg); /* This is the Human (Bot) */
}

.avatar {
    width: 30px;
    height: 30px;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
}

.ai .avatar {
    background-color: transparent;
    color: white;
}

.user .avatar {
    background-color: #8e8ea0; /* Generic human color */
    color: white;
}

.message-content {
    line-height: 1.6;
    font-size: 1rem;
    max-width: 800px;
    min-width: 0; /* Fix flexbox overflow for code blocks */
    overflow-wrap: break-word; /* Prevent text blowout */
}

/* Bold and Action/Italic Text Styling */
.message-content strong,
.message-content b,
.message-content em,
.message-content i {
    font-weight: 600; /* Bolded as requested */
    color: #ffffff;   /* White as requested */
}

.message-content em,
.message-content i {
    font-style: italic;
}

[data-theme="light"] .message-content strong,
[data-theme="light"] .message-content b,
[data-theme="light"] .message-content em,
[data-theme="light"] .message-content i {
    color: #000000; /* Use black for visibility in light mode */
}

.file-attachment {
    background: rgba(0,0,0,0.2);
    padding: 8px 12px;
    border-radius: 6px;
    margin: 8px 0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(255,255,255,0.1);
}

.file-attachment svg {
    flex-shrink: 0;
}

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

.typing-indicator {
    padding: 10px 20px;
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.8rem;
}

/* Input Area */
.input-area {
    padding: 20px;
    background: linear-gradient(180deg, rgba(53,53,65,0), var(--bg-color) 20%);
}

.input-wrapper {
    background-color: var(--input-bg);
    border-radius: 12px;
    padding: 10px 15px;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    box-shadow: 0 0 15px rgba(0,0,0,0.1);
    border: 1px solid rgba(0,0,0,0.1);
}

textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    font-family: inherit;
    font-size: 1rem;
    resize: none;
    max-height: 200px;
    outline: none;
}

#upload-btn,
#mic-btn,
#send-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    flex-shrink: 0;
}

#upload-btn:hover,
#send-btn:hover {
    background: rgba(0,0,0,0.2);
    color: var(--accent);
}

/* Mic recording state */
#mic-btn.recording {
    color: white;
    background: linear-gradient(90deg, rgba(16,163,127,0.14), rgba(16,163,127,0.06));
    box-shadow: 0 4px 12px rgba(16,163,127,0.12);
    transform: scale(1.03);
}

/* small pulsing indicator while recording */
#mic-btn.recording::after {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    margin-left: 6px;
    box-shadow: 0 0 8px rgba(16,163,127,0.6);
}

/* footer */
.footer-text {
    text-align: center;
    font-size: 0.7rem;
    color: #666;
    margin-top: 10px;
}

.system-message {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Form Styles for Modal */
.form-group {
    margin-bottom: 15px;
}
.avatar-type-toggle {
    display: flex;
    gap: 10px;
    margin-bottom: 8px;
}
.avatar-type-toggle .secondary-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* Community Light Mode Overrides */
[data-theme="light"] #community-page {
    background-color: #ffffff;
    color: #1a1a1a;
}
[data-theme="light"] #community-loader {
    background: #ffffff;
    color: #1a1a1a;
}
[data-theme="light"] .loader-spinner {
    border-color: rgba(0,0,0,0.1);
    border-left-color: #10a37f;
}
[data-theme="light"] .community-header {
    background: #ffffff;
    border-bottom: 1px solid #e5e5e5;
}
[data-theme="light"] #community-title {
    color: #1a1a1a;
}
[data-theme="light"] #community-search-input {
    background: #f4f4f5;
    border: 1px solid #e5e5e5;
    color: #1a1a1a;
}
[data-theme="light"] .upload-section-container,
[data-theme="light"] .post-card,
[data-theme="light"] .profile-header-card {
    background: #ffffff;
    border: 1px solid #e5e5e5;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
[data-theme="light"] .post-author,
[data-theme="light"] .comment-author {
    color: #1a1a1a;
}
[data-theme="light"] .post-desc,
[data-theme="light"] .post-time,
[data-theme="light"] .action-btn,
[data-theme="light"] .users-section-title {
    color: #666;
}
[data-theme="light"] .comm-input,
[data-theme="light"] .comment-input {
    background: #f4f4f5;
    border: 1px solid #e5e5e5;
    color: #1a1a1a;
}
[data-theme="light"] .comment-bubble {
    background: #f4f4f5;
    color: #1a1a1a;
}
[data-theme="light"] .comment-text {
    color: #1a1a1a;
}
[data-theme="light"] .icon-btn {
    border-color: #e5e5e5;
    color: #333;
}
[data-theme="light"] .icon-btn:hover {
    background: #f4f4f5;
}
[data-theme="light"] #community-back-btn {
    border-color: #e5e5e5;
    color: #333;
}
[data-theme="light"] #community-back-btn:hover {
    background: #f4f4f5;
}
[data-theme="light"] .post-actions {
    border-top-color: #f0f0f0;
}
[data-theme="light"] .comments-section {
    border-top-color: #f0f0f0;
}
[data-theme="light"] .replies-container {
    border-left-color: #e5e5e5;
}
[data-theme="light"] #upload-toggle-btn {
    color: #1a1a1a;
    border-color: #e5e5e5;
}
[data-theme="light"] #upload-form-body h3,
[data-theme="light"] .upload-header-row h3 {
    color: #1a1a1a;
}

/* Mobile Tweaks */
@media (max-width: 768px) {
    .sidebar {
        display: none; /* Simple hide for now */
    }
    
    .message-row {
        padding: 15px;
    }
    
    .input-area {
        padding: 10px;
    }
}

/* Top Controls Bar */
.top-controls-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background-color: var(--bg-color);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    min-height: 50px;
}

.top-controls-bar .secondary-btn {
    margin-top: 0;
    padding: 6px 12px;
    font-size: 0.85rem;
}

/* Control Group for Hideable Buttons */
.control-group {
    display: flex;
    align-items: center;
    gap: 4px;
    position: relative;
}

/* Invisible placeholder that restores hidden buttons */
.ghost-btn {
    opacity: 0;
    cursor: pointer;
    user-select: none;
    /* Basic button reset to match dimensions */
    padding: 10px; 
    border: 1px solid transparent; 
    background: transparent;
    color: transparent;
    border-radius: 4px;
    margin-top: auto; /* Match secondary-btn alignment */
}

/* Support Modal & Buttons */

/* Users modal (select persona) */
.users-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 11000;
}
.users-modal .backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(2px);
}
.users-panel {
    position: relative;
    width: min(520px, 94%);
    max-height: 80vh;
    overflow: auto;
    background: #1f1f23;
    border-radius: 12px;
    padding: 12px;
    color: var(--text-primary);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    z-index: 2;
}
.users-panel h3 {
    margin: 6px 0 12px 0;
    font-size: 1.05rem;
}
.users-sections-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.users-section-title {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.persona-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
}
.persona-item {
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.04);
    padding: 10px;
    border-radius: 8px;
    display: flex;
    gap: 10px;
    align-items: center;
    cursor: pointer;
    transition: transform 0.12s ease, background 0.12s;
}
.persona-item:hover {
    transform: translateY(-4px);
    background: rgba(16,163,127,0.06);
}
.persona-emoji {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    background: rgba(255,255,255,0.03);
    border-radius: 6px;
}
.persona-meta {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}
.persona-actions {
    display: flex;
    gap: 4px;
    margin-left: 5px;
}
.persona-action-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-secondary);
    border-radius: 4px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}
.persona-action-btn:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text-primary);
}
.persona-action-btn.delete:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border-color: #ef4444;
}
.create-user-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
}
.persona-name {
    font-weight: 600;
    color: var(--text-primary);
}
.persona-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.users-close {
    position: absolute;
    right: 10px;
    top: 8px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
}

/* Follow modal link styling: make links clearly blue and clickable */
#follow-modal a {
    color: #1a73e8;
    text-decoration: underline;
    word-break: break-all;
    font-size: 0.95rem;
}
#follow-modal a:hover {
    color: #1558b0;
    text-decoration: underline;
}

/* Small inline close button next to the Support/Follow button */
.support-close-btn {
    /* margin-left handled by gap in control-group */
    background: transparent;
    border: 1px solid rgba(255,255,255,0.06);
    color: var(--text-secondary);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0;
    transition: background 0.15s, color 0.15s, transform 0.08s;
}

/* hover / active states */
.support-close-btn:hover {
    background: rgba(255,255,255,0.03);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.support-close-btn:active {
    transform: translateY(0);
}

/* hide when support button is hidden to avoid orphan control */
.support-close-btn[style*="display: none"] {
    display: none !important;
}

.primary-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
}

.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(2px);
}

.modal-panel {
    position: relative;
    width: min(420px, 92%);
    background: #1f1f23;
    border-radius: 12px;
    padding: 18px;
    color: var(--text-primary);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    z-index: 2;
}

.modal-panel h3 {
    margin-bottom: 12px;
    font-size: 1.1rem;
}

.modal-close {
    position: absolute;
    right: 10px;
    top: 8px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
}

.tip-section .label,
.donation-section .label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.tip-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 6px;
}

#tip-amount {
    width: 120px;
    padding: 8px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-primary);
}

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

.secondary-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: auto;
}

.secondary-btn:hover {
    background: var(--input-bg);
}

/* Simple markdown parsing for code blocks (visual flair) */
.code-wrapper {
    position: relative;
    max-width: 100%;
    min-width: 0;
    margin-bottom: 8px;
}

/* Force black background + white monospace text for ALL code blocks in messages, posts, comments, personas, and editors */
pre,
code,
pre code,
.message-row pre,
.message-row code,
.message-row pre code,
.message-row .message-content pre,
.message-row .message-content code,
.post-desc pre,
.post-desc code,
.comment-bubble pre,
.comment-bubble code,
.persona-desc pre,
.persona-desc code,
.code-wrapper pre,
.code-wrapper code {
    background-color: #000000 !important;
    color: #ffffff !important;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, "Roboto Mono", "Helvetica Neue", monospace !important;
}

pre {
    padding: 12px;
    border-radius: 8px;
    display: block;
    overflow-x: auto;
    max-width: 100%;
    white-space: pre;
    border: 1px solid rgba(255,255,255,0.1);
    font-size: 0.9rem;
    line-height: 1.4;
}

/* Inline code styling specifically */
:not(pre) > code {
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 0.9em;
}

/* Ensure nested code inherits the black background */
pre code {
    background-color: transparent !important;
    color: #ffffff !important;
    padding: 0 !important;
    border: none !important;
    display: inline !important;
}

/* Extra specificity for code blocks rendered inside user/persona messages to override inline/theme styles */
.message-row.user pre,
.message-row.ai pre,
.message-row.user code,
.message-row.ai code {
    background-color: #000000 !important;
    color: #ffffff !important;
}

/* Keep editing outline but preserve black background when editing */
pre.editing {
    outline: 2px solid rgba(16,163,127,0.12);
    background: #000 !important;
    color: #fff !important;
}

/* Make sure light theme doesn't override code block colors */
[data-theme="light"] pre,
[data-theme="light"] .message-row pre,
[data-theme="light"] .post-desc pre,
[data-theme="light"] .comment-bubble pre {
    background: #000 !important;
    color: #fff !important;
}

/* Toolbar shown at top-right of code blocks to copy/edit */
.code-toolbar {
    display: flex;
    gap: 8px;
    position: relative;
    justify-content: flex-end;
    margin-bottom: 6px;
}

.code-toolbar button {
    background: rgba(255,255,255,0.04);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.06);
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    line-height: 1;
}

.code-toolbar button:hover {
    background: rgba(255,255,255,0.08);
    transform: translateY(-1px);
}

/* When editing, show a subtle outline */
pre.editing {
    outline: 2px solid rgba(16,163,127,0.12);
}

/* Settings Modal & Language List */
.settings-header-row {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 5px;
    padding-right: 30px; /* Space for close button */
}

#theme-toggle-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

#theme-toggle-btn:hover {
    background: var(--input-bg);
    border-color: var(--accent);
    color: var(--accent);
}

.settings-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.4;
}

.settings-section {
    margin-top: 10px;
}

.full-width {
    width: 100%;
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.full-width::after {
    content: '›';
    font-size: 1.2rem;
    line-height: 0;
}

.language-list-scroll {
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 6px;
    padding: 10px;
    background: rgba(0,0,0,0.2);
}

.language-item {
    padding: 8px 12px;
    background: rgba(255,255,255,0.03);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.1s;
    text-align: left;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
}

.language-item:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.1);
}

.language-item.active {
    background: var(--accent);
    color: white;
}

/* Saved Chats Styles */
.saved-chat-item {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 6px;
    padding: 8px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}
.saved-chat-item:hover {
    background: rgba(255,255,255,0.06);
}
.saved-chat-info {
    flex: 1;
    min-width: 0;
    margin-right: 10px;
}
.saved-chat-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.saved-chat-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
}
.saved-chat-actions {
    display: flex;
    gap: 6px;
}
.chat-action-btn {
    padding: 4px 8px;
    font-size: 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-primary);
}
.chat-action-btn.load:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}
.chat-action-btn.delete:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border-color: #ef4444;
}
[data-theme="light"] .saved-chat-item {
    background: #f9f9f9;
    border-color: #e5e5e5;
}
[data-theme="light"] .saved-chat-item:hover {
    background: #f0f0f0;
}

.lang-flag {
    margin-right: 12px;
    font-size: 1.4em;
    line-height: 1;
    flex-shrink: 0;
}

/* Ensure settings button fits nicely */
#settings-btn {
    margin-right: 4px;
}

/* Community Page Styles */
#community-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #1f1f23; /* Dark background as requested */
    color: white; /* White text as requested */
    z-index: 5000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.community-header {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    background: #2b2c31;
    border-bottom: 1px solid #40414f;
    gap: 15px;
}

#community-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-right: auto;
}

.community-search {
    flex: 1;
    max-width: 400px;
}

#community-search-input {
    width: 100%;
    background: #40414f;
    border: 1px solid #565869;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
}

.community-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

/* Upload Section */
.upload-section-container {
    background: #2b2c31;
    border-radius: 8px;
    border: 1px solid #40414f;
    padding: 15px;
    margin-bottom: 25px;
    transition: all 0.3s ease;
}

.upload-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.upload-header-row h3 {
    font-size: 1rem;
    font-weight: 600;
}

.upload-buttons {
    display: flex;
    gap: 10px;
}

.comm-input {
    width: 100%;
    background: #40414f;
    border: 1px solid #565869;
    color: white;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 10px;
    font-family: inherit;
}

.full-width-btn {
    width: 100%;
    margin-top: 10px;
    font-weight: 600;
}

/* Feed Items */
.post-card {
    background: #2b2c31;
    border-radius: 8px;
    border: 1px solid #40414f;
    padding: 15px;
    margin-bottom: 20px;
}

.post-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    cursor: pointer;
}

.post-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.post-meta {
    display: flex;
    flex-direction: column;
}

.post-author {
    font-weight: 600;
    color: white;
}

.post-time {
    font-size: 0.8rem;
    color: #9ca3af;
}

.post-media {
    width: 100%;
    border-radius: 6px;
    margin-bottom: 12px;
    background: #000;
    max-height: 500px;
    object-fit: contain;
}

.post-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.post-desc {
    font-size: 0.95rem;
    color: #d1d5db;
    margin-bottom: 15px;
    line-height: 1.5;
}

.persona-feed-card {
    background: rgba(255,255,255,0.05);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 12px;
    display: flex;
    gap: 15px;
    align-items: center;
}
[data-theme="light"] .persona-feed-card {
    background: #f4f4f5;
    border: 1px solid #e5e5e5;
}

.post-actions {
    display: flex;
    gap: 15px;
    padding-top: 10px;
    border-top: 1px solid #40414f;
}

.action-btn {
    background: transparent;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.action-btn:hover {
    color: white;
}

.action-btn.active {
    color: #10a37f; /* Green accent */
}

.action-btn.dislike-active {
    color: #ef4444; /* Red accent */
}

/* Comments */
.comments-section {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #40414f;
}

.comment-input-row {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.comment-input {
    flex: 1;
    background: #40414f;
    border: 1px solid #565869;
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
}

.comment-item {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

.comment-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.comment-body {
    flex: 1;
}

.comment-bubble {
    background: #343541;
    padding: 8px 12px;
    border-radius: 12px;
    display: inline-block;
}

.comment-author {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.comment-text {
    font-size: 0.95rem;
    color: #ececf1;
}

.comment-actions {
    display: flex;
    gap: 12px;
    margin-top: 4px;
    margin-left: 4px;
    font-size: 0.8rem;
    color: #9ca3af;
}

.comment-action {
    cursor: pointer;
}

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

.replies-container {
    margin-left: 42px;
    margin-top: 8px;
    border-left: 2px solid #40414f;
    padding-left: 10px;
}

.reply-input-box {
    margin-top: 8px;
    display: flex;
    gap: 8px;
}

.delete-btn {
    color: #ef4444;
}

/* Loader */
#community-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #1f1f23;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 6000;
}

.loader-spinner {
    border: 4px solid rgba(255,255,255,0.1);
    border-left-color: #10a37f;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Profile View */
.profile-header-card {
    background: #2b2c31;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    text-align: center;
}

.profile-lg-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin-top: 15px;
    border: 3px solid #10a37f;
}

.collapsed-upload {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.collapsed-upload .upload-buttons,
.collapsed-upload .upload-header-row h3,
.collapsed-upload #upload-form-body {
    display: none !important;
}

.collapsed-upload .upload-header-row {
    margin: 0;
    width: 100%;
    height: 100%;
    justify-content: center;
}

/* Back button (community page) */
#community-back-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.06);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s, transform 0.08s;
}
#community-back-btn:hover {
    background: rgba(255,255,255,0.02);
    transform: translateY(-2px);
}
#community-back-btn:active {
    transform: translateY(0);
}

/* Generic icon button (used for up/down arrows and similar controls) */
.icon-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.04);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.12s, transform 0.06s, border-color 0.12s;
}
.icon-btn:hover {
    background: rgba(255,255,255,0.03);
    border-color: rgba(255,255,255,0.08);
    transform: translateY(-2px);
}
.icon-btn:active {
    transform: translateY(0);
}

/* Specific Upload Toggle (up / down arrow) */
#upload-toggle-btn.icon-btn {
    width: 44px;
    height: 44px;
    padding: 6px;
}

/* Visual states for explicit up / down affordance */
#upload-toggle-btn svg {
    transition: transform 0.18s ease, opacity 0.12s;
}

/* When collapsed, slightly emphasize the button */
.collapsed-upload #upload-toggle-btn {
    width: 44px;
    height: 44px;
    background: linear-gradient(180deg, rgba(16,163,127,0.06), rgba(16,163,127,0.03));
    border: 1px solid rgba(16,163,127,0.12);
}

/* Optional utility classes to rotate arrow icons when used */
.icon-rotate-180 {
    transform: rotate(180deg);
}

/* small responsive tweak so icons keep tappable size on mobile */
@media (max-width: 480px) {
    #community-back-btn,
    .icon-btn,
    #upload-toggle-btn {
        width: 44px;
        height: 44px;
    }
}
