/* B"H - Awtsmoos Quantum Mail: Vivid Edition */

:root {
    --bg-deep: #050505;
    --bg-surface: #0f0f11;
    --glass-panel: rgba(20, 20, 23, 0.75);
    --border: rgba(255, 255, 255, 0.08);
    
    /* VIVID PALETTE */
    --neon-gold: #ffaa00;
    --neon-amber: #f59e0b;
    --neon-fire: #ef4444;
    --neon-void: #8b5cf6;
    
    /* Gradients */
    --gradient-me: linear-gradient(135deg, #ffaa00 0%, #d97706 100%);
    --gradient-glow: radial-gradient(circle at top, rgba(245,158,11,0.15), transparent 70%);
    
    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    
    /* Metrics */
    --sidebar-w: 300px;
    --header-h: 54px;
    
    --awtsmoos-header-h: 45px;
}



.main * {
    box-sizing: content-box;
}
/* Add to styles.css */

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden; /* Stop the browser window from scrolling */
}

/* B"H - Fix Wrapper Layout (Full Screen without Header) */
.all.awtsmoospage {
    height: 100% !important;
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
}


.all.awtsmoospage > .main {
    /* 1. Stop forcing 100% height. Let Flexbox calculate the remaining space. */
    height: auto !important;
    flex: 1 1 auto !important; 
    
    /* 2. Fix Flexbox bugs (Mozilla/Webkit) where it refuses to shrink */
    min-height: 0 !important;
    
    /* 3. Keep layout clean */
    display: flex !important;
    flex-direction: column !important;
    
    /* 4. Stop the scrollbar on the wrapper */
    overflow: hidden !important;
    padding: 0 !important;
}
/* Ensure the main container fills the remaining space */
.main {
    flex: 1; /* Grow to fill space under header */
    height: 100%;
    overflow: hidden; /* Contain the app layout */
    position: relative;
}

/* LAYOUT GRID */






/* --- SIDEBAR (Left) --- */
.sidebar {
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    backdrop-filter: blur(20px);
    z-index: 10; position: relative;
     height: 100% !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    background: rgba(255,255,255,0.02);
}

.brand-row {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1rem;
}

.brand {
    font-size: 1.4rem; font-weight: 900;
    background: linear-gradient(to right, #fff, var(--neon-gold));
    -webkit-background-clip: text; color: transparent;
    letter-spacing: -0.5px;
    text-transform: uppercase;
}

.tabs {
    display: flex; gap: 6px; background: rgba(0,0,0,0.4);
    padding: 6px; border-radius: 12px;
}

.tab-btn {
    flex: 1; padding: 8px; border: none; background: transparent;
    color: var(--text-secondary); font-weight: 600; font-size: 0.8rem;
    cursor: pointer; border-radius: 8px; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-btn:hover { color: #fff; background: rgba(255,255,255,0.05); }
.tab-btn.active {
    background: var(--neon-amber); color: #000;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

.btn-compose {
    margin: 1rem 1.5rem;
    background: rgba(255,255,255,0.03); border: 1px dashed var(--border);
    padding: 12px; border-radius: 12px; color: var(--text-secondary);
    font-weight: 600; cursor: pointer; transition: all 0.2s ease;
    display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-compose:hover {
    border-color: var(--neon-gold); color: var(--neon-gold);
    background: rgba(245, 158, 11, 0.05);
}

.threads-list {
    flex: 1; overflow-y: auto; padding: 0 10px;
}

.thread-item {
    display: grid; grid-template-columns: auto 1fr; gap: 12px;
    padding: 14px; border-radius: 14px; cursor: pointer;
    margin-bottom: 6px; border: 1px solid transparent;
    transition: all 0.2s ease; position: relative; overflow: hidden;
}

.thread-item:hover { background: rgba(255,255,255,0.04); }
.thread-item.active {
    background: linear-gradient(90deg, rgba(245,158,11,0.1), transparent);
    border-left: 3px solid var(--neon-gold);
}

.avatar {
    width: 48px; height: 48px; border-radius: 14px;
    background: linear-gradient(135deg, #2a2a2e, #18181b);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 1.1rem; color: #fff;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
}

.thread-top { display: flex; justify-content: space-between; margin-bottom: 4px; }
.thread-name { font-weight: 700; font-size: 0.95rem; color: #fff; }
.thread-time { font-size: 0.75rem; color: var(--text-secondary); }
.thread-preview { font-size: 0.85rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unread-badge {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%); /* Center vertically */
    background: var(--neon-gold); 
    color: #000; 
    font-weight: 800; 
    padding: 4px 8px; 
    border-radius: 12px; 
    font-size: 0.75rem; 
    box-shadow: 0 2px 8px rgba(245,158,11,0.5); 
}
/* --- CHAT AREA (Right) --- */
.chat-area {
    background: var(--bg-deep); 
    position: relative;
    
    height: 100% !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
}

.chat-header {
    height: var(--header-h); 
    padding: 0 1rem; /* Reduced horizontal padding */
    display: flex; align-items: center; justify-content: space-between;
    background: rgba(10,10,12,0.95); 
    border-bottom: 1px solid var(--border);
    flex-shrink: 0; /* Don't let header shrink */
    z-index: 20;
}

/* Chat Info - Compact */
.chat-info h2 { 
    margin: 0; 
    font-size: 1rem; /* Smaller font */
    font-weight: 700;
}

.last-seen { font-size: 0.8rem; color: var(--neon-gold); display: block; margin-top: 4px; }

/* Action Buttons */
.header-actions button {
    background: rgba(255,255,255,0.05); border: 1px solid var(--border);
    color: #fff; padding: 8px 14px; border-radius: 8px; cursor: pointer;
    font-weight: 600; font-size: 0.85rem; transition: all 0.2s;
}
.header-actions button:hover { background: #fff; color: #000; }
.btn-danger:hover { background: var(--neon-fire) !important; color: #fff !important; border-color: var(--neon-fire); }

/* Messages */
.messages-container {
    flex: 1; 
    overflow-y: auto; 
    overflow-x: hidden;
    padding: 1rem;
    display: flex; 
    flex-direction: column; 
    gap: 12px;
    min-height: 0; /* Critical for Flexbox scrolling */
    
    /* Scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: var(--neon-gold) transparent;
}

.message-row {
display:flex;
    position: relative;
    touch-action: pan-y; /* Prevent browser nav swipe, allow scroll */
    /* B"H - No transition here! handled by JS for 0 latency */
}

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

.message-bubble {
    max-width: 75%; padding: 12px 16px;
    border-radius: 18px; font-size: 0.95rem; line-height: 1.5;
    position: relative; box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    display: flex; flex-direction: column;
}

/* Sender Name Small Header */
.msg-sender-name {
    font-size: 0.7rem; margin-bottom: 4px; font-weight: 700;
    color: rgba(255,255,255,0.5); letter-spacing: 0.5px;
    margin-left: 2px;
}
.row-me .msg-sender-name { display: none; } /* Don't show name for self */

/* 3-Dot Menu Trigger */
.msg-menu-btn {
    position: absolute; top: 5px; right: 6px;
    background: rgba(0,0,0,0.3); /* Slight dim to stand out on colors */
    border-radius: 50%;
    border: none; color: #fff;
    font-size: 1.2rem; line-height: 1; /* Fix height */
    width: 24px; height: 24px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; 
    opacity: 0; transition: opacity 0.2s;
    z-index: 20; /* Ensure it is ABOVE the quote */
}
.message-bubble:hover .msg-menu-btn, .message-bubble:active .msg-menu-btn { opacity: 1; }

/* Context Menu Modal Styles */
.context-menu {
    position: absolute; bottom: 0; left: 0; width: 100%;
    border-radius: 20px 20px 0 0; border: 1px solid var(--neon-gold);
    background: #111; padding: 20px;
    display: flex; flex-direction: column; gap: 8px;
    animation: slideUpMenu 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.menu-header { font-size: 0.9rem; color: var(--text-secondary); text-align: center; margin-bottom: 10px; text-transform: uppercase; letter-spacing: 1px; }

.menu-item {
    background: rgba(255,255,255,0.05); border: none; color: #fff;
    padding: 16px; border-radius: 12px; font-size: 1rem; font-weight: 600;
    display: flex; align-items: center; gap: 12px; cursor: pointer;
}
.menu-item:active { background: rgba(255,255,255,0.1); transform: scale(0.98); }
.menu-item.danger { color: var(--neon-fire); background: rgba(239, 68, 68, 0.1); }



.row-me { justify-content: flex-end; }
.row-me .message-bubble {
    background: var(--gradient-me);
    color: #fff;
    border-bottom-right-radius: 4px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.row-them { justify-content: flex-start; }
.row-them .message-bubble {
    background: #1e1e22;
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}


/* Update .input-area */
.input-area {
    flex-shrink: 0;
    width: 100%;
    /* B"H - Safe zone logic: 20px buffer + system inset */
    padding: 15px 20px;
    padding-bottom: calc(15px + env(safe-area-inset-bottom));
    
    background: linear-gradient(to top, #000 90%, transparent); 
    display: flex; flex-direction: column;
    box-sizing: border-box;
    z-index: 50;
}

.input-wrapper {
    background: rgba(30, 30, 35, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 0; /* Let children handle padding */
    display: flex; 
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    overflow: hidden; /* Contain the children */
}

.input-wrapper:focus-within {
    background: rgba(40, 40, 45, 0.9);
    border-color: var(--neon-gold);
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.15);
    transform: translateY(-2px);
}

/* THE SUBJECT LINE */
.subject-input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 16px;
    background: rgba(0,0,0,0.2);
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--neon-gold);
    font-size: 0.8rem;
    font-weight: 600;
    font-family: inherit;
    outline: none;
    letter-spacing: 0.5px;
    transition: all 0.2s;
}

.subject-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
    font-weight: 400;
    font-style: italic;
}

.subject-input:focus {
    background: rgba(0,0,0,0.4);
}

.flex-row {
    display: flex; 
    align-items: flex-end; 
    gap: 10px;
    padding: 10px 12px 10px 16px; /* Specific padding for message area */
}

textarea {
    flex: 1; 
    background: transparent; 
    border: none; 
    color: #e5e7eb;
    font-size: 1rem; 
    min-height: 24px; 
    max-height: 150px; 
    resize: none; 
    font-family: 'Inter', sans-serif; 
    line-height: 1.5;
    padding: 4px 0;
    outline: none;
}
textarea::placeholder { color: rgba(255, 255, 255, 0.4); }

.btn-send {
    width: 36px; height: 36px; 
    border-radius: 12px;
    background: rgba(255,255,255,0.05);
    color: rgba(255,255,255,0.4);
    border: none; 
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    flex-shrink: 0;
}

/* Ready State */
.btn-send.ready {
    background: var(--neon-gold);
    color: #000;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}
.btn-send.ready:hover {
    transform: scale(1.1) rotate(-10deg);
}


/* --- SWIPE GESTURE STYLES --- */




.btn-send svg { width: 20px; height: 20px; fill: currentColor; transform: translateX(2px); }

/* Empty States */
.empty-state { margin: auto; text-align: center; opacity: 0.3; }
.logo-faint { font-size: 5rem; font-weight: 900; letter-spacing: -2px; margin-bottom: 10px; }


/* MOBILE RESPONSIVE LOGIC */
.back-btn { 
    display: none; /* Hidden on desktop */
    font-size: 1.5rem; 
    background: transparent; 
    border: none; 
    color: var(--text-primary); 
    margin-right: 15px; 
    cursor: pointer; 
    padding: 0 10px;
    z-index: 100;
}


/* 2. The App: Force 2-Column Grid on Desktop */
#appContainer.app-layout {
    /* Size Logic */
    flex: 1 1 auto !important;
    height: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    min-height: 0 !important;
    
    /* Grid Logic - HERE IS THE FIX */
    display: grid !important;
    /* 300px Sidebar | Remaining Space for Chat */
    grid-template-columns: 300px 1fr !important; 
    grid-template-rows: 100% !important;
    overflow: hidden !important;
}

@media (max-width: 800px) {
.input-area {
	.padding-bottom: calc(75px + env(safe-area-inset-bottom));
}
#appContainer.app-layout {
        display: flex !important; /* Or grid-template-columns: 1fr */
        flex-direction: column !important;
    }
    .app-layout { grid-template-columns: 1fr; }
    
    .back-btn { display: block !important; }
    
    /* Toggle Visibility Logic */
    .app-layout:not(.chat-open) .chat-area { display: none !important; }
    .app-layout:not(.chat-open) .sidebar { 
        display: flex !important; 
        width: 100%; 
        height: 100vh;
        border-right: none; /* Remove border on mobile to ensure fit */
    }
    .app-layout.chat-open .sidebar { display: none !important; }
    .app-layout.chat-open .chat-area { 
        display: flex !important; 
        width: 100%; 
        height: 100%; /* Fill .main, not the screen */
        position: absolute; /* Stay inside .main */
        top: 0; 
        left: 0; 
        z-index: 50; 
        background: var(--bg-deep); /* Ensure no transparency overlap */
    }
    
    .back-btn { display: block; }
    
   
}
  .sidebar, .chat-area {
    height: 100% !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
}

/* Find the ".modal" block and update it to this: */
.modal {
    position: fixed; 
    top: 0; left: 0; 
    width: 100%; height: 100%;
    z-index: 9999 !important;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    
    /* B"H - Center align logic */
    display: flex;
    align-items: center; /* Vertical Center */
    justify-content: center; /* Horizontal Center */
    padding-bottom: env(safe-area-inset-bottom); /* Respect bottom bar */
}
/* SETTINGS MODAL */
/* SETTINGS MODAL & Generic Modals */
.modal-content {
    background: #111;
    border: 1px solid var(--neon-gold);
    box-shadow: 0 0 50px rgba(0,0,0,0.8), 0 0 30px rgba(245, 158, 11, 0.1);
    position: relative;
    padding: 30px 24px; /* Fixed Padding */
    width: 90%; max-width: 500px;
    box-sizing: border-box; /* IMPORTANT to prevent overflow */
    border-radius: 16px;
    margin: auto; /* Center in flex container */
}

/* Context Menu Fixes */
.context-menu {
    position: absolute; bottom: 10px; left: 0; right: 0; /* Center horizontally */
    width: 95%; margin: 0 auto;
    border-radius: 20px; 
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(20,20,23, 0.98);
    backdrop-filter: blur(20px);
    padding: 20px 10px; /* Internal padding */
    box-sizing: border-box;
    display: flex; flex-direction: column; gap: 8px;
    animation: slideUpMenu 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1000;
}

.menu-handle {
    width: 40px; height: 4px; background: rgba(255,255,255,0.2);
    border-radius: 2px; margin: 0 auto 10px auto;
}

.cancel-item {
    background: transparent; border: 1px solid rgba(255,255,255,0.1);
    text-align: center; justify-content: center;
}



/* Delete Message "X" */
.msg-del {
    width: 24px; height: 24px;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 50%;
    color: var(--text-secondary);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; margin-left: 8px;
    font-size: 1.2rem; line-height: 1;
    transition: all 0.2s;
}
.msg-del:hover {
    background: var(--neon-fire);
    color: #fff;
    transform: scale(1.1);
}

/* Settings Gear Icon */
.btn-icon {
    background: none; border: none;
    color: var(--text-secondary);
    font-size: 1.4rem; cursor: pointer;
    padding: 8px; border-radius: 50%;
    transition: all 0.3s ease;
}
.btn-icon:hover {
    background: rgba(255,255,255,0.1);
    color: var(--neon-gold);
    transform: rotate(90deg);
}

/* Close Modal "X" */
.close-modal {
    position: absolute; top: 15px; right: 20px;
    font-size: 2rem; cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s;
    line-height: 1;
}
.close-modal:hover { color: var(--neon-fire); }


/* B"H - ESSENTIAL UTILITY: Hides elements until JS activates them */
.hidden {
    display: none !important;
}
#appContainer.app-layout {
    display: grid;
    grid-template-columns: 300px 1fr; /* Sidebar | Chat */
    grid-template-rows: 100%;
    overflow: hidden;
}
/* --- RULE BUILDER & SETTINGS STYLES --- */
.rules-list {
    display: flex; flex-direction: column; gap: 10px;
    max-height: 300px; overflow-y: auto; margin-bottom: 15px;
    padding-right: 5px;
}

.rule-card {
    background: rgba(255,255,255,0.03); 
    border: 1px solid var(--border);
    border-left: 3px solid var(--neon-amber);
    padding: 12px; border-radius: 8px;
    display: flex; flex-direction: column; gap: 10px;
    animation: fadeIn 0.3s ease;
}

.rule-header { display: flex; justify-content: space-between; align-items: center; }
.rule-action-row { display: flex; align-items: center; gap: 10px; color: var(--neon-gold); font-size: 0.9rem; }

.input-sm, .input-block {
    background: #000; border: 1px solid var(--border);
    color: #fff; padding: 8px; border-radius: 6px;
    font-family: inherit; width: 100%;
}
.input-sm { width: auto; }

.code-font { font-family: monospace; color: #4ade80; background: #050505; }

.btn-secondary {
    width: 100%; padding: 10px;
    background: rgba(255,255,255,0.05);
    border: 1px dashed var(--border);
    color: var(--text-secondary); cursor: pointer;
    border-radius: 8px; transition: all 0.2s;
}
.btn-secondary:hover { border-color: var(--neon-gold); color: var(--neon-gold); }

/* Fix Toggle Checkbox */
.toggle-label {
    display: flex; align-items: center; gap: 10px;
    background: rgba(255,255,255,0.05); padding: 10px;
    border-radius: 8px; cursor: pointer; user-select: none;
}
.toggle-label input { width: 20px; height: 20px; accent-color: var(--neon-gold); }


/* --- REPLY SYSTEM STYLES --- */

/* The Preview Bar above input */
.reply-preview {
    background: rgba(30, 30, 35, 0.95);
    border-left: 3px solid var(--neon-gold);
    padding: 10px 14px;
    margin-bottom: 4px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: space-between;
    animation: slideUp 0.2s ease;
}
/* ensure Reply Preview looks good with new inputs */
/*.reply-preview {
    margin: 0 0 8px 0;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 170, 0, 0.3);
}*/
.reply-info { display: flex; flex-direction: column; overflow: hidden; }
.reply-to-label { font-size: 0.75rem; color: var(--neon-gold); font-weight: 700; margin-bottom: 2px; }
.reply-text-snippet { font-size: 0.85rem; color: #ccc; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 250px; }
.close-reply { background: none; border: none; color: #fff; font-size: 1.5rem; cursor: pointer; padding: 0 8px; }

/* The Embedded Quote in the Message Bubble */
.embedded-quote {
    background: rgba(0,0,0,0.2);
    border-left: 3px solid var(--neon-gold);
    padding: 8px 10px;
    border-radius: 6px;
    margin-bottom: 8px;
    /* Prevent overlap with the 3-dot menu */
    margin-right: 28px; 
    
    font-size: 0.85rem;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    transition: background 0.2s;
    position: relative; z-index: 10;
}
.embedded-quote:hover { background: rgba(255,255,255,0.05); }
.quote-name { display: block; font-weight: 700; color: var(--neon-gold); font-size: 0.7rem; margin-bottom: 2px; }

/* Highlight effect when scrolling to message */
@keyframes flashHighlight {
    0% { background: var(--neon-gold); color: #000; }
    100% { background: transparent; }
}
.highlight-msg .message-bubble { animation: flashHighlight 1.5s ease; }

/* --- SWIPE GESTURE STYLES --- */
.message-row {
    position: relative;
    touch-action: pan-y; /* Allow vertical scroll, handle horizontal in JS */
    transition: transform 0.1s linear; /* Smooth drag */
}

/* The icon that appears behind the swipe */
/* --- SWIPE GESTURE ICONS --- */

.swipe-indicator {
    position: absolute;
    top: 50%; 
    
    /* FIX: Position it explicitly to the LEFT of the content */
    left: -50px; 
    right: auto;
    
    transform: translateY(-50%);
    color: var(--neon-gold);
    font-size: 1.5rem;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 0; /* Ensure it's behind the text but visible when pulled */
    pointer-events: none;
    
    /* Center the emoji in its own box */
    width: 40px; 
    display: flex; 
    justify-content: center;
}

.row-me .swipe-indicator {
    /*  For 'Me' messages, position to the RIGHT */
    left: auto;
    right: -50px;
    
    /* Reset margins/transforms specific to the right side */
    transform-origin: center;
}

/* Ensure the row is visible during the swipe */
.message-row.swiping .swipe-indicator { 
    opacity: 1; 
}


/* B"H - NEW TRANSMISSION MODAL STYLES */

/* 1. The Container Card */
/* Update these styles for the New Message Modal */

#newMsgModal .modal-content {
    background: rgba(11, 11, 13, 0.98);
    border: 1px solid rgba(255, 170, 0, 0.2);
    box-shadow: 0 0 50px rgba(0,0,0,0.8);
    border-radius: 20px;
    
    /* B"H - Compact Layout Fixes */
    padding: 20px 24px;   /* Reduced vertical padding */
    width: 85%;           /* slightly narrower */
    max-width: 400px;
    
    /* Prevent cutoff */
    max-height: 80dvh;    /* Never exceed 80% of viewport height */
    overflow-y: auto;     /* Scroll internally if content is too tall */
    scrollbar-width: none; /* Hide scrollbar for cleanliness */
    
    /* Reset margins since flex handles centering */
    margin: 0; 
    position: relative;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Compact the form groups slightly */
.form-group {
    margin-bottom: 12px; /* Tighter spacing */
    text-align: left;
}

#newThreadForm textarea {
    min-height: 80px; /* Don't let it start too huge */
    resize: none;
}

@keyframes popIn {
    from { transform: scale(0.9) translateY(20px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

/* 2. The Header */
#newMsgModal h2 {
    margin: 0 0 20px 0;
    font-size: 1.4rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
    background: linear-gradient(90deg, #fff, var(--neon-gold));
    -webkit-background-clip: text;
    color: transparent;
}

/* 3. Form Layout */
.form-group {
    margin-bottom: 16px;
    text-align: left;
}

.form-group label {
    display: block;
    color: var(--neon-gold);
    font-size: 0.75rem;
    font-weight: 700;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 4px;
}

/* 4. Inputs & Textarea - The "Void" Look */
#newThreadForm input,
#newThreadForm textarea {
    width: 100%;
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 14px;
    color: #fff;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.2s ease;
}

/* Focus State: Neon Glow */
#newThreadForm input:focus,
#newThreadForm textarea:focus {
    outline: none;
    background: rgba(0, 0, 0, 0.4);
    border-color: var(--neon-gold);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

/* Placeholder Styling */
#newThreadForm input::placeholder,
#newThreadForm textarea::placeholder {
    color: rgba(255, 255, 255, 0.3);
    font-style: italic;
}

/* 5. The Send Button */
#newMsgModal .modal-actions {
    margin-top: 24px;
    display: flex;
    justify-content: stretch; /* Full width button */
}

#newMsgModal .btn-primary {
    width: 100%;
    background: var(--neon-gold);
    color: #000;
    font-weight: 800;
    padding: 14px;
    border-radius: 12px;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
    transition: transform 0.1s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#newMsgModal .btn-primary:active {
    transform: scale(0.98);
    box-shadow: none;
}

/* 6. Close Button Fix */
.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2rem;
    line-height: 0.7;
    color: rgba(255,255,255,0.3);
    cursor: pointer;
    z-index: 10;
    padding: 10px; /* Larger tap target */
}
.close-modal:hover {
    color: var(--neon-fire);
}



.thread-info {
    min-width: 0; 
    
    
    display: flex; 
    flex-direction: column;
}



/* Ensure thread info fits in sidebar properly */
.thread-info {
    min-width: 0; 
    display: flex; 
    flex-direction: column;
}

/* B"H
 - SUBJECT LINE STYLES */
.msg-subject {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--neon-gold);
    padding-bottom: 4px;
    margin-bottom: 4px;
    border-bottom: 1px solid rgba(255, 170, 0, 0.15);
    opacity: 0.9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.message-row.row-me .msg-subject {
	color: #1e1e22;
}
/* B"H - SETTINGS MODAL FIXES */

/* Clean up the section headers */
.setting-section {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.setting-section:last-of-type { border-bottom: none; }

.setting-section h3 {
    margin: 0 0 12px 0;
    font-size: 0.9rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 1px;
}
#settingsModal .modal-content {
    max-height: 80vh;
    overflow: auto;
    color: white;
}
/* Fix Inputs & Textareas */
.input-block, .code-input {
    width: 100%;
    box-sizing: border-box; /* Prevents overflow */
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    padding: 12px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    margin-bottom: 10px; /* Space between inputs */
    transition: all 0.2s ease;
}

.input-block:focus, .code-input:focus {
    background: rgba(0, 0, 0, 0.5);
    border-color: var(--neon-gold);
    outline: none;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.1);
}

/* Specific fix for the "System Prompt" textarea */
textarea.input-block {
    min-height: 80px;
    line-height: 1.5;
    resize: vertical;
}

/* Code Input (Darker, monospace) */
.code-input {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    color: #a5f3fc; /* Cyan */
    background: #050505;
    border: 1px dashed rgba(255, 255, 255, 0.2);
}

/* The Hidden AI Config Box */
.config-box {
    background: rgba(255, 170, 0, 0.03);
    border-left: 2px solid var(--neon-gold);
    padding: 16px;
    border-radius: 0 8px 8px 0;
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Links inside labels */
label a { color: var(--neon-gold); text-decoration: none; }
label a:hover { text-decoration: underline; }

/* Toggles */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}
.toggle-label:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
}
.toggle-label input[type="checkbox"] {
    appearance: none;
    width: 20px; height: 20px;
    border: 2px solid var(--text-secondary);
    border-radius: 4px;
    position: relative;
    cursor: pointer;
}
.toggle-label input[type="checkbox"]:checked {
    background: var(--neon-gold);
    border-color: var(--neon-gold);
}
.toggle-label input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    color: #000;
    font-weight: 800;
    font-size: 14px;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
}



/* --- ARTIFACT CAPSULE (Collapsible) --- */
.html-capsule {
    margin: 12px 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #000;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    transition: all 0.3s ease;
}

.capsule-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    cursor: pointer; /* Clickable */
    user-select: none;
}

.capsule-header:hover {
    background: rgba(255, 255, 255, 0.08);
}

.capsule-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* The Arrow */
.capsule-arrow {
    font-size: 0.8rem;
    color: var(--neon-gold);
    transition: transform 0.2s ease;
    transform: rotate(0deg); /* Open (Down) state assumption */
}

/* When collapsed, rotate arrow */
.html-capsule.collapsed .capsule-arrow {
    transform: rotate(-90deg);
}

.capsule-label {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--neon-gold);
    text-transform: uppercase;
    letter-spacing: 1px;
}

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

/* Prevent header click when clicking buttons */
.capsule-btn {
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    font-size: 0.7rem;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 2; 
}

.capsule-btn:hover {
    background: var(--neon-gold);
    color: #000;
}

.capsule-frame {
    width: 100%;
    height: 350px;
    border: none;
    background: #fff;
    display: block;
    transition: height 0.3s ease;
}

/* Collapsed State */
.html-capsule.collapsed .capsule-frame {
    height: 0;
    border: none;
}
.html-capsule.collapsed {
    border-bottom: 1px solid transparent; /* Cleaner look when closed */
}


/* --- HTML ARTIFACT CAPSULE --- */


.capsule-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}

.capsule-label {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--neon-gold);
    text-transform: uppercase;
    letter-spacing: 1px;
}

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

.capsule-btn {
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    font-size: 0.7rem;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.capsule-btn:hover {
    background: var(--neon-gold);
    color: #000;
}

.capsule-frame {
    width: 100%;
    height: 300px; /* Default height */
    border: none;
    background: #fff; /* White background for the HTML content itself */
    display: block;
}

/* B"H - Ghost Bubble (Live Typing) */
.ghost-row {
    animation: pulse 2s infinite;
}
.ghost-bubble {
    background: transparent !important;
    border: 1px dashed var(--neon-gold) !important;
    color: var(--text-secondary) !important;
    font-style: italic;
    transition: all 0.1s ease;
}
@keyframes pulse { 0% { opacity: 0.5; } 50% { opacity: 0.8; } 100% { opacity: 0.5; } }


/* B"H - Add this to styles.css */

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Ensure hidden overrides the display:flex above */
.overlay.hidden {
    display: none !important;
}
/* B"H - Formatting Toolbar & Smart Scroll Styles */

.formatting-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    overflow-x: auto; /* Scrollable on small mobiles */
    white-space: nowrap;
    
    /* Hide scrollbar but allow scroll */
    scrollbar-width: none; 
    -ms-overflow-style: none;
}
.formatting-bar::-webkit-scrollbar { display: none; }

.fmt-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    border-radius: 6px;
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    font-family: monospace;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.fmt-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--neon-gold);
}

.fmt-btn:active {
    transform: scale(0.95);
}

.fmt-sep {
    width: 1px;
    height: 16px;
    background: rgba(255, 255, 255, 0.1);
    margin: 0 4px;
}
 

.preview-box {
        width: 100%;
        min-height: 40px;
        max-height: 200px;
        overflow-y: auto;
        padding: 10px;
        background: rgba(255, 255, 255, 0.05);
        border-radius: 8px;
        color: var(--text-primary, #e0e0e0);
        font-family: inherit;
        white-space: pre-wrap; /* Preserve spacing logic */
    }
    
    .tab-active {
        background: rgba(255, 215, 0, 0.2) !important;
        border-color: var(--neon-gold, #ffd700) !important;
    }
    


