@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --primary: #4CAF82;
    --primary-dark: #3D9170;
    --primary-light: #E8F5EE;
    --primary-pale: #F0FAF4;
    --bg-page: #F4F8F6;
    --bg-chat: #FFFFFF;
    --bg-bot-bubble: #F0FAF4;
    --bg-user-bubble-from: #4CAF82;
    --bg-user-bubble-to: #5BBE94;
    --text-primary: #2D3B35;
    --text-secondary: #6B7F75;
    --text-muted: #8E9F96;
    --border: #D4E5DC;
    --border-light: #E9F2EE;
    --accent-warm: #FBF6EE;
    --accent-peach: #FFEAD2;
    --accent-blue: #E8F0FE;
    --accent-yellow: #FFF9E6;
    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.03);
    --shadow-md: 0 8px 24px rgba(60, 145, 112, 0.06);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.08);
    --radius-bubble: 18px;
    --radius-card: 16px;
    --radius-btn: 10px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);

    /* Multi-color icon palette */
    --accent-sage: #4CAF82;
    --accent-sky: #5BA4CF;
    --accent-sky-light: #E3F1FA;
    --accent-lavender: #9B8EC4;
    --accent-lavender-light: #EFEBF7;
    --accent-amber: #D4963A;
    --accent-amber-light: #FFF4E0;
    --accent-rose: #D4697A;
    --accent-rose-light: #FDE8EC;
    --accent-teal: #3DA8A0;
    --accent-indigo: #5B6BBF;
    --accent-coral: #E07B5F;
}

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

html,
body {
    height: 100%;
    height: -webkit-fill-available;
    width: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-page);
    color: var(--text-primary);
    overscroll-behavior: none;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ══════ PAGE WRAPPER ══════ */
.page-wrapper {
    display: flex;
    flex-direction: row;
    height: 100vh;
    height: 100dvh;
    width: 100%;
    background: var(--bg-page);
}

/* ══════ SIDEBAR ══════ */
.sidebar {
    width: 280px;
    min-width: 280px;
    background: #2D463C; /* Beautiful premium medium-dark sage/forest green */
    color: #FFFFFF;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    flex-shrink: 0;
    z-index: 200;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar.collapsed {
    transform: translateX(-100%);
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    pointer-events: none;
}

/* Mobile: sidebar overlays on top */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        top: 0;
        left: 0;
        height: 100%;
        transform: translateX(-100%);
        opacity: 0;
        pointer-events: none;
        box-shadow: 6px 0 30px rgba(0, 0, 0, 0.2);
    }

    .sidebar.open {
        transform: translateX(0);
        opacity: 1;
        pointer-events: auto;
    }
}

/* Desktop Sidebar collapse toggle */
@media (min-width: 769px) {
    .sidebar.collapsed {
        transform: translateX(-100%);
    }

    .sidebar:not(.collapsed) {
        transform: translateX(0);
        opacity: 1;
        pointer-events: auto;
    }
}

.sidebar-backdrop {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(2px);
    z-index: 199;
    animation: fadeIn 0.25s ease;
}

.sidebar-backdrop.show {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.sidebar-header {
    padding: 20px 18px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.sidebar-logo img {
    height: 30px;
    width: 30px;
    border-radius: 50%;
    object-fit: cover;
    border: 1.5px solid rgba(255, 255, 255, 0.2);
    box-shadow: var(--shadow-sm);
}

.sidebar-logo span {
    font-size: 0.95rem;
    font-weight: 700;
    color: #FFFFFF;
    letter-spacing: 0.2px;
}

.new-chat-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 11px 16px;
    background: var(--primary);
    color: #FFFFFF;
    border: none;
    border-radius: var(--radius-btn);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 12px rgba(76, 175, 130, 0.2);
}

.new-chat-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(76, 175, 130, 0.3);
}

.new-chat-btn:active {
    transform: translateY(0);
}

.new-chat-btn i {
    opacity: 0.9;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-list::-webkit-scrollbar {
    width: 4px;
}

.history-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.history-section-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: #A9C2B5;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 10px 10px 6px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    color: #E2ECE7;
    font-size: 0.85rem;
    font-weight: 500;
    transition: var(--transition);
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #FFFFFF;
}

.history-item.active {
    background: rgba(255, 255, 255, 0.15);
    border-left: 3px solid var(--accent-sky);
    color: #FFFFFF;
    font-weight: 600;
    padding-left: 9px;
    box-shadow: none;
}

.history-item i {
    font-size: 0.95rem;
    flex-shrink: 0;
    opacity: 0.6;
}

.history-item.active i {
    opacity: 0.9;
    color: var(--accent-sky);
}

.history-item-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-delete-btn {
    opacity: 0.75;
    color: #C3D8CE;
    padding: 4px;
    border-radius: 6px;
    transition: var(--transition);
}

.history-item:hover .history-delete-btn {
    opacity: 0.9;
}

.history-delete-btn:hover {
    background: rgba(239, 68, 68, 0.2) !important;
    color: #FF8B8B !important;
    opacity: 1 !important;
}

.history-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 140px;
    gap: 10px;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-align: center;
    padding: 20px;
}

.history-empty i {
    font-size: 1.6rem;
}

.history-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 60px;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.sidebar-footer {
    padding: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.7rem;
    color: #A9C2B5;
    text-align: center;
    letter-spacing: 0.3px;
}

/* ══════ MAIN AREA ══════ */
.main-area {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow: hidden;
    transition: padding 0.3s ease;
}

@media (max-width: 768px) {
    .main-area {
        padding: 0;
    }
}

/* ══════ CHAT BOX ══════ */
.chat-box {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 900px;
    height: calc(100vh - 48px);
    height: calc(100dvh - 48px);
    background: var(--bg-chat);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-light);
    overflow: hidden;
    transition: var(--transition);
}

@media (max-width: 768px) {
    .chat-box {
        height: 100vh;
        height: 100dvh;
        border-radius: 0;
        box-shadow: none;
        max-width: 100%;
        border: none;
    }
}

.page-wrapper.fullscreen .main-area {
    padding: 0;
}

.page-wrapper.fullscreen .chat-box {
    max-width: 100%;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    box-shadow: none;
    border: none;
}

/* ══════ CHAT HEADER ══════ */
.chat-header {
    background: #FFFFFF;
    color: var(--text-primary);
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-light);
    padding-top: calc(16px + env(safe-area-inset-top, 0px));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-shrink: 0;
    z-index: 10;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.01);
}

.chat-header-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-header h1 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Add an active online status badge next to name */
.chat-header h1::after {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #4CAF50;
    border-radius: 50%;
    flex-shrink: 0;
}

.chat-header p {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin: 3px 0 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 480px) {
    .chat-header p {
        display: none;
    }
}

.header-btn-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.icon-btn {
    background: var(--primary-light);
    border: none;
    color: var(--primary-dark);
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.05rem;
    transition: var(--transition);
    flex-shrink: 0;
}

.icon-btn:hover {
    background: var(--primary);
    color: #FFFFFF;
    transform: translateY(-1px);
}

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

/* Header button overrides */
#sidebarToggleBtn {
    background: var(--accent-sky-light);
    color: var(--accent-sky);
}
#sidebarToggleBtn:hover {
    background: var(--accent-sky);
    color: #FFFFFF;
}

#hcToggleBtn {
    background: var(--accent-amber-light);
    color: var(--accent-amber);
}
#hcToggleBtn:hover {
    background: var(--accent-amber);
    color: #FFFFFF;
}

#langMenuBtn {
    background: var(--accent-lavender-light);
    color: var(--accent-lavender);
}
#langMenuBtn:hover {
    background: var(--accent-lavender);
    color: #FFFFFF;
}

.header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid #FFFFFF;
    box-shadow: var(--shadow-sm);
    object-fit: cover;
    background: var(--primary-light);
}

/* Language dropdown */
.lang-wrap {
    display: none !important;
    position: relative;
}

.lang-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: #FFFFFF;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 6px;
    display: none;
    flex-direction: column;
    gap: 4px;
    z-index: 700;
    min-width: 170px;
    animation: dropdownIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.lang-dropdown.show {
    display: flex;
}

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

.lang-option {
    padding: 10px 12px;
    border: none;
    background: transparent;
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: var(--transition);
}

.lang-option:hover {
    background: var(--primary-light);
    color: var(--primary-dark);
}

.lang-option.active {
    background: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 700;
}

/* ══════ SEARCH MODE BAR ══════ */
.search-mode-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 8px 16px;
    background: var(--bg-page);
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}

.toggle-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.toggle-switch {
    position: relative;
    width: 130px;
    height: 32px;
    background: var(--border-light);
    border-radius: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 3px;
    flex-shrink: 0;
    border: 1px solid var(--border);
}

.toggle-slider {
    position: absolute;
    width: 60px;
    height: 24px;
    background: var(--primary);
    border-radius: 12px;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 6px rgba(76, 175, 130, 0.2);
}

.toggle-switch.external .toggle-slider {
    transform: translateX(63px);
}

.toggle-options {
    display: flex;
    width: 100%;
    position: relative;
    z-index: 1;
}

.toggle-option {
    flex: 1;
    text-align: center;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-secondary);
    transition: color 0.2s;
    padding: 4px 2px;
    white-space: nowrap;
}

.toggle-switch.external .toggle-option.ext-lbl,
.toggle-switch:not(.external) .toggle-option.int-lbl {
    color: #FFFFFF;
}

/* ══════ MESSAGES CONTAINER ══════ */
.messages-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: var(--bg-chat);
}

.messages-container::-webkit-scrollbar {
    width: 6px;
}

.messages-container::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 6px;
}

/* ══════ WELCOME SCREEN ══════ */
.welcome-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 30px 20px;
    animation: fadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    max-width: 600px;
    margin: 0 auto;
}

@media (max-width: 768px) {
    .welcome-screen {
        justify-content: flex-start;
        padding-top: 40px;
        overflow-y: auto;
    }
}

/* Redesigned Welcome Avatar */
.welcome-avatar-wrap {
    position: relative;
    margin-bottom: 24px;
}

.welcome-avatar-wrap img {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: var(--primary-light);
    border: 4px solid #FFFFFF;
    box-shadow: 0 8px 24px rgba(76, 175, 130, 0.15);
}

/* Cute pulsing ring around avatar */
.welcome-avatar-wrap::before {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid var(--primary);
    opacity: 0.15;
    animation: avatarPulse 2.5s infinite;
}

@keyframes avatarPulse {
    0% { transform: scale(0.95); opacity: 0.2; }
    50% { transform: scale(1.05); opacity: 0.05; }
    100% { transform: scale(0.95); opacity: 0.2; }
}

.welcome-screen h2 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 10px;
    letter-spacing: -0.3px;
}

.welcome-screen p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    max-width: 420px;
    line-height: 1.6;
    margin-bottom: 30px;
}

/* Welcome quick actions (2x2 grid category cards) */
.welcome-categories {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    width: 100%;
    max-width: 520px;
}

@media (max-width: 480px) {
    .welcome-categories {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

.welcome-card {
    background: var(--accent-warm);
    border: 1px solid rgba(76, 175, 130, 0.12);
    border-radius: var(--radius-card);
    padding: 18px;
    text-align: left;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: var(--shadow-sm);
}

.welcome-card:nth-child(2) { background: var(--accent-blue); }
.welcome-card:nth-child(3) { background: var(--primary-pale); }
.welcome-card:nth-child(4) { background: var(--accent-yellow); }

.welcome-card:nth-child(1) .welcome-card-icon { color: #C4873B; }
.welcome-card:nth-child(2) .welcome-card-icon { color: #4A8CC7; }
.welcome-card:nth-child(3) .welcome-card-icon { color: var(--primary-dark); }
.welcome-card:nth-child(4) .welcome-card-icon { color: #B8941F; }

.welcome-card-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: #FFFFFF;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.02);
}

.welcome-card-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-primary);
}

.welcome-card-desc {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.welcome-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: rgba(76, 175, 130, 0.25);
}

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

/* ══════ MESSAGE BUBBLES ══════ */
.message {
    max-width: 80%;
    padding: 13px 18px;
    border-radius: var(--radius-bubble);
    font-size: 0.95rem;
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
    animation: msgIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes msgIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (max-width: 480px) {
    .message {
        max-width: 90%;
        font-size: 0.93rem;
    }
}

.user-message {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--bg-user-bubble-from), var(--bg-user-bubble-to));
    color: #FFFFFF;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(76, 175, 130, 0.15);
    animation: userMessageIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes userMessageIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.bot-message-container {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    align-self: flex-start;
    max-width: 85%;
    min-width: 0;
    animation: botMessageIn 1.0s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes botMessageIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (max-width: 480px) {
    .bot-message-container {
        max-width: 95%;
    }
}

.bot-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 2px;
    background: var(--primary-light);
    border: 2px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.bot-message-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    max-width: 100%;
}

.bot-message {
    background: var(--bg-bot-bubble);
    color: var(--text-primary);
    border-radius: var(--radius-bubble);
    border-bottom-left-radius: 4px;
    padding: 14px 18px 20px 22px;
    font-size: 0.95rem;
    line-height: 1.6;
    word-wrap: break-word;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    position: relative;
    box-shadow: var(--shadow-sm);
}

.bot-message::before {
    content: '';
    position: absolute;
    top: 14px;
    bottom: 14px;
    left: 8px;
    width: 3.5px;
    background: var(--primary);
    border-radius: 2px;
}

.bot-message.thinking {
    font-style: italic;
    color: var(--text-secondary);
}

.bot-message.thinking::before {
    background: var(--border);
}

.bot-message a {
    color: var(--primary-dark);
    word-break: break-all;
    font-weight: 600;
    text-decoration: underline;
    transition: var(--transition);
}

.bot-message a:hover {
    color: var(--primary);
}

/* Time stamps */
.msg-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
    display: block;
}

.user-message .msg-time {
    color: rgba(255, 255, 255, 0.7);
    text-align: right;
    margin-right: 4px;
}

.bot-message .msg-time {
    position: absolute;
    bottom: 6px;
    right: 14px;
    font-size: 0.68rem;
    color: var(--text-muted);
}

/* WhatsApp-style sequential message grouping gap reduction */
.bot-message-container + .bot-message-container {
    margin-top: -10px;
}

/* Response Category Badge */
.response-category-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--primary-light);
    color: var(--primary-dark);
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 700;
    margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(76, 175, 130, 0.15);
    width: fit-content;
}

.response-category-badge i {
    font-size: 0.9rem;
}

/* Response contextual image (visual responses) */
.response-image-wrapper {
    max-width: 320px;
    margin: 8px 0 12px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid #FFFFFF;
}

.response-image-wrapper:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-lg);
}

.response-image-wrapper img {
    width: 100%;
    display: block;
}

/* Fullscreen overlay for tapped images */
.image-fullscreen-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(45, 59, 53, 0.9);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    cursor: pointer;
    animation: fadeIn 0.25s ease;
}

.image-fullscreen-overlay img {
    max-width: 90vw;
    max-height: 85vh;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.3);
    border: 4px solid #FFFFFF;
}

@media (max-width: 480px) {
    .response-image-wrapper {
        max-width: 100%;
        margin: 8px 0 12px;
    }
}

/* Action buttons */
.msg-actions {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 2px;
    margin-left: 4px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border: 1px solid var(--border-light);
    background: #FFFFFF;
    color: var(--text-secondary);
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.action-btn:hover {
    background: var(--primary-light);
    color: var(--primary-dark);
    border-color: var(--primary-light);
    transform: translateY(-1px);
}

.action-btn.action-play,
.action-btn.action-save,
.action-btn.action-share {
    display: none !important;
}

.action-btn.action-play:hover {
    background: #E6F6F5;
    color: var(--accent-teal);
    border-color: #E6F6F5;
}

.action-btn.action-save:hover {
    background: #ECEEF8;
    color: var(--accent-indigo);
    border-color: #ECEEF8;
}

.action-btn.action-share:hover {
    background: #FCEEE9;
    color: var(--accent-coral);
    border-color: #FCEEE9;
}

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

.action-btn.speaking {
    color: var(--accent-teal);
    background: #E6F6F5;
    border-color: var(--accent-teal);
    animation: pulse-spk 1.5s infinite;
}

.action-btn svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
}

@keyframes pulse-spk {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Feedback buttons (👍 / 👎) */
.feedback-divider {
    display: none !important;
    width: 1px;
    height: 16px;
    background: var(--border);
    margin: 0 4px;
    align-self: center;
}

.action-btn.fb-btn:hover {
    background: var(--primary-pale);
    color: var(--primary-dark);
}

.action-btn.fb-up.active {
    color: #16A34A;
    background: #DCFCE7;
    border-color: #BBF7D0;
}

.action-btn.fb-down.active {
    color: #DC2626;
    background: #FEE2E2;
    border-color: #FECACA;
}

.action-btn.fb-btn.disabled {
    opacity: 0.35;
    pointer-events: none;
}

/* Resource card */
.resource-card {
    background: #FFFFFF;
    border: 1px solid var(--border-light);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius-card);
    padding: 12px 16px;
    margin-top: 8px;
    box-shadow: var(--shadow-sm);
}

.resource-source {
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--primary-dark);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 6px;
}

.resource-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--primary-dark);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 700;
}

.resource-link:hover {
    text-decoration: underline;
    color: var(--primary);
}

.alternate-card {
    border-left-color: var(--text-secondary);
}

.alternate-badge {
    display: inline-block;
    background: var(--text-secondary);
    color: #FFFFFF;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 700;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

/* ══════ RESOURCE CHIPS (inline-links) ══════ */
.inline-links {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    border-bottom: 1px solid var(--border-light);
    width: 100%;
}

.inline-links::-webkit-scrollbar {
    display: none;
}

.resource-header {
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.inline-link-btn {
    display: flex;
    flex-direction: column;
    min-width: 170px;
    max-width: 230px;
    padding: 12px 14px;
    background: #FFFFFF;
    border: 2px solid var(--primary-light);
    border-radius: 12px;
    color: var(--primary-dark);
    text-decoration: none;
    transition: var(--transition);
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
}

.inline-link-btn:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.inline-link-btn:active {
    transform: translateY(0);
}

.inline-link-label {
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 4px;
}

.inline-link-domain {
    font-size: 0.68rem;
    color: var(--text-secondary);
    font-weight: 400;
}

@media (max-width: 768px) {
    .inline-link-btn {
        min-width: 180px;
        padding: 12px 14px;
    }

    .inline-link-label {
        font-size: 0.9rem;
    }
}

/* ══════ SUMMARY POPUP CARD ══════ */
.summary-popup-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(45, 59, 53, 0.5);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

.summary-popup-overlay.open {
    display: flex;
}

.summary-popup-card {
    background: #FFFFFF;
    width: 92%;
    max-width: 500px;
    max-height: 80vh;
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popIn {
    from { transform: scale(0.92); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.summary-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--primary-pale), #FFFFFF);
    border-bottom: 1px solid var(--border-light);
}

.summary-popup-title {
    font-size: 0.98rem;
    font-weight: 800;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.summary-popup-title span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.summary-popup-close {
    background: var(--border-light);
    border: none;
    font-size: 1.4rem;
    color: var(--text-secondary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.summary-popup-close:hover {
    background: var(--border);
    color: var(--text-primary);
}

.summary-popup-visit {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 20px;
    background: var(--primary-light);
    text-decoration: none;
    color: var(--primary-dark);
    font-size: 0.82rem;
    font-weight: 700;
    transition: var(--transition);
    border-bottom: 1px solid var(--border-light);
}

.summary-popup-visit:hover {
    background: var(--primary);
    color: #FFFFFF;
}

.summary-popup-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    font-size: 0.9rem;
    line-height: 1.65;
    color: var(--text-primary);
}

.summary-popup-body strong {
    color: var(--text-primary);
}

.summary-popup-body ul {
    margin: 8px 0 12px 20px;
    padding: 0;
}

.summary-popup-body li {
    margin-bottom: 6px;
}

.summary-popup-loading {
    text-align: center;
    padding: 40px 0;
    color: var(--text-secondary);
    font-size: 0.88rem;
}

.summary-popup-loading .spinner-sm {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}

.show-more-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    padding: 10px 20px;
    background: #FFFFFF;
    border: 2px solid var(--primary);
    border-radius: 22px;
    color: var(--primary-dark);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.show-more-btn:hover {
    background: var(--primary);
    color: #FFFFFF;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

@media (max-width: 768px) {
    .show-more-btn {
        padding: 12px 24px;
        font-size: 0.92rem;
    }
}

.collapsible-extra {
    display: none;
}

.collapsible-extra.expanded {
    display: block;
}

/* Typing indicator */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 4px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--primary);
    opacity: 0.4;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(1) {
    background: var(--accent-teal);
}

.typing-indicator span:nth-child(2) {
    background: var(--accent-amber);
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    background: var(--accent-rose);
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* Suggestion chips — sticky floating bar above input */
.suggestion-chips-bar {
    display: none;
    padding: 10px 16px 6px;
    background: linear-gradient(180deg, rgba(255,255,255,0) 0%, #FFFFFF 100%);
    flex-shrink: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.suggestion-chips-bar::-webkit-scrollbar {
    display: none;
}

.suggestion-chips-bar.visible {
    display: block;
}

.suggestion-chips-bar .suggestion-chips {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    animation: fadeSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.suggestion-chip {
    background: #FAFAF7;
    border: 1.5px solid #E5E2DA;
    color: var(--text-primary);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.suggestion-chip:hover {
    background: var(--primary);
    color: #FFFFFF;
    border-color: var(--primary);
    transform: translateY(-1px);
}

.suggestion-chip:active {
    transform: translateY(0);
}

@media (max-width: 768px) {
    .suggestion-chips-bar {
        padding: 8px 12px;
    }

    .suggestion-chip {
        padding: 11px 18px;
        font-size: 0.9rem;
        border-radius: 24px;
    }
}

/* Category Quick Bar (visible during active chat) */
.category-quick-bar {
    display: none;
    padding: 8px 16px 6px;
    background: #FFFFFF;
    flex-shrink: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    border-top: 1px solid var(--border-light);
}

.category-quick-bar::-webkit-scrollbar {
    display: none;
}

.category-quick-bar.visible {
    display: flex;
    gap: 8px;
    align-items: center;
    animation: fadeSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.category-quick-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
    border: 1.5px solid rgba(76, 175, 130, 0.12);
}

.category-quick-chip i {
    font-size: 0.9rem;
}

/* Same colors as the welcome cards */
.category-quick-chip.bg-cat-1 {
    background: var(--accent-warm);
    color: var(--text-primary);
}
.category-quick-chip.bg-cat-1 i {
    color: #C4873B;
}

.category-quick-chip.bg-cat-2 {
    background: var(--accent-blue);
    color: var(--text-primary);
}
.category-quick-chip.bg-cat-2 i {
    color: #4A8CC7;
}

.category-quick-chip.bg-cat-3 {
    background: var(--primary-pale);
    color: var(--text-primary);
}
.category-quick-chip.bg-cat-3 i {
    color: var(--primary-dark);
}

.category-quick-chip.bg-cat-4 {
    background: var(--accent-yellow);
    color: var(--text-primary);
}
.category-quick-chip.bg-cat-4 i {
    color: #B8941F;
}

.category-quick-chip:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    border-color: rgba(76, 175, 130, 0.25);
}

.category-quick-chip:active {
    transform: translateY(0);
}

@media (max-width: 768px) {
    .category-quick-bar {
        padding: 6px 12px 6px;
    }
    .category-quick-chip {
        padding: 10px 16px;
        font-size: 0.88rem;
        border-radius: 22px;
    }
}

/* ══════ INPUT AREA ══════ */
.input-area {
    padding: 12px 20px 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border-light);
    background: #FFFFFF;
    flex-shrink: 0;
}

.input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-page);
    border: 1.5px solid var(--border);
    border-radius: 16px;
    padding: 6px 8px 6px 16px;
    transition: var(--transition);
}

.input-row:focus-within {
    border-color: var(--primary);
    background: #FFFFFF;
    box-shadow: 0 0 0 3px rgba(76, 175, 130, 0.12);
}

.chat-input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: 0.95rem;
    color: var(--text-primary);
    resize: none;
    line-height: 1.5;
    min-height: 24px;
    max-height: 110px;
    padding: 6px 0;
    font-family: inherit;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.chat-input::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}

.chat-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.8;
}

@media (max-width: 480px) {
    .chat-input {
        font-size: 16px; /* Prevents iOS auto-zoom */
    }
}

.voice-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: var(--transition);
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
}

.voice-btn:hover {
    color: var(--accent-rose);
    background: var(--accent-rose-light);
}

.voice-btn.recording {
    color: #FFFFFF;
    background: #EF4444;
    animation: pulse-mic 1.2s infinite;
}

@keyframes pulse-mic {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
    50% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
}

.send-btn {
    background: var(--primary);
    color: #FFFFFF;
    border: none;
    border-radius: 12px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition);
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(76, 175, 130, 0.2);
}

.send-btn:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

.cancel-btn {
    background-color: #EF4444 !important;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.2) !important;
}

/* ══════ SPECIAL DOCUMENT BLOCKS ══════ */
.bot-message br+br {
    display: none;
}

.bot-message p {
    margin: 0 0 8px 0;
}

.bot-message .disclaimer-block {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border-light);
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.bot-message .emergency-block {
    background-color: #FEF2F2;
    border-left: 4px solid #EF4444;
    padding: 12px 16px;
    margin-bottom: 16px;
    margin-top: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.03);
    font-size: 0.9rem;
    color: #991B1B;
    line-height: 1.55;
}

.bot-message .emergency-block strong {
    color: #991B1B !important;
}

.bot-message .advisory-block {
    background-color: #FFFBEB;
    border-left: 4px solid #F59E0B;
    padding: 12px 14px;
    margin-top: 14px;
    margin-bottom: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.03);
    font-size: 0.88rem;
    color: #92400E;
    line-height: 1.55;
}

.bot-message .advisory-block strong {
    color: #92400E !important;
}

/* ══════════════════════════════════════════════════════════
   HIGH CONTRAST ACCESSIBILITY MODES
   hc-mode-1 : Yellow-on-Black (cataracts / low vision)
   hc-mode-2 : White-on-Black (severe low vision / glare)
   ══════════════════════════════════════════════════════════ */
html.hc-mode-1,
html.hc-mode-2 {
    --hc-bg: #000000;
    --hc-surface: #0C0C0C;
    --hc-border: #666666;
    --hc-text: #FFE600; /* Yellow */
    --hc-subtext: #DDDD00;
    --hc-accent: #FFE600;
    --hc-btn-bg: #151500;
    --hc-input-bg: #101000;
}

html.hc-mode-2 {
    --hc-text: #FFFFFF; /* White */
    --hc-subtext: #E0E0E0;
    --hc-accent: #FFFFFF;
    --hc-btn-bg: #1A1A1A;
    --hc-input-bg: #0C0C0C;
}

html.hc-mode-1 body,
html.hc-mode-2 body {
    background: var(--hc-bg) !important;
    color: var(--hc-text) !important;
}

html.hc-mode-1 .page-wrapper,
html.hc-mode-2 .page-wrapper {
    background: var(--hc-bg) !important;
}

/* Sidebar */
html.hc-mode-1 .sidebar,
html.hc-mode-2 .sidebar {
    background: #000000 !important;
    border-right: 2px solid var(--hc-border) !important;
}

html.hc-mode-1 .sidebar-logo span,
html.hc-mode-2 .sidebar-logo span,
html.hc-mode-1 .history-item,
html.hc-mode-2 .history-item {
    color: var(--hc-text) !important;
}

html.hc-mode-1 .history-section-label,
html.hc-mode-2 .history-section-label {
    color: var(--hc-subtext) !important;
}

html.hc-mode-1 .history-item:hover,
html.hc-mode-2 .history-item:hover {
    background: rgba(255, 230, 0, 0.12) !important;
}

html.hc-mode-2 .history-item:hover {
    background: rgba(255, 255, 255, 0.12) !important;
}

html.hc-mode-1 .history-item.active,
html.hc-mode-2 .history-item.active {
    background: rgba(255, 230, 0, 0.22) !important;
    border-left-color: var(--hc-accent) !important;
    font-weight: 700;
}

html.hc-mode-2 .history-item.active {
    background: rgba(255, 255, 255, 0.22) !important;
}

html.hc-mode-1 .new-chat-btn,
html.hc-mode-2 .new-chat-btn {
    background: var(--hc-btn-bg) !important;
    color: var(--hc-text) !important;
    border: 2px solid var(--hc-accent) !important;
    box-shadow: none !important;
}

html.hc-mode-1 .sidebar-footer,
html.hc-mode-2 .sidebar-footer {
    color: var(--hc-subtext) !important;
}

/* Chat Header */
html.hc-mode-1 .chat-header,
html.hc-mode-2 .chat-header {
    background: #000000 !important;
    border-bottom: 2px solid var(--hc-accent) !important;
    color: var(--hc-text) !important;
}

html.hc-mode-1 .chat-header h1,
html.hc-mode-2 .chat-header h1 {
    color: var(--hc-text) !important;
}

html.hc-mode-1 .chat-header h1::after,
html.hc-mode-2 .chat-header h1::after {
    background: var(--hc-accent) !important;
}

html.hc-mode-1 .chat-header p,
html.hc-mode-2 .chat-header p {
    color: var(--hc-subtext) !important;
}

html.hc-mode-1 .icon-btn,
html.hc-mode-2 .icon-btn {
    background: var(--hc-btn-bg) !important;
    border: 1.5px solid var(--hc-border) !important;
    color: var(--hc-text) !important;
}

html.hc-mode-1 .icon-btn:hover,
html.hc-mode-2 .icon-btn:hover {
    border-color: var(--hc-accent) !important;
    background: var(--hc-accent) !important;
    color: #000000 !important;
}

/* Main & Chatbox */
html.hc-mode-1 .main-area,
html.hc-mode-2 .main-area {
    background: var(--hc-bg) !important;
}

html.hc-mode-1 .chat-box,
html.hc-mode-2 .chat-box {
    background: var(--hc-surface) !important;
    border: 2px solid var(--hc-border) !important;
    box-shadow: 0 0 0 3px var(--hc-accent) !important;
}

/* Messages */
html.hc-mode-1 .messages-container,
html.hc-mode-2 .messages-container {
    background: var(--hc-surface) !important;
}

html.hc-mode-1 .bot-message,
html.hc-mode-2 .bot-message {
    background: #111111 !important;
    color: var(--hc-text) !important;
    border: 2px solid var(--hc-border) !important;
    font-weight: 600 !important;
    box-shadow: none !important;
    padding: 14px 18px !important;
}

html.hc-mode-1 .bot-message::before,
html.hc-mode-2 .bot-message::before {
    display: none !important;
}

html.hc-mode-2 .bot-message {
    border-color: #888888 !important;
}

html.hc-mode-1 .user-message,
html.hc-mode-2 .user-message {
    background: #151500 !important;
    color: var(--hc-text) !important;
    border: 2px solid var(--hc-accent) !important;
    font-weight: 600 !important;
    box-shadow: none !important;
}

html.hc-mode-2 .user-message {
    background: #1A1A1A !important;
    border-color: #FFFFFF !important;
}

html.hc-mode-1 .bot-message a,
html.hc-mode-2 .bot-message a {
    color: var(--hc-accent) !important;
    text-decoration: underline !important;
    font-weight: 700 !important;
}

html.hc-mode-1 .bot-message .disclaimer-block,
html.hc-mode-2 .bot-message .disclaimer-block {
    border-top-color: var(--hc-border) !important;
    color: var(--hc-subtext) !important;
}

html.hc-mode-1 .msg-time,
html.hc-mode-2 .msg-time {
    color: var(--hc-subtext) !important;
}

/* Action buttons */
html.hc-mode-1 .action-btn,
html.hc-mode-2 .action-btn {
    background: var(--hc-btn-bg) !important;
    border: 1px solid var(--hc-border) !important;
    color: var(--hc-text) !important;
    box-shadow: none !important;
}

html.hc-mode-1 .action-btn:hover,
html.hc-mode-2 .action-btn:hover {
    background: var(--hc-accent) !important;
    color: #000000 !important;
    border-color: var(--hc-accent) !important;
}

/* Input Area */
html.hc-mode-1 .input-area,
html.hc-mode-2 .input-area {
    background: #000000 !important;
    border-top: 2px solid var(--hc-border) !important;
}

html.hc-mode-1 .input-row,
html.hc-mode-2 .input-row {
    background: var(--hc-input-bg) !important;
    border: 2px solid var(--hc-border) !important;
}

html.hc-mode-1 .input-row:focus-within,
html.hc-mode-2 .input-row:focus-within {
    border-color: var(--hc-accent) !important;
}

html.hc-mode-1 .chat-input,
html.hc-mode-2 .chat-input {
    color: var(--hc-text) !important;
    caret-color: var(--hc-accent) !important;
}

html.hc-mode-1 .chat-input::placeholder,
html.hc-mode-2 .chat-input::placeholder {
    color: #888800 !important;
}

html.hc-mode-2 .chat-input::placeholder {
    color: #888888 !important;
}

html.hc-mode-1 .send-btn,
html.hc-mode-2 .send-btn {
    background: var(--hc-btn-bg) !important;
    border: 2px solid var(--hc-accent) !important;
    color: var(--hc-text) !important;
    box-shadow: none !important;
}

html.hc-mode-1 .send-btn:hover:not(:disabled),
html.hc-mode-2 .send-btn:hover:not(:disabled) {
    background: #2D2D00 !important;
}

html.hc-mode-2 .send-btn:hover:not(:disabled) {
    background: #2D2D2D !important;
}

html.hc-mode-1 .voice-btn,
html.hc-mode-2 .voice-btn {
    color: var(--hc-subtext) !important;
}

html.hc-mode-1 .voice-btn:hover,
html.hc-mode-2 .voice-btn:hover {
    color: #000000 !important;
    background: var(--hc-accent) !important;
}

/* Category Badge in HC */
html.hc-mode-1 .response-category-badge,
html.hc-mode-2 .response-category-badge {
    background: var(--hc-btn-bg) !important;
    border: 2px solid var(--hc-accent) !important;
    color: var(--hc-text) !important;
    box-shadow: none !important;
}

/* Category Quick Bar & Chips in HC */
html.hc-mode-1 .category-quick-bar,
html.hc-mode-2 .category-quick-bar {
    background: var(--hc-bg) !important;
    border-top-color: var(--hc-border) !important;
}

html.hc-mode-1 .category-quick-chip,
html.hc-mode-2 .category-quick-chip {
    background: var(--hc-btn-bg) !important;
    border: 2px solid var(--hc-accent) !important;
    color: var(--hc-text) !important;
    box-shadow: none !important;
}

html.hc-mode-1 .category-quick-chip:hover,
html.hc-mode-2 .category-quick-chip:hover {
    background: var(--hc-accent) !important;
    color: #000000 !important;
}

/* Welcome screen in HC */
html.hc-mode-1 .welcome-screen h2,
html.hc-mode-2 .welcome-screen h2 {
    color: var(--hc-text) !important;
}

html.hc-mode-1 .welcome-screen p,
html.hc-mode-2 .welcome-screen p {
    color: var(--hc-subtext) !important;
}

html.hc-mode-1 .welcome-card,
html.hc-mode-2 .welcome-card {
    background: var(--hc-surface) !important;
    border: 2px solid var(--hc-border) !important;
}

html.hc-mode-1 .welcome-card:hover,
html.hc-mode-2 .welcome-card:hover {
    border-color: var(--hc-accent) !important;
}

html.hc-mode-1 .welcome-card-icon,
html.hc-mode-2 .welcome-card-icon {
    background: var(--hc-btn-bg) !important;
    color: var(--hc-accent) !important;
    border: 1px solid var(--hc-border) !important;
}

html.hc-mode-1 .welcome-card-title,
html.hc-mode-2 .welcome-card-title {
    color: var(--hc-text) !important;
}

html.hc-mode-1 .welcome-card-desc,
html.hc-mode-2 .welcome-card-desc {
    color: var(--hc-subtext) !important;
}

/* Suggestion chips in HC */
html.hc-mode-1 .suggestion-chips-bar,
html.hc-mode-2 .suggestion-chips-bar {
    background: var(--hc-bg) !important;
}

html.hc-mode-1 .suggestion-chip,
html.hc-mode-2 .suggestion-chip {
    background: var(--hc-btn-bg) !important;
    border: 2px solid var(--hc-accent) !important;
    color: var(--hc-text) !important;
    box-shadow: none !important;
}

html.hc-mode-1 .suggestion-chip:hover,
html.hc-mode-2 .suggestion-chip:hover {
    background: var(--hc-accent) !important;
    color: #000000 !important;
}

/* Resource inline link cards in HC */
html.hc-mode-1 .inline-link-btn,
html.hc-mode-2 .inline-link-btn {
    background: #000000 !important;
    border: 2px solid var(--hc-accent) !important;
    color: var(--hc-text) !important;
}

html.hc-mode-1 .resource-card,
html.hc-mode-2 .resource-card {
    background: var(--hc-surface) !important;
    border: 2px solid var(--hc-border) !important;
    border-left-color: var(--hc-accent) !important;
}

/* Language dropdown in HC */
html.hc-mode-1 .lang-dropdown,
html.hc-mode-2 .lang-dropdown {
    background: #000000 !important;
    border: 2px solid var(--hc-border) !important;
}

html.hc-mode-1 .lang-option,
html.hc-mode-2 .lang-option {
    color: var(--hc-text) !important;
}

html.hc-mode-1 .lang-option:hover,
html.hc-mode-2 .lang-option:hover {
    background: rgba(255, 230, 0, 0.15) !important;
}

html.hc-mode-2 .lang-option:hover {
    background: rgba(255, 255, 255, 0.15) !important;
}

html.hc-mode-1 .lang-option.active,
html.hc-mode-2 .lang-option.active {
    background: rgba(255, 230, 0, 0.25) !important;
    color: var(--hc-accent) !important;
}

html.hc-mode-2 .lang-option.active {
    background: rgba(255, 255, 255, 0.25) !important;
}

/* HC active toggle buttons rings */
.hc-toggle-btn.hc-active-1 {
    background: #151500 !important;
    border: 2px solid #FFE600 !important;
    color: #FFE600 !important;
    box-shadow: 0 0 10px 2px rgba(255, 230, 0, 0.5) !important;
}

.hc-toggle-btn.hc-active-2 {
    background: #1A1A1A !important;
    border: 2px solid #FFFFFF !important;
    color: #FFFFFF !important;
    box-shadow: 0 0 10px 2px rgba(255, 255, 255, 0.5) !important;
}

/* HC toast notification */
#hcToast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #111111;
    color: #FFE600;
    border: 2px solid #FFE600;
    border-radius: 12px;
    padding: 12px 24px;
    font-size: 0.9rem;
    font-weight: 700;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 9999;
    white-space: nowrap;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

#hcToast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ══════ VIDEO MODAL ══════ */
.video-modal {
    display: none;
    position: fixed;
    z-index: 2000;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    align-items: center;
    justify-content: center;
}

.video-modal-content {
    position: relative;
    width: 90%;
    max-width: 880px;
    aspect-ratio: 16/9;
    background: #000000;
    border-radius: 12px;
    overflow: hidden;
}

.video-modal-close {
    position: absolute;
    top: -44px;
    right: 0;
    color: #FFFFFF;
    font-size: 32px;
    cursor: pointer;
    transition: var(--transition);
}

.video-modal-close:hover {
    color: #EF4444;
}

/* ══════ CARD DOWNLOAD MODAL ══════ */
.card-modal-overlay {
    display: none;
    position: fixed;
    z-index: 3000;
    inset: 0;
    background: rgba(45, 59, 53, 0.4);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: fadeIn 0.25s ease;
}

.card-modal-overlay.show {
    display: flex;
}

.card-modal {
    background: #FFFFFF;
    border-radius: 20px;
    padding: 24px;
    width: 100%;
    max-width: 530px;
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
    border: 1px solid var(--border);
}

.card-modal h3 {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-primary);
}

.card-preview {
    border-radius: 14px;
    padding: 24px;
    min-height: 150px;
    max-height: 280px;
    overflow-y: auto !important;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
}

/* Premium slim dark-sage scrollbar for card preview */
.card-preview {
    scrollbar-width: thin;
    scrollbar-color: rgba(45, 59, 53, 0.25) transparent;
}
.card-preview::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.card-preview::-webkit-scrollbar-track {
    background: transparent;
}
.card-preview::-webkit-scrollbar-thumb {
    background: rgba(45, 59, 53, 0.25) !important;
    border-radius: 10px;
}
.card-preview::-webkit-scrollbar-thumb:hover {
    background: rgba(45, 59, 53, 0.5) !important;
}

.card-preview.bg-1 {
    background: linear-gradient(135deg, #D1FAE5, #A7F3D0);
}

.card-preview.bg-2 {
    background: linear-gradient(135deg, #E0F2FE, #BAE6FD);
}

.card-preview.bg-3 {
    background: linear-gradient(135deg, #FEF3C7, #FDE68A);
}

.card-preview-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.card-preview-logo img {
    height: 24px;
    width: 24px;
    border-radius: 50%;
    object-fit: cover;
}

.card-preview-logo span {
    font-size: 0.8rem;
    font-weight: 700;
    color: #374151;
}

.card-preview-text {
    font-size: 0.98rem;
    color: #111827;
    font-weight: 500;
    line-height: 1.6;
}

.card-controls {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.ctrl-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ctrl-row label {
    font-size: 0.83rem;
    font-weight: 700;
    color: var(--text-primary);
    min-width: 80px;
}

.bg-options {
    display: flex;
    gap: 10px;
}

.bg-swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: var(--transition);
}

.bg-swatch.active {
    border-color: var(--primary);
    transform: scale(1.15);
}

.bg-swatch.s1 {
    background: linear-gradient(135deg, #D1FAE5, #A7F3D0);
}

.bg-swatch.s2 {
    background: linear-gradient(135deg, #E0F2FE, #BAE6FD);
}

.bg-swatch.s3 {
    background: linear-gradient(135deg, #FEF3C7, #FDE68A);
}

.card-font-slider {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border);
    border-radius: 4px;
    outline: none;
    cursor: pointer;
}

.card-font-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary);
    border: 2.5px solid #FFFFFF;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.card-modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-cancel-btn {
    padding: 10px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-btn);
    background: #FFFFFF;
    color: var(--text-primary);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.modal-cancel-btn:hover {
    background: var(--bg-page);
}

.modal-download-btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-btn);
    background: var(--primary);
    color: #FFFFFF;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

.modal-download-btn:hover {
    background: var(--primary-dark);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ══════ CONFIRMATION (DELETE) MODAL ══════ */
.confirm-modal-overlay {
    display: none;
    position: fixed;
    z-index: 3100;
    inset: 0;
    background: rgba(45, 59, 53, 0.4);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: fadeIn 0.25s ease;
}

.confirm-modal-overlay.show {
    display: flex;
}

.confirm-modal {
    background: #FFFFFF;
    border-radius: 20px;
    padding: 28px 24px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scaleIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.confirm-modal-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent-rose-light);
    color: var(--accent-rose);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    margin-bottom: 18px;
}

.confirm-modal h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
    letter-spacing: -0.2px;
}

.confirm-modal p {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 24px;
}

.confirm-modal-footer {
    display: flex;
    gap: 12px;
    width: 100%;
    justify-content: stretch;
}

.confirm-modal-footer button {
    flex: 1;
    padding: 11px 20px;
    border-radius: var(--radius-btn);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.confirm-cancel-btn {
    border: 1px solid var(--border);
    background: #FFFFFF;
    color: var(--text-primary);
}

.confirm-cancel-btn:hover {
    background: var(--bg-page);
}

.confirm-delete-btn {
    border: none;
    background: var(--accent-rose);
    color: #FFFFFF;
    box-shadow: 0 4px 12px rgba(212, 105, 122, 0.2);
}

.confirm-delete-btn:hover {
    background: #C45566;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(212, 105, 122, 0.3);
}

.confirm-delete-btn:active {
    transform: translateY(0);
}

/* High Contrast for Custom Confirm Modal */
html.hc-mode-1 .confirm-modal-overlay,
html.hc-mode-2 .confirm-modal-overlay {
    background: rgba(0, 0, 0, 0.8) !important;
}

html.hc-mode-1 .confirm-modal,
html.hc-mode-2 .confirm-modal {
    background: var(--hc-surface) !important;
    border: 2px solid var(--hc-border) !important;
    box-shadow: 0 0 0 3px var(--hc-accent) !important;
}

html.hc-mode-1 .confirm-modal-icon,
html.hc-mode-2 .confirm-modal-icon {
    background: var(--hc-btn-bg) !important;
    color: var(--hc-text) !important;
    border: 2px solid var(--hc-border) !important;
}

html.hc-mode-1 .confirm-modal h3,
html.hc-mode-2 .confirm-modal h3,
html.hc-mode-1 .confirm-modal p,
html.hc-mode-2 .confirm-modal p {
    color: var(--hc-text) !important;
}

html.hc-mode-1 .confirm-cancel-btn,
html.hc-mode-2 .confirm-cancel-btn {
    background: var(--hc-btn-bg) !important;
    border: 2.5px solid var(--hc-border) !important;
    color: var(--hc-text) !important;
}

html.hc-mode-1 .confirm-cancel-btn:hover,
html.hc-mode-2 .confirm-cancel-btn:hover {
    background: var(--hc-accent) !important;
    color: #000000 !important;
    border-color: var(--hc-accent) !important;
}

html.hc-mode-1 .confirm-delete-btn,
html.hc-mode-2 .confirm-delete-btn {
    background: var(--hc-btn-bg) !important;
    border: 2.5px solid var(--hc-accent) !important;
    color: var(--hc-text) !important;
    box-shadow: none !important;
}

html.hc-mode-1 .confirm-delete-btn:hover,
html.hc-mode-2 .confirm-delete-btn:hover {
    background: var(--hc-accent) !important;
    color: #000000 !important;
    border-color: var(--hc-accent) !important;
}

/* ══════ MODERN DYNAMIC STATUS INDICATOR ══════ */
.typing-status-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 2px 4px;
}

.typing-status-text {
    font-size: 0.88rem;
    color: var(--text-secondary);
    font-style: normal;
    font-weight: 600;
    letter-spacing: 0.2px;
}

/* Modern Slack/Discord Bouncing Dots for Typing */
.typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 16px;
    padding: 2px 4px;
}

.typing-dots span {
    width: 10px;
    height: 10px;
    background: var(--primary);
    border-radius: 50%;
    display: inline-block;
    animation: typing-bounce 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
    background: var(--accent-teal);
}

.typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
    background: var(--accent-amber);
}

.typing-dots span:nth-child(3) {
    background: var(--accent-rose);
}

@keyframes typing-bounce {
    0%, 80%, 100% { 
        transform: translateY(0);
        opacity: 0.5;
    } 
    40% { 
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* Elegant Glowing Neural Pulse for Thinking */
.thinking-pulse-wrap {
    position: relative;
    width: 14px;
    height: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 2px;
}

.thinking-pulse-dot {
    width: 6px;
    height: 6px;
    background: var(--primary);
    border-radius: 50%;
    z-index: 2;
    box-shadow: 0 0 8px var(--primary);
}

.thinking-pulse-ring {
    position: absolute;
    width: 14px;
    height: 14px;
    border: 2px solid var(--primary);
    border-radius: 50%;
    animation: thinking-ring-pulse 1.8s cubic-bezier(0.215, 0.610, 0.355, 1) infinite;
    opacity: 0.8;
}

@keyframes thinking-ring-pulse {
    0% {
        transform: scale(0.5);
        opacity: 0.8;
        border-color: var(--accent-teal);
    }
    50% {
        border-color: var(--accent-amber);
    }
    100% {
        transform: scale(1.6);
        opacity: 0;
        border-color: var(--accent-rose);
    }
}
