:root {
    --bg0: #070a10;
    --bg1: #0b1220;
    --panel: #0f172a;
    --panel2: #111827;
    --border: rgba(255, 255, 255, .08);
    --text: #e5e7eb;
    --muted: rgba(229, 231, 235, .65);
    --accent: #3b82f6;
    --radius: 14px;
}

body {
    background:
        radial-gradient(900px 500px at 50% 0%, rgba(59, 130, 246, .12), transparent 55%),
        linear-gradient(180deg, var(--bg1), var(--bg0));
    background-attachment: fixed;
    color: var(--text);
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Centered Wrapper */
.chat-page-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

/* Heading & Subtitle */
.chat-page-header {
    text-align: center;
    margin-bottom: 32px;
}

.chat-page-title {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #fff 30%, rgba(255, 255, 255, 0.5) 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.chat-page-subtitle {
    color: var(--muted);
    font-size: 1.1rem;
    font-weight: 500;
}

/* Main Chat Panel */
.chat-container {
    width: 100%;
    max-width: 900px;
    height: 700px;
    background: linear-gradient(180deg, rgba(17, 24, 39, .75), rgba(15, 23, 42, .65));
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    animation: panelAppear 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes panelAppear {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Panel Header */
.chat-header {
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-status {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.6);
    position: relative;
}

.status-dot::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: inherit;
    transform: translate(-50%, -50%);
    animation: ripple 2s infinite;
}

@keyframes ripple {
    0% {
        width: 8px;
        height: 8px;
        opacity: 1;
    }

    100% {
        width: 24px;
        height: 24px;
        opacity: 0;
    }
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Friendly Mode Toggle - Keeping it exactly as it was but with better styling */
.mode-toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.mode-toggle-wrapper:hover {
    background: rgba(255, 255, 255, 0.08);
}

.switch {
    position: relative;
    display: inline-block;
    width: 34px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border-radius: 20px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--accent);
}

input:checked+.slider:before {
    transform: translateX(14px);
}

.mode-label {
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 500;
}

.btn-clear {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-clear:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.2);
    transform: translateY(-1px);
}

.btn-clear:active {
    transform: translateY(0);
}

/* Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Message Bubbles */
.message {
    max-width: 75%;
    padding: 14px 20px;
    border-radius: 20px;
    font-size: 0.95rem;
    line-height: 1.6;
    animation: messageSlide 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    position: relative;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.message.bot {
    align-self: flex-start;
    background: linear-gradient(145deg, #1e293b, #111827);
    color: var(--text);
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(59, 130, 246, 0.1));
    color: #93c5fd;
    border-bottom-right-radius: 4px;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.message.system {
    align-self: center;
    background: rgba(255, 255, 255, 0.03);
    color: var(--muted);
    font-size: 0.8rem;
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid var(--border);
    font-weight: 500;
}

/* Typing Indicator */
.typing-indicator {
    align-self: flex-start;
    font-size: 0.85rem;
    color: var(--muted);
    padding: 0 0 10px 10px;
    display: none;
    margin-top: -10px;
}

/* Bottom Input Area */
.chat-input-wrapper {
    padding: 24px;
    background: rgba(0, 0, 0, 0.15);
    border-top: 1px solid var(--border);
}

.chat-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-input-row {
    display: flex;
    gap: 14px;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 18px;
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
    resize: none;
    max-height: 160px;
    outline: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-input:focus {
    border-color: var(--accent);
    background: rgba(15, 23, 42, 0.9);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
    transform: translateY(-1px);
}

.btn-send {
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, var(--accent) 0%, #2563eb 100%);
    border: none;
    border-radius: 14px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-send:hover:not(:disabled) {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.5);
    filter: brightness(1.1);
}

.btn-send:active:not(:disabled) {
    transform: translateY(0) scale(0.95);
}

.btn-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(1);
    box-shadow: none;
}

.chat-disclaimer {
    text-align: center;
    font-size: 0.75rem;
    color: var(--muted);
    line-height: 1.5;
    margin-top: 16px;
    max-width: 80%;
    margin-left: auto;
    margin-right: auto;
}

/* Navbar Animations */
.nav-link {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.nav-link:hover {
    transform: translateY(-2px);
    color: var(--accent) !important;
}

.nav-link:active {
    transform: translateY(0) scale(0.95);
}

.nav-brand {
    transition: all 0.3s ease;
}

.nav-brand:hover {
    filter: brightness(1.2);
    transform: scale(1.02);
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .chat-page-wrapper {
        padding: 0;
        justify-content: flex-start;
        height: 100vh;
    }

    .chat-page-header {
        display: none;
    }

    .chat-container {
        height: 100%;
        max-width: 100%;
        border-radius: 0;
        border: none;
    }

    .chat-messages {
        padding: 16px;
    }

    .message {
        max-width: 85%;
    }

    .chat-input-wrapper {
        padding: 16px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }
}

.error-code {
    display: inline-block;
    margin-top: 4px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.75rem;
    opacity: 0.6;
    letter-spacing: 0.05em;
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
}