* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f3f4f6;
    color: #111827;
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 320px;
    background: #0f172a;
    color: white;
    display: flex;
    flex-direction: column;
    padding: 24px 18px;
}

.sidebar-top {
    margin-bottom: 24px;
}

.brand-block {
    margin-bottom: 18px;
}

.brand-name {
    margin: 0;
    font-size: 32px;
    line-height: 1;
    font-weight: 800;
}

.brand-tag {
    margin: 8px 0 0;
    color: #cbd5e1;
    font-size: 14px;
}

.new-chat-btn {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #334155;
    border-radius: 12px;
    background: white;
    color: #111827;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}

.new-chat-btn:hover {
    opacity: 0.95;
}

.history-section {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
}

.history-header {
    font-size: 14px;
    color: #cbd5e1;
    margin-bottom: 10px;
}

.chat-history {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-item {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 14px;
    padding: 12px;
    cursor: pointer;
}

.history-item:hover {
    background: #273449;
}

.history-item.active {
    border-color: white;
}

.history-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 6px;
    color: white;
}

.history-preview {
    font-size: 12px;
    color: #cbd5e1;
    line-height: 1.4;
}

.history-actions {
    margin-top: 10px;
    display: flex;
    justify-content: flex-end;
}

.delete-chat-btn {
    border: none;
    background: transparent;
    color: #fca5a5;
    cursor: pointer;
    font-size: 12px;
    padding: 0;
}

.main-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 24px;
}

.topbar {
    margin-bottom: 18px;
}

.header {
    background: white;
    border-radius: 22px;
    padding: 24px 28px;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08);

    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
        "title flag"
        "subtitle subtitle";
    align-items: center;
    column-gap: 10px;
    row-gap: 8px;
}

.main-title {
    grid-area: title;
    margin: 0;
    font-size: 42px;
    font-weight: 800;
    line-height: 1;
    word-break: break-word;
}

.sub-title {
    grid-area: subtitle;
    margin: 0;
    font-size: 18px;
    color: #6b7280;
    font-weight: 600;
}

.chat-box {
    flex: unset;              /* 🔥 THIS is the real fix */
    max-height: 60vh;         /* controls height nicely */
    min-height: 180px;        /* keeps it usable */

    background: white;
    border-radius: 22px;
    padding: 24px;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;

    justify-content: flex-start; /* keeps content at top */
}

.welcome-card {
    margin: 0 auto;              /* center horizontally only */
    margin-top: 40px;            /* control vertical position */
    max-width: 520px;
    text-align: center;
    color: #475569;
}

.welcome-icon {
    font-size: 42px;
    margin-bottom: 12px;
}

.message-row {
    display: flex;
    width: 100%;
}

.message-row.user {
    justify-content: flex-end;
}

.message-row.bot {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 72%;
    padding: 14px 16px;
    border-radius: 18px;
    line-height: 1.5;
    font-size: 15px;
    white-space: pre-wrap;
}

.message-row.user .message-bubble {
    background: #111827;
    color: white;
    border-bottom-right-radius: 6px;
}

.message-row.bot .message-bubble {
    background: #f1f5f9;
    color: #111827;
    border-bottom-left-radius: 6px;
}

.source-block {
    margin-top: 8px;
    font-size: 12px;
    color: #64748b;
}

.status-bar {
    margin-top: 14px;
    background: white;
    border-radius: 18px;
    padding: 14px 18px;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.06);
}

.hidden {
    display: none;
}

.thinking-wrap {
    display: flex;
    align-items: center;
    gap: 14px;
}

.thinking-text {
    color: #334155;
    font-size: 14px;
    font-weight: 600;
}

.brain-loader {
    position: relative;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.brain-core {
    position: absolute;
    font-size: 20px;
    z-index: 2;
    animation: pulseBrain 1.2s infinite ease-in-out;
}

.brain-ring {
    position: absolute;
    border: 2px solid #94a3b8;
    border-radius: 50%;
    animation: spinRing 1.5s linear infinite;
}

.ring-1 {
    width: 34px;
    height: 34px;
}

.ring-2 {
    width: 42px;
    height: 42px;
    animation-duration: 2.2s;
    border-color: #cbd5e1;
}

@keyframes spinRing {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes pulseBrain {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.12); }
}

.input-panel {
    margin-top: 18px;
    background: white;
    border-radius: 22px;
    padding: 16px;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
    display: flex;
    gap: 12px;
    align-items: center;
}

#question {
    flex: 1;
    border: 1px solid #cbd5e1;
    border-radius: 16px;
    padding: 16px 18px;
    font-size: 16px;
    outline: none;
}

#question:focus {
    border-color: #111827;
}

.ask-btn,
.speak-btn {
    min-width: 110px;
    border: none;
    color: white;
    border-radius: 16px;
    padding: 16px 20px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    height: 58px;

    display: flex;
    align-items: center;
    justify-content: center;
}

.ask-btn {
    background: #111827;
}

.ask-btn.stop-mode {
    background: #991b1b;
}

.speak-btn {
    background: #1f2a44;
}

.speak-btn:hover {
    background: #162038;
}

.speak-btn.listening {
    background: #b91c1c;
}

.empty-history {
    color: #94a3b8;
    font-size: 13px;
}



.welcome-text {
    max-width: 760px;
    margin: 0 auto 18px auto;
    font-size: 16px;
    line-height: 1.7;
    color: #475569;
}

.prompt-chip-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin-top: 18px;
}

.prompt-chip {
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #0f172a;
    padding: 10px 14px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.prompt-chip:hover {
    background: #0f172a;
    color: white;
    border-color: #0f172a;
}

.flag-wrap {
    grid-area: flag;
    width: 40px;
    height: 26px;
    overflow: hidden;
    border-radius: 4px;
    justify-self: start;
    align-self: center;
}

.flag-logo {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    transform-origin: left center;
    animation: flagWaveMobileSafe 3s ease-in-out infinite;
}

.flag-shimmer {
    display: none;
}

@keyframes flagWaveMobileSafe {
    0% {
        transform: perspective(400px) rotateY(0deg) scaleX(1);
    }
    25% {
        transform: perspective(400px) rotateY(-10deg) scaleX(1.03);
    }
    50% {
        transform: perspective(400px) rotateY(4deg) scaleX(0.98);
    }
    75% {
        transform: perspective(400px) rotateY(-6deg) scaleX(1.01);
    }
    100% {
        transform: perspective(400px) rotateY(0deg) scaleX(1);
    }
}

@media (max-width: 980px) {
    .app-shell {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
    }

    .message-bubble {
        max-width: 90%;
    }

    .chat-box {
        min-height: 280px;
    }

   
}

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

    .header {
        padding: 18px 20px;
        column-gap: 8px;
        row-gap: 6px;
    }

    .main-title {
        font-size: 30px;
    }

    .sub-title {
        font-size: 15px;
        line-height: 1.4;
    }

    .flag-wrap {
        width: 34px;
        height: 22px;
    }

    .chat-box {
        padding: 18px;
        min-height: 160px;   /* 🔥 reduced */
        max-height: 50vh;    /* 🔥 controls space */
    }

    .welcome-card {
        margin-top: 20px;
        margin-bottom: 10px;
    }

    .input-panel {
        flex-direction: column;
        align-items: stretch;
    }

    .ask-btn,
.speak-btn {
    width: 100%;
}
}

@media (max-width: 480px) {
    .brand-name {
        font-size: 28px;
    }

    .main-title {
        font-size: 24px;
    }

    .sub-title {
        font-size: 14px;
    }

    .prompt-chip {
        width: 100%;
        text-align: center;
    }

    .message-bubble {
        max-width: 95%;
    }
}



.resource-links {
    margin-top: 14px;
}

.resource-title {
    font-weight: 700;
    font-size: 13px;
    margin-bottom: 8px;
    color: #475569;
}

.resource-card {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: #f8fafc;
    transition: all 0.2s ease;
}

.resource-card a {
    text-decoration: none;
    color: #1e293b;
    font-size: 14px;
    font-weight: 600;
    word-break: break-word;
}

.resource-card:hover {
    background: #e2e8f0;
    transform: translateY(-1px);
}

.app-footer {
    margin-top: 20px;
    padding: 16px 12px;
    text-align: center;
    font-size: 12px;
    color: #94a3b8;
    border-top: 1px solid #e5e7eb;
}

.app-footer a {
    display: block;          /* 🔥 stacks nicely on mobile */
    margin-top: 4px;
    color: #0f172a;
    text-decoration: none;
    font-weight: 600;
}

.app-footer a:hover {
    text-decoration: underline;
}

