/* --- Dark theme (default) --- */
:root, [data-theme="dark"] {
    --primary: #6366F1;
    --primary-dark: #4F46E5;
    --primary-light: #818CF8;
    --primary-glow: rgba(99, 102, 241, 0.3);
    --accent: #F59E0B;
    --accent-dark: #D97706;
    --accent-light: #FCD34D;
    --bg: #0F1117;
    --bg-secondary: #161822;
    --surface: #1E2030;
    --surface-hover: #252840;
    --surface-border: rgba(255,255,255,0.06);
    --glass: rgba(30, 32, 48, 0.8);
    --glass-border: rgba(255,255,255,0.08);
    --text: #F1F5F9;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    --border: rgba(255,255,255,0.08);
    --success: #10B981;
    --success-bg: rgba(16, 185, 129, 0.12);
    --danger: #EF4444;
    --danger-bg: rgba(239, 68, 68, 0.12);
    --warning: #F59E0B;
    --warning-bg: rgba(245, 158, 11, 0.12);
    --radius: 12px;
    --radius-lg: 16px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --code-bg: rgba(255,255,255,0.08);
    --scrollbar-thumb: rgba(255,255,255,0.1);
    --scrollbar-hover: rgba(255,255,255,0.2);
    --login-gradient-1: rgba(99,102,241,0.15);
    --login-gradient-2: rgba(245,158,11,0.1);
    --select-arrow: %2364748B;
    --toggle-bg: var(--surface-hover);
    --toggle-knob: var(--text-muted);
    --disabled-opacity: 0.5;
}

/* --- Light theme --- */
[data-theme="light"] {
    --primary: #4F46E5;
    --primary-dark: #4338CA;
    --primary-light: #6366F1;
    --primary-glow: rgba(79, 70, 229, 0.2);
    --accent: #D97706;
    --accent-dark: #B45309;
    --accent-light: #F59E0B;
    --bg: #F5F7FA;
    --bg-secondary: #FFFFFF;
    --surface: #FFFFFF;
    --surface-hover: #F1F5F9;
    --surface-border: rgba(0,0,0,0.06);
    --glass: rgba(255, 255, 255, 0.9);
    --glass-border: rgba(0,0,0,0.08);
    --text: #111827;
    --text-secondary: #4B5563;
    --text-muted: #9CA3AF;
    --border: rgba(0,0,0,0.1);
    --success: #059669;
    --success-bg: rgba(5, 150, 105, 0.08);
    --danger: #DC2626;
    --danger-bg: rgba(220, 38, 38, 0.08);
    --warning: #D97706;
    --warning-bg: rgba(217, 119, 6, 0.08);
    --shadow: 0 4px 24px rgba(0,0,0,0.08);
    --code-bg: rgba(0,0,0,0.05);
    --scrollbar-thumb: rgba(0,0,0,0.15);
    --scrollbar-hover: rgba(0,0,0,0.25);
    --login-gradient-1: rgba(79,70,229,0.08);
    --login-gradient-2: rgba(217,119,6,0.06);
    --select-arrow: %239CA3AF;
    --toggle-bg: #E5E7EB;
    --toggle-knob: #9CA3AF;
    --disabled-opacity: 0.6;
}

/* Light theme overrides for gradients that can't use variables */
[data-theme="light"] .sidebar-header h2 {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
[data-theme="light"] .login-card h1,
[data-theme="light"] .register-card h1 {
    background: linear-gradient(135deg, var(--text), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
[data-theme="light"] .message.user .message-bubble {
    color: white;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover); }

/* --- Modal --- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}
.modal-overlay.show { display: flex; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-box {
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 28px;
    max-width: 420px;
    width: 90%;
    box-shadow: var(--shadow);
    animation: slideUp 0.25s ease;
}

.modal-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    font-size: 22px;
}
.modal-icon.warning { background: var(--warning-bg); }
.modal-icon.error { background: var(--danger-bg); }
.modal-icon.success { background: var(--success-bg); }
.modal-icon.info { background: rgba(99,102,241,0.12); }

.modal-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}

.modal-message {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* --- Login Page --- */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
    background-image:
        radial-gradient(ellipse at 20% 50%, var(--login-gradient-1) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, var(--login-gradient-2) 0%, transparent 50%);
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 48px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow);
}

.login-card h1 {
    font-size: 24px;
    margin-bottom: 8px;
    text-align: center;
    background: linear-gradient(135deg, var(--text), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-card .subtitle {
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 32px;
    font-size: 14px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--text);
    outline: none;
    transition: all var(--transition);
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-group input::placeholder, .form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2394A3B8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-group select option {
    background: var(--surface);
    color: var(--text);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    gap: 6px;
}

.btn-primary {
    background: var(--primary);
    color: white;
    width: 100%;
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 16px var(--primary-glow); }

.btn-danger {
    background: var(--danger-bg);
    color: var(--danger);
    padding: 6px 12px;
    font-size: 13px;
    border: 1px solid rgba(239,68,68,0.2);
}
.btn-danger:hover { background: rgba(239,68,68,0.2); }

.btn-secondary {
    background: var(--surface-hover);
    color: var(--text-secondary);
    padding: 6px 12px;
    font-size: 13px;
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: rgba(255,255,255,0.08); color: var(--text); }

.error-msg {
    background: var(--danger-bg);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
    border: 1px solid rgba(239,68,68,0.2);
}

/* --- Chat Layout --- */
.app-layout {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    font-size: 18px;
    background: linear-gradient(135deg, var(--primary-light), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 700;
}

.sidebar-header .team-name {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.sidebar-nav {
    padding: 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    margin-bottom: 4px;
    cursor: pointer;
    transition: all var(--transition);
}

.nav-item:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.nav-item.active {
    background: rgba(99,102,241,0.12);
    color: var(--primary-light);
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.sidebar-footer a {
    font-size: 13px;
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition);
}
.sidebar-footer a:hover { color: var(--danger); }

/* --- Main Content --- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background: var(--bg);
}

.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    display: flex;
    gap: 12px;
    max-width: 80%;
    animation: slideUp 0.3s ease;
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
    letter-spacing: -0.5px;
}

.message.assistant .message-avatar {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.message.user .message-avatar {
    background: var(--surface-hover);
    color: var(--text-secondary);
}

.message-bubble {
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    line-height: 1.6;
}

.message.assistant .message-bubble {
    background: var(--surface);
    border: 1px solid var(--border);
}

.message.user .message-bubble {
    background: var(--primary);
    color: white;
}

.message-bubble p { margin-bottom: 8px; }
.message-bubble p:last-child { margin-bottom: 0; }
.message-bubble ul, .message-bubble ol { margin: 8px 0 8px 20px; }
.message-bubble code {
    background: var(--code-bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}
.message-bubble strong { font-weight: 600; }

.typing-indicator {
    display: none;
    align-self: flex-start;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text-muted);
    font-size: 14px;
    animation: pulse 1.5s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.typing-indicator.show { display: block; }

/* --- Chat Input --- */
.chat-input-area {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

.chat-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.chat-input-wrapper textarea {
    flex: 1;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    resize: none;
    outline: none;
    min-height: 48px;
    max-height: 120px;
    transition: all var(--transition);
}

.chat-input-wrapper textarea::placeholder { color: var(--text-muted); }

.chat-input-wrapper textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.send-btn {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    width: 48px;
    height: 48px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}
.send-btn:hover { background: var(--primary-dark); box-shadow: 0 4px 16px var(--primary-glow); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* --- Social Post Generator Panel --- */
.post-generator {
    display: none;
    flex: 1;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}
.post-generator.active { display: flex; }
.chat-container { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }
.chat-container.hidden { display: none; }

.post-form {
    padding: 24px;
    flex: 1;
    overflow-y: auto;
}

.post-output {
    margin-top: 20px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    font-size: 14px;
    line-height: 1.7;
    white-space: pre-wrap;
    display: none;
    color: var(--text);
}
.post-output.show { display: block; }

.copy-btn {
    margin-top: 8px;
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(16,185,129,0.2);
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition);
}
.copy-btn:hover { background: rgba(16,185,129,0.2); }

/* --- Admin Page --- */
.admin-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 32px 24px;
    overflow-y: auto;
    height: 100vh;
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
}
.admin-header h1 { font-size: 24px; }

.stats-row {
    display: flex;
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    flex: 1;
    text-align: center;
}

.stat-card .number {
    font-size: 32px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-light), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stat-card .label {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

.section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
}

.section h2 {
    font-size: 18px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.doc-list, .user-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.doc-item, .user-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.doc-item .doc-info, .user-item .user-info-row { flex: 1; }
.doc-item .doc-title, .user-item .user-name { font-weight: 500; font-size: 14px; }
.doc-item .doc-meta, .user-item .user-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.upload-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.tab-buttons {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.tab-btn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    transition: all var(--transition);
}
.tab-btn:hover { background: var(--surface-hover); }
.tab-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.text-entry-form {
    display: none;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.text-entry-form.show { display: flex; }
.upload-form.hidden { display: none; }

/* --- Mobile bottom nav bar --- */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    z-index: 100;
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.mobile-nav-items {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 56px;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 12px;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: color var(--transition);
    text-decoration: none;
    border: none;
    background: none;
}

.mobile-nav-item span:first-child {
    font-size: 20px;
    line-height: 1;
}

.mobile-nav-item.active {
    color: var(--primary-light);
}

/* --- Mobile header bar --- */
.mobile-header {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.mobile-header h2 {
    font-size: 16px;
    background: linear-gradient(135deg, var(--primary-light), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 700;
}

.mobile-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* --- Responsive: Tablet --- */
@media (max-width: 768px) {
    .sidebar { width: 200px; }
    .message { max-width: 95%; }
    .stats-row { flex-direction: column; }
    .chat-messages { padding: 16px; }
    .post-form { padding: 16px; }
    .profile-form { padding: 16px; }
    .chat-header { padding: 12px 16px; }
    .chat-input-area { padding: 12px 16px; }
}

/* --- Responsive: Mobile --- */
@media (max-width: 600px) {
    .sidebar { display: none; }
    .mobile-nav { display: block; }
    .mobile-header { display: flex; }

    .app-layout { flex-direction: column; }

    .main-content {
        padding-bottom: 56px; /* space for bottom nav */
    }

    .login-card { margin: 16px; padding: 24px; }
    .register-card { margin: 16px; padding: 24px; }

    .chat-header h3 { font-size: 14px; }
    .chat-messages { padding: 12px; gap: 12px; }
    .message { max-width: 92%; }
    .message-avatar { width: 30px; height: 30px; font-size: 10px; }
    .message-bubble { padding: 10px 12px; font-size: 13px; }

    .chat-input-area { padding: 10px 12px; }
    .chat-input-wrapper textarea { padding: 10px 12px; min-height: 42px; font-size: 14px; }
    .send-btn { width: 42px; height: 42px; border-radius: 10px; }

    .post-form { padding: 16px; }
    .post-tips { padding: 12px; font-size: 12px; }
    .post-tips h4 { font-size: 13px; }

    .suggestion-chip { padding: 4px 10px; font-size: 11px; }
    .topic-suggestions { gap: 4px; }

    .platform-info { padding: 10px 12px; font-size: 12px; }

    .profile-form { padding: 16px; max-width: 100%; }

    .replicated-link-box { flex-direction: column; align-items: stretch; gap: 8px; }
    .replicated-link-box .copy-link-btn { text-align: center; }

    .reminder-banner { flex-direction: column; gap: 8px; padding: 10px 16px; font-size: 13px; }
    .reminder-banner .btn-banner { align-self: flex-start; }

    .form-row { flex-direction: column; gap: 0; }

    .modal-box { margin: 16px; padding: 20px; }

    /* Admin page mobile */
    .admin-container { padding: 16px; }
    .admin-header { flex-direction: column; gap: 12px; align-items: flex-start; }
    .admin-header h1 { font-size: 20px; }
    .stat-card { padding: 14px; }
    .stat-card .number { font-size: 24px; }
    .section { padding: 16px; }
    .section h2 { font-size: 16px; }
    .doc-item { flex-direction: column; align-items: flex-start; gap: 8px; padding: 10px 12px; }
    .tab-buttons { flex-wrap: wrap; }
}

/* --- Accent button --- */
.btn-accent {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    width: 100%;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.btn-accent:hover {
    box-shadow: 0 4px 20px var(--primary-glow);
    transform: translateY(-1px);
}

/* --- Login page secondary link --- */
.login-toggle {
    text-align: center;
    margin-top: 16px;
    font-size: 14px;
    color: var(--text-muted);
}
.login-toggle a {
    color: var(--primary-light);
    text-decoration: none;
    font-weight: 500;
}
.login-toggle a:hover { text-decoration: underline; }

/* --- Registration form --- */
.register-card {
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 48px;
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow);
}
.register-card h1 {
    font-size: 24px;
    margin-bottom: 8px;
    text-align: center;
    background: linear-gradient(135deg, var(--text), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.register-card .subtitle {
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 32px;
    font-size: 14px;
}
.success-msg {
    background: var(--success-bg);
    color: var(--success);
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
    border: 1px solid rgba(16,185,129,0.2);
}
.form-row {
    display: flex;
    gap: 12px;
}
.form-row .form-group { flex: 1; }

/* --- Zinzino ID Reminder Banner --- */
.reminder-banner {
    background: linear-gradient(90deg, rgba(245,158,11,0.12), rgba(245,158,11,0.06));
    border-bottom: 1px solid rgba(245,158,11,0.2);
    padding: 10px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    color: var(--accent-light);
}
.reminder-banner .banner-text {
    display: flex;
    align-items: center;
    gap: 8px;
}
.reminder-banner .btn-banner {
    background: var(--accent);
    color: var(--bg);
    border: none;
    padding: 6px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all var(--transition);
}
.reminder-banner .btn-banner:hover { background: var(--accent-dark); }

/* --- Profile / Settings Panel --- */
.profile-panel {
    display: none;
    flex: 1;
    flex-direction: column;
}
.profile-panel.active { display: flex; }
.profile-form {
    padding: 24px;
    max-width: 560px;
}

.replicated-link-box {
    background: var(--success-bg);
    border: 1px solid rgba(16,185,129,0.2);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-top: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.replicated-link-box .link-url {
    font-size: 14px;
    font-weight: 500;
    color: var(--success);
    word-break: break-all;
}
.replicated-link-box .copy-link-btn {
    background: var(--success);
    color: white;
    border: none;
    padding: 6px 14px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
    transition: all var(--transition);
}
.replicated-link-box .copy-link-btn:hover { opacity: 0.85; }

.no-link-msg {
    background: var(--warning-bg);
    border: 1px solid rgba(245,158,11,0.2);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-top: 12px;
    font-size: 14px;
    color: var(--accent-light);
}

/* --- Post Generator Improvements --- */
.platform-info {
    background: rgba(99,102,241,0.08);
    border: 1px solid rgba(99,102,241,0.15);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-top: 8px;
    font-size: 13px;
    color: var(--primary-light);
    line-height: 1.5;
}

.post-tips {
    background: rgba(99,102,241,0.06);
    border: 1px solid rgba(99,102,241,0.12);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 20px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
}
.post-tips h4 {
    font-size: 14px;
    margin-bottom: 8px;
    color: var(--primary-light);
}
.post-tips ul {
    margin: 0;
    padding-left: 18px;
}
.post-tips li { margin-bottom: 4px; }

/* Topic suggestions */
.topic-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-bottom: 8px;
}
.suggestion-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-right: 4px;
}
.suggestion-chip {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 5px 14px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    font-weight: 500;
}
.suggestion-chip:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 2px 12px var(--primary-glow);
    transform: translateY(-1px);
}

/* --- Toggle switch for include link --- */
.toggle-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--toggle-bg);
    border-radius: 12px;
    transition: all var(--transition);
    border: 1px solid var(--border);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background: var(--toggle-knob);
    border-radius: 50%;
    transition: all var(--transition);
}

/* --- Theme toggle button --- */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.08);
    color: var(--accent-light);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 18px;
    flex-shrink: 0;
    padding: 0;
    line-height: 1;
}
.theme-toggle:hover {
    background: rgba(255,255,255,0.15);
    border-color: var(--accent);
    transform: scale(1.1);
}
[data-theme="light"] .theme-toggle {
    border: 1px solid rgba(0,0,0,0.15);
    background: rgba(0,0,0,0.05);
    color: var(--primary);
}
[data-theme="light"] .theme-toggle:hover {
    background: rgba(0,0,0,0.1);
    border-color: var(--primary);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--primary);
    border-color: var(--primary);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
    background: white;
}

.toggle-label {
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

/* --- User Table List (Admin) --- */
.user-search-bar {
    margin-bottom: 12px;
}
.user-search-bar input {
    width: 100%;
    max-width: 400px;
    padding: 8px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
}
.user-search-bar input:focus {
    border-color: var(--primary);
    outline: none;
}
.user-search-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    padding: 16px;
}

.user-table-wrap {
    overflow-x: auto;
}
.user-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.user-table thead th {
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.user-table tbody tr.user-row {
    cursor: pointer;
    transition: background var(--transition);
}
.user-table tbody tr.user-row:hover {
    background: var(--surface-hover);
}
.user-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    color: var(--text);
}
.user-table td.cell-muted {
    color: var(--text-muted);
}
.user-table td strong {
    font-weight: 600;
}

.card-role {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 6px;
    vertical-align: middle;
}
.card-role.role-admin {
    background: rgba(99,102,241,0.15);
    color: var(--primary-light);
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}
.status-dot.active { background: #10B981; }
.status-dot.disabled { background: #EF4444; }

/* --- User Detail Modal (Admin) --- */
.user-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
}
.user-modal-overlay.show {
    display: flex;
}

.user-modal {
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 560px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.user-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}
.user-modal-header h3 {
    font-size: 20px;
    margin: 0;
}
.user-modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}
.user-modal-close:hover { color: var(--text); }

.modal-section {
    margin-bottom: 20px;
}
.modal-section-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 10px;
    font-weight: 600;
}

.modal-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.modal-info-item label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 2px;
}
.modal-info-item span {
    font-size: 14px;
    color: var(--text);
}

.credit-display {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}
.credit-stat {
    text-align: center;
}
.credit-stat .big-number {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary-light);
    line-height: 1;
}
.credit-stat .stat-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.add-credits-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 12px;
}
.add-credits-row input {
    width: 100px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
}

.modal-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.btn-success {
    background: var(--success);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition);
}
.btn-success:hover { opacity: 0.85; }

.btn-warning {
    background: var(--warning);
    color: var(--bg);
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition);
}
.btn-warning:hover { opacity: 0.85; }

/* --- Credits display in sidebar --- */
.credits-badge {
    font-size: 12px;
    color: var(--text-muted);
    padding: 4px 10px;
    background: var(--surface);
    border-radius: 20px;
    border: 1px solid var(--border);
}

/* Mobile responsive for user table */
@media (max-width: 600px) {
    .user-search-bar input {
        max-width: 100%;
    }
    .user-table {
        font-size: 13px;
    }
    .user-table td, .user-table thead th {
        padding: 8px 8px;
    }
    .user-modal {
        margin: 10px;
        padding: 20px;
        max-height: 85vh;
    }
    .modal-info-grid {
        grid-template-columns: 1fr;
    }
    .credit-display {
        gap: 16px;
    }
}

/* --- Chat List (Sidebar Conversations) --- */
.chat-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-top: 1px solid var(--border);
}

.chat-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.new-chat-btn {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    width: 24px;
    height: 24px;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
}
.new-chat-btn:hover { background: var(--primary-dark); }

.chat-list-items {
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px;
}

.chat-list-empty {
    padding: 12px 8px;
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}

.chat-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background var(--transition);
    margin-bottom: 2px;
}
.chat-list-item:hover {
    background: var(--surface-hover);
}
.chat-list-item.active {
    background: var(--primary-glow);
}

.chat-list-title {
    flex: 1;
    font-size: 13px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.chat-list-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity var(--transition);
    flex-shrink: 0;
}
.chat-list-item:hover .chat-list-actions {
    opacity: 1;
}

.chat-action-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 4px;
    border-radius: 4px;
    line-height: 1;
}
.chat-action-btn:hover {
    color: var(--text);
    background: var(--surface);
}
.chat-action-btn.delete:hover {
    color: var(--danger);
}

/* --- Chat Images --- */
.chat-image {
    max-width: 100%;
    max-height: 400px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: transform var(--transition);
    display: block;
}
.chat-image:hover {
    transform: scale(1.02);
}
.image-bubble {
    padding: 8px !important;
}
.image-caption {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
    padding: 0 4px;
    line-height: 1.4;
}

/* --- Post Generator Image Output --- */
.post-image-output {
    margin-top: 16px;
    text-align: center;
}
.post-generated-image {
    max-width: 100%;
    max-height: 500px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.download-img-btn {
    margin-top: 8px;
    background: rgba(99,102,241,0.12);
    color: var(--primary-light);
    border: 1px solid rgba(99,102,241,0.2);
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
    transition: all var(--transition);
}
.download-img-btn:hover {
    background: rgba(99,102,241,0.2);
}

/* --- Image generation loading --- */
.image-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px;
    color: var(--text-muted);
    font-size: 13px;
}
.image-loading .spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Mobile adjustments for images */
@media (max-width: 600px) {
    .chat-image { max-height: 250px; }
    .post-generated-image { max-height: 300px; }
}

/* --- Daily Believe Quote (Login Page) --- */
.daily-quote {
    background: linear-gradient(135deg, rgba(99,102,241,0.1), rgba(245,158,11,0.08));
    border: 1px solid rgba(99,102,241,0.15);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 24px;
    text-align: center;
}
.daily-quote-text {
    font-size: 15px;
    font-style: italic;
    color: var(--text);
    line-height: 1.6;
    margin-bottom: 6px;
}
.daily-quote-author {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

/* --- Daily Believe Quote Banner (Dashboard) --- */
.daily-quote-banner {
    background: linear-gradient(90deg, rgba(99,102,241,0.08), rgba(245,158,11,0.06));
    border-bottom: 1px solid rgba(99,102,241,0.12);
    padding: 10px 24px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--text-secondary);
    flex-wrap: wrap;
}
.daily-quote-banner .quote-star {
    font-size: 16px;
    flex-shrink: 0;
}
.daily-quote-banner .quote-text {
    font-style: italic;
    color: var(--text);
}
.daily-quote-banner .quote-author {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* --- Image Creator View --- */
.image-creator {
    display: none;
    flex: 1;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}
.image-creator.active { display: flex; }
.image-creator-form {
    padding: 24px;
    flex: 1;
    overflow-y: auto;
}
.image-creator-output {
    margin-top: 20px;
    text-align: center;
}
.image-creator-caption {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
    line-height: 1.4;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* Mobile adjustments for daily quote banner */
@media (max-width: 600px) {
    .daily-quote-banner {
        padding: 8px 16px;
        font-size: 13px;
    }
    .image-creator-form {
        padding: 16px;
    }
}

/* --- Mobile History Button --- */
.mobile-history-btn {
    display: none;
    background: none;
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 20px;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition);
}
.mobile-history-btn:hover {
    background: var(--surface-hover);
}
@media (max-width: 600px) {
    .mobile-history-btn { display: flex; }
}

/* --- Mobile Chat List Drawer --- */
.mobile-chat-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 199;
    backdrop-filter: blur(2px);
}
.mobile-chat-overlay.show {
    display: block;
}

.mobile-chat-drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    background: var(--bg-secondary);
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 24px rgba(0,0,0,0.3);
}
.mobile-chat-drawer.open {
    transform: translateX(0);
}

.mobile-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.mobile-drawer-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}
.mobile-drawer-close:hover {
    color: var(--text);
}

.mobile-chat-list-items {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    -webkit-overflow-scrolling: touch;
}

/* --- Fix bottom nav z-index and scroll containment --- */
@media (max-width: 600px) {
    .mobile-nav {
        z-index: 150;
    }
    .main-content {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}
