.ai-counsellor-page {
    background: #eef3f8;
    color: #0f172a;
    margin: 0;
    padding: 0;
}

html.ai-counsellor-page,
body.ai-counsellor-page {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100vh;
    height: 100dvh;
    width: 100%;
    overflow: hidden !important;
    margin: 0;
    padding: 0;
}

.ai-counsellor-page > header,
.ai-counsellor-page > footer {
    display: none !important;
}

.ai-counsellor-main {
    height: 100vh;
    height: 100dvh;
    padding: 0;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ai-counsellor-shell {
    width: 100%;
    height: 100%;
    min-height: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.counsellor-backdrop {
    position: fixed;
    top: 76px;
    right: 0;
    bottom: 0;
    left: 0;
    display: block;
    background: rgba(15, 23, 42, 0.42);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
    z-index: 1200;
}

.counsellor-sidebar-open .counsellor-backdrop {
    opacity: 1;
    pointer-events: auto;
}

.counsellor-profile-panel,
.ai-counsellor-chat {
    background: #ffffff;
    border: 1px solid #d7e1ea;
    border-radius: 8px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

.counsellor-profile-panel {
    position: fixed;
    top: 76px;
    bottom: 0;
    left: 0;
    width: min(86vw, 320px);
    height: calc(100vh - 76px);
    max-height: none;
    padding: 14px;
    border-radius: 0 8px 8px 0;
    transform: translateX(-104%);
    transition: transform 0.24s ease;
    z-index: 1300;
    overflow-y: auto;
    box-shadow: 16px 0 36px rgba(15, 23, 42, 0.16);
    background: #ffffff;
    border: 1px solid #d7e1ea;
    border-top: 3px solid #2563eb;
}

.counsellor-sidebar-open .counsellor-profile-panel {
    transform: translateX(0);
}

.counsellor-panel-top {
    display: grid;
    grid-template-columns: 42px 1fr auto;
    align-items: center;
    gap: 10px;
    padding-bottom: 14px;
    border-bottom: 1px solid #e3eaf2;
}

.counsellor-panel-icon {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: #eff6ff;
    color: #2563eb;
    font-size: 1.3rem;
}

.counsellor-panel-top h1 {
    margin: 0;
    color: #0f172a;
    font-size: 1.05rem;
    line-height: 1.2;
    letter-spacing: 0;
}

.counsellor-profile-status {
    margin: 3px 0 0;
    color: #64748b;
    font-size: 0.82rem;
}

.counsellor-sidebar-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid #d7e1ea;
    border-radius: 8px;
    background: #ffffff;
    color: #334155;
    cursor: pointer;
    font-size: 1.1rem;
}

.counsellor-profile-list {
    display: grid;
    gap: 8px;
    margin: 14px 0;
}

.counsellor-profile-row {
    display: grid;
    gap: 4px;
    min-height: 58px;
    padding: 10px 11px;
    border: 1px solid #e2e8f0;
    border-left: 3px solid #2563eb;
    border-radius: 8px;
    background: #f8fafc;
}

.counsellor-profile-label {
    color: #64748b;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.counsellor-profile-value {
    color: #102033;
    font-size: 0.96rem;
    font-weight: 700;
    line-height: 1.32;
    overflow-wrap: anywhere;
}

.counsellor-actions {
    display: grid;
    gap: 8px;
    padding-top: 14px;
    border-top: 1px solid #e3eaf2;
}

.counsellor-action-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid #d7e1ea;
    border-radius: 8px;
    background: #ffffff;
    color: #1e293b;
    text-decoration: none;
    font-size: 0.93rem;
    font-weight: 700;
    transition: border-color 0.18s ease, color 0.18s ease, background-color 0.18s ease;
}

.counsellor-action-link:hover {
    border-color: #2563eb;
    background: #f8fafc;
    color: #1d4ed8;
}

.ai-counsellor-page .chatbot-container.ai-counsellor-chat {
    position: relative;
    inset: auto;
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: none;
    display: flex;
    flex-direction: column;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
    overflow: hidden;
}

.ai-counsellor-page .chatbot-container.ai-counsellor-chat header {
    min-height: 78px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    color: #0f172a;
    background: #ffffff;
    border-bottom: 1px solid #e3eaf2;
    box-shadow: none;
}

.counsellor-sidebar-toggle {
    display: inline-flex;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border: 1px solid #d7e1ea;
    border-radius: 8px;
    background: #f8fafc;
    color: #1e293b;
    cursor: pointer;
    font-size: 1.25rem;
    flex: 0 0 auto;
}

.counsellor-back-btn {
    display: inline-flex;
    background: none;
    border: none;
    margin-right: 8px;
    cursor: pointer;
    color: #1e293b;
    padding: 5px;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.counsellor-sidebar-toggle:hover,
.counsellor-sidebar-close:hover {
    border-color: #2563eb;
    color: #1d4ed8;
}

.ai-counsellor-page .header-content {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-counsellor-page .header-logo {
    width: 40px;
    height: 40px;
    padding: 3px;
    border: 1px solid #e3eaf2;
    border-radius: 8px;
    background: #ffffff;
    object-fit: contain;
    flex: 0 0 auto;
}

.counsellor-chat-title {
    min-width: 0;
}

.ai-counsellor-page .chatbot-container header h2 {
    margin: 0;
    color: #0f172a;
    font-size: 1.08rem;
    line-height: 1.2;
    letter-spacing: 0;
}

.counsellor-chat-title p {
    margin: 3px 0 0;
    color: #64748b;
    font-size: 0.82rem;
    font-weight: 500;
}

.counsellor-badge {
    display: inline-flex;
    align-items: center;
    margin-top: 7px;
    padding: 5px 8px;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #475569;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.ai-counsellor-page .chatbot-container.ai-counsellor-chat .chatbox {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    margin: 0;
    padding: 10px 18px 18px;
    overflow-y: auto;
    list-style: none;
    background: #ffffff;
}

.ai-counsellor-page .chatbox .chat {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    list-style: none;
}

.ai-counsellor-page .chatbox .incoming {
    width: 100%;
    margin: 0;
    padding: 18px 0;
    justify-content: flex-start;
    border-bottom: 1px solid #eef2f7;
}

.ai-counsellor-page .chatbox .outgoing {
    margin: 18px 0 10px;
    justify-content: flex-end;
}

.ai-counsellor-page .chatbox .incoming .chatbot-logo {
    width: 32px;
    height: 32px;
    padding: 4px;
    border: 1px solid #e3eaf2;
    border-radius: 8px;
    background: #f8fafc;
    object-fit: contain;
    flex: 0 0 auto;
    margin-top: 2px;
}

.ai-counsellor-page .chatbox .message-bubble {
    white-space: normal;
    line-height: 1.58;
    overflow-wrap: anywhere;
}

.ai-counsellor-page .chatbox .incoming .message-bubble {
    width: min(780px, calc(100% - 48px));
    max-width: min(780px, calc(100% - 48px));
    padding: 2px 0 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #1e293b;
    box-shadow: none;
}

.ai-counsellor-page .chatbox .outgoing .message-bubble {
    max-width: min(680px, 82%);
    padding: 11px 14px;
    border-radius: 8px;
    background: #f1f5f9;
    color: #0f172a;
    box-shadow: none;
}

.ai-counsellor-page .chatbox .message-bubble > :first-child {
    margin-top: 0;
}

.ai-counsellor-page .chatbox .message-bubble > :last-child {
    margin-bottom: 0;
}

.ai-counsellor-page .chatbox .message-bubble p {
    margin: 0 0 0.75rem;
    color: inherit;
    background: transparent;
    padding: 0;
    max-width: none;
    border-radius: 0;
}

.ai-counsellor-page .chatbox .message-bubble h1,
.ai-counsellor-page .chatbox .message-bubble h2,
.ai-counsellor-page .chatbox .message-bubble h3 {
    margin: 0.85rem 0 0.45rem;
    color: inherit;
    font-size: 1rem;
    line-height: 1.35;
    letter-spacing: 0;
}

.ai-counsellor-page .chatbox .message-bubble ul,
.ai-counsellor-page .chatbox .message-bubble ol {
    padding-left: 1.2rem;
    margin: 0 0 0.8rem;
    list-style-position: outside;
}

.ai-counsellor-page .chatbox .message-bubble li {
    display: list-item;
    margin-bottom: 0.38rem;
    line-height: 1.55;
}

.ai-counsellor-page .chatbox .message-bubble li::before {
    content: none;
}

.ai-counsellor-page .chatbox .message-bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.8rem 0;
    font-size: 0.9rem;
}

.ai-counsellor-page .chatbox .message-bubble th,
.ai-counsellor-page .chatbox .message-bubble td {
    border: 1px solid #d7e1ea;
    padding: 8px 10px;
    text-align: left;
}

.ai-counsellor-page .chatbox .message-bubble th {
    background: #f8fafc;
    font-weight: 800;
}

.ai-counsellor-page .chatbox .message-bubble.error {
    border-color: #fecaca;
    background: #fff7f7;
    color: #991b1b;
}

.streaming-caret {
    display: inline-block;
    width: 2px;
    height: 1em;
    margin-left: 3px;
    vertical-align: -0.15em;
    background: #2563eb;
    animation: counsellor-caret-blink 0.9s steps(1, end) infinite;
}

@keyframes counsellor-caret-blink {
    0%,
    49% {
        opacity: 1;
    }
    50%,
    100% {
        opacity: 0;
    }
}

.ai-counsellor-page .chatbot-container.ai-counsellor-chat .chat-input {
    position: static;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 14px 14px;
    background: #ffffff;
    border-top: 1px solid #e3eaf2;
    box-shadow: none;
}

.ai-counsellor-page .chat-input textarea {
    min-height: 50px;
    max-height: 132px;
    width: 100%;
    padding: 12px 13px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #ffffff;
    color: #0f172a;
    font-family: inherit;
    font-size: 0.97rem;
    line-height: 1.35;
    resize: none;
    outline: none;
    box-shadow: none;
}

.ai-counsellor-page .chat-input textarea:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.ai-counsellor-page .chat-input span#send-btn {
    width: 48px;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 48px;
    border-radius: 8px;
    background: #1d4ed8;
    color: #ffffff;
    cursor: pointer;
    font-size: 1.75rem;
    opacity: 1;
    box-shadow: 0 8px 16px rgba(29, 78, 216, 0.16);
    transition: background-color 0.18s ease, opacity 0.18s ease, transform 0.18s ease;
}

.ai-counsellor-page .chat-input span#send-btn:hover {
    background: #1e40af;
}

.ai-counsellor-page .chat-input span#send-btn.is-loading {
    opacity: 0.62;
    cursor: progress;
    pointer-events: none;
}

@media (max-width: 900px) {
    html.ai-counsellor-page,
    body.ai-counsellor-page {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        height: 100dvh;
        width: 100%;
        overflow: hidden !important;
        padding: 0;
    }

    .ai-counsellor-page > header {
        display: none !important;
    }

    .ai-counsellor-page > header .logo-container {
        display: none;
    }

    .ai-counsellor-page .menu-toggle {
        display: block;
        order: 1;
    }

    .ai-counsellor-page .nav-controls-wrapper {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 0.5rem;
    }

    .ai-counsellor-page .mobile-header-controls {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }

    .ai-counsellor-page .auth-container {
        order: 2;
    }

    .ai-counsellor-page nav#main-nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: #ffffff;
        box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
        border-top: 1px solid #e0e0e0;
        flex-direction: column;
        z-index: 1100;
    }

    .ai-counsellor-page nav#main-nav.nav-active {
        display: flex;
    }

    .ai-counsellor-page nav#main-nav a {
        width: 100%;
        margin-left: 0;
        padding: 1rem 1.2rem;
        text-align: center;
        border-bottom: 1px solid #f0f0f0;
    }

    .ai-counsellor-page nav#main-nav a:last-child {
        border-bottom: none;
    }
    .ai-counsellor-main {
        height: 100dvh !important;
        margin-top: 0 !important;
        padding: 0;
        background: #ffffff;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .counsellor-back-btn {
        display: inline-flex !important;
    }

    .ai-counsellor-shell {
        flex: 1;
        padding: 0 0 16px;
        display: flex;
        flex-direction: column;
        min-height: 0;
        overflow: hidden;
    }

    .ai-counsellor-shell > section:last-child {
        flex: 1;
        display: flex;
        flex-direction: column;
    }

    .counsellor-profile-panel {
        width: min(92vw, 320px);
    }

    .ai-counsellor-page .chatbot-container.ai-counsellor-chat header {
        padding: 10px 12px;
    }

    .ai-counsellor-page .chat-input {
        gap: 8px;
    }

    .ai-counsellor-shell {
        width: 100%;
        height: 100%;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .ai-counsellor-shell > section:last-child {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    .counsellor-backdrop {
        position: fixed;
        top: 70px;
        right: 0;
        bottom: 0;
        left: 0;
        display: block;
        background: rgba(15, 23, 42, 0.42);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.22s ease;
        z-index: 1200;
    }

    .counsellor-sidebar-open .counsellor-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .counsellor-profile-panel {
        position: fixed;
        top: 70px;
        bottom: 0;
        left: 0;
        width: min(86vw, 320px);
        height: calc(100dvh - 70px);
        max-height: none;
        padding: 14px;
        border-radius: 0 8px 8px 0;
        transform: translateX(-104%);
        transition: transform 0.24s ease;
        z-index: 1300;
        overflow-y: auto;
        box-shadow: 16px 0 36px rgba(15, 23, 42, 0.16);
    }

    .counsellor-sidebar-open .counsellor-profile-panel {
        transform: translateX(0);
    }

    .counsellor-sidebar-close,
    .counsellor-sidebar-toggle {
        display: inline-flex;
    }

    .ai-counsellor-page .chatbot-container.ai-counsellor-chat {
        height: 100%;
        min-height: 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .ai-counsellor-page .chatbot-container.ai-counsellor-chat header {
        min-height: 64px;
        padding: 10px 12px;
        gap: 10px;
    }

    .ai-counsellor-page .header-logo {
        width: 36px;
        height: 36px;
    }

    .ai-counsellor-page .chatbot-container header h2 {
        font-size: 1.02rem;
    }

    .counsellor-chat-title p {
        max-width: 235px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 0.76rem;
    }

    .counsellor-badge {
        display: none;
    }

    .ai-counsellor-page .chatbot-container.ai-counsellor-chat .chatbox {
        padding: 14px 12px;
    }

    .ai-counsellor-page .chatbox .incoming .chatbot-logo {
        display: inline-flex;
        width: 28px;
        height: 28px;
        padding: 3px;
    }

    .ai-counsellor-page .chatbox .incoming {
        gap: 9px;
        padding: 16px 0;
    }

    .ai-counsellor-page .chatbox .incoming .message-bubble {
        width: calc(100% - 37px);
        max-width: calc(100% - 37px);
        font-size: 0.92rem;
    }

    .ai-counsellor-page .chatbox .outgoing .message-bubble {
        max-width: 88%;
        font-size: 0.92rem;
    }

    .ai-counsellor-page .chatbot-container.ai-counsellor-chat .chat-input {
        padding: 10px;
    }

    .ai-counsellor-page .chat-input textarea {
        min-height: 46px;
        font-size: 0.95rem;
    }

    .ai-counsellor-page .chat-input span#send-btn {
        width: 46px;
        height: 46px;
        flex-basis: 46px;
    }
}

@media (max-width: 430px) {
    .ai-counsellor-page > header {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .ai-counsellor-page > header .logo-name {
        font-size: 0.92rem;
    }

    .ai-counsellor-page .btn-login {
        padding: 0.55rem 0.85rem;
        font-size: 0.84rem;
    }

    .counsellor-profile-panel {
        width: 88vw;
    }

    .counsellor-chat-title p {
        max-width: 180px;
    }
}
