/* Color Mapping Config */
:root {
  --app-bg: #0F1A3C;
  --card-bg: #1E2B58;
  --text-main: #FFFFFF;
  --text-muted: #94A3B8;
  --electric-blue: #3B82F6;
  --cyber-purple: #8B5CF6;
  --tech-gradient: linear-gradient(90deg, var(--electric-blue) 0%, var(--cyber-purple) 100%);
  --nav-height: 65px;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }

body { background-color: var(--app-bg); color: var(--text-main); padding-bottom: calc(var(--nav-height) + 20px); overflow-x: hidden; }

/* Structural Components */
.app-header { background: rgba(30, 43, 88, 0.4); backdrop-filter: blur(10px); text-align: center; padding: 15px; position: sticky; top: 0; z-index: 100; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.brand-text { font-size: 1.4rem; font-weight: 800; letter-spacing: 0.5px; }
.brand-text span { background: var(--tech-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

#app-canvas { padding: 15px; width: 100%; max-width: 600px; margin: 0 auto; }

/* Content Component Cards */
.news-card { background: var(--card-bg); border-radius: 12px; padding: 16px; margin-bottom: 14px; border: 1px solid rgba(255, 255, 255, 0.03); transition: transform 0.2s; position: relative; }
.news-card.cly-special { border: 1.5px solid transparent; background-image: linear-gradient(var(--card-bg), var(--card-bg)), var(--tech-gradient); background-origin: border-box; background-clip: padding-box, border-box; }
.card-meta { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--text-muted); margin-bottom: 8px; font-weight: 500; }
.card-title { font-size: 1.05rem; font-weight: 600; line-height: 1.4; margin-bottom: 8px; }
.card-snippet { font-size: 0.88rem; color: var(--text-muted); line-height: 1.5; margin-bottom: 12px; }
.read-btn { display: inline-block; width: 100%; text-align: center; background: rgba(255, 255, 255, 0.05); color: var(--text-main); text-decoration: none; padding: 10px; border-radius: 6px; font-size: 0.85rem; font-weight: 600; border: 1px solid rgba(255, 255, 255, 0.05); }
.read-btn:active { background: var(--tech-gradient); }

/* Navigation Infrastructure */
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; height: var(--nav-height); background: #15224B; border-top: 1px solid rgba(255, 255, 255, 0.05); display: flex; justify-content: space-around; align-items: center; z-index: 100; padding-bottom: env(safe-area-inset-bottom); }
.nav-tab { background: none; border: none; color: var(--text-muted); display: flex; flex-direction: column; align-items: center; font-size: 0.7rem; font-weight: 500; cursor: pointer; flex-grow: 1; transition: color 0.2s; position: relative; }
.nav-tab .icon { width: 22px; height: 22px; fill: currentColor; margin-bottom: 4px; }
.nav-tab.active { color: var(--electric-blue); }
.nav-tab.brand-special.active { color: var(--cyber-purple); }

/* Unique Branding Elements */
.pulse-indicator { width: 6px; height: 6px; background-color: var(--cyber-purple); border-radius: 50%; position: absolute; top: 2px; right: 32%; display: none; box-shadow: 0 0 8px var(--cyber-purple); }

/* System Utilities */
#install-banner { background: var(--tech-gradient); padding: 12px; border-radius: 8px; font-size: 0.85rem; text-align: center; margin-bottom: 15px; }
#btn-install { background: white; color: #0F1A3C; border: none; padding: 6px 12px; border-radius: 4px; font-weight: 700; margin-top: 8px; font-size: 0.8rem; }
.hidden { display: none !important; }

/* --- Core Fix: Force Layout Reset --- */
#clybot-fab, #clybot-chat-container, .auth-box-overlay {
    box-sizing: border-box !important;
    font-family: system-ui, -apple-system, sans-serif !important;
}

/* --- SECURE AUTH LOCKOVER SYSTEM LAYOUTS --- */
.auth-box-overlay {
    position: absolute !important;
    top: 53px !important; /* Locks exactly below the chat title header line */
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: #091022 !important; /* Blends perfectly into inputs section panels */
    z-index: 10001 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 20px !important;
}

.auth-card {
    width: 100% !important;
    max-width: 400px !important;
    background: var(--card-bg) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 16px !important;
    padding: 24px !important;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5) !important;
    /* Core Fix: Force children to stack vertically instead of wrapping raw text nodes */
    display: flex !important;
    flex-direction: column !important;
}

.auth-card h5 {
    font-size: 1.15rem !important;
    font-weight: 700 !important;
    margin-bottom: 8px !important;
    color: var(--text-main) !important;
}

.auth-card p {
    font-size: 0.85rem !important;
    color: var(--text-muted) !important;
    line-height: 1.5 !important;
    margin-bottom: 18px !important;
}

/* Core Fix: Form inputs styled for full-width stack blocks */
.auth-card input {
    display: block !important;
    width: 100% !important;
    background: #0b1326 !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    color: #ffffff !important;
    padding: 14px 16px !important; /* Slightly more breathable padding */
    border-radius: 8px !important;
    outline: none !important;
    font-size: 14px !important;
    margin-bottom: 14px !important; /* Clear separation below each input element */
    box-sizing: border-box !important; /* Prevents padding from breaking width bounds */
    transition: border-color 0.2s ease;
}

.auth-card input:focus {
    border-color: var(--electric-blue) !important;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2) !important;
}

/* --- Clybot Floating Button --- */
#clybot-fab {
    position: fixed !important;
    bottom: 90px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    background: linear-gradient(135deg, #0d3270 0%, #1c1045 100%) !important;
    border: 1px solid rgba(106, 90, 205, 0.4) !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6) !important;
    color: #ffffff !important;
    padding: 12px 24px !important;
    border-radius: 30px !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    cursor: pointer !important;
    z-index: 9999 !important;
    white-space: nowrap !important;
    transition: all 0.3s ease;
}

/* --- Fixed Overlay View Panel --- */
#clybot-chat-container {
    position: fixed !important;
    bottom: 0 !important;
    left: 50% !important;
    transform: translateX(-50%) translateY(0) !important;
    width: 100% !important;
    max-width: 480px !important;
    height: 65vh !important;
    background: rgba(14, 26, 54, 0.96) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border-top-left-radius: 24px !important;
    border-top-right-radius: 24px !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    display: flex !important;
    flex-direction: column !important;
    z-index: 10000 !important;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.7) !important;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important, opacity 0.2s ease !important;
}

/* --- Clean Toggle Hidden Class --- */
#clybot-chat-container.clybot-hidden {
    transform: translateX(-50%) translateY(100%) !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* --- Header Layout Structural Alignment --- */
.clybot-header {
    padding: 16px !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
}

.clybot-title {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    color: #fff !important;
}
.clybot-title h4 { margin: 0 !important; font-size: 16px !important; color: white !important;}

.clybot-close-btn {
    background: transparent !important;
    border: none !important;
    color: #8fa0c0 !important;
    font-size: 20px !important;
    cursor: pointer !important;
}

/* --- Chat Inner Core Scroller --- */
.clybot-messages {
    flex: 1 !important;
    overflow-y: auto !important;
    padding: 16px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
}

.system-msg {
    background: rgba(24, 43, 87, 0.6) !important;
    border: 1px solid rgba(58, 110, 238, 0.2) !important;
    color: #e2e8f0 !important;
    padding: 16px !important;
    border-radius: 16px !important;
}

.ams-capabilities {
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
    margin-top: 12px !important;
    font-size: 13px !important;
    color: #94a3b8 !important;
}

/* --- Input Bar Control Layout --- */
.clybot-input-area {
    padding: 16px !important;
    border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
    display: flex !important;
    gap: 10px !important;
    background: #091022 !important;
    align-items: center !important;
    padding-bottom: calc(16px + env(safe-area-inset-bottom)) !important;
}

#clybot-user-input {
    flex: 1 !important;
    background: #0b1326 !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    color: #ffffff !important;
    padding: 12px 18px !important;
    border-radius: 24px !important;
    outline: none !important;
    font-size: 14px !important;
}

#clybot-user-input:disabled {
    opacity: 0.4 !important;
    cursor: not-allowed !important;
    placeholder: "Locked..." !important;
}

#clybot-send-btn {
    background: linear-gradient(135deg, #3a6eee 0%, #6a5acd 100%) !important;
    border: none !important;
    color: white !important;
    width: 42px !important;
    height: 42px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
}

#clybot-send-btn:disabled {
    background: #1e2b58 !important;
    color: #4b5563 !important;
    cursor: not-allowed !important;
}
