/* style.css */
:root {
    --bg-main: #f4f4f9;
    --bg-container: #fff;
    --text-dark: #040404;
    --text-light: #fff;
    --border-color: #e5e7eb;
    --primary-accent: #7c3aed;
    --primary-accent-dark: #6d28d9;
    --bubble-assistant-bg: #e9e9eb;
    --bubble-user-bg: var(--primary-accent);
}
html, body { height: 100%; margin: 0; padding: 0; }
*, *::before, *::after { box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-dark);
    display: flex;
    flex-direction: column; 
    justify-content: center;
    align-items: center;
}
#dde-wrapper {
    width: 100%;
    max-width: 1200px; 
    height: 95vh;
    max-height: 1000px;
    background-color: var(--bg-container);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* --- Header --- */
#chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
#logo-container { display: flex; align-items: center; gap: 0.6rem; }
.logo-svg { width: 28px; height: 28px; }
#logo-container h1 { margin: 0; font-size: 1.2rem; font-weight: 600; }
#new-chat-button { background-color: #f0f0f0; border: 1px solid #ddd; padding: 0.4rem 0.8rem; border-radius: 6px; cursor: pointer; transition: background-color 0.2s; }
#new-chat-button:hover { background-color: #e6e6e6; }

/* --- Main Content Area: DYNAMIC LAYOUT --- */
#main-content {
    flex-grow: 1;
    display: grid;
    grid-template-columns: 1fr;
    overflow: hidden;
    transition: grid-template-columns 0.3s ease-in-out;
}
#main-content.search-layout {
    grid-template-columns: 2fr 1fr;
}

/* --- Chat Container --- */
#chat-container {
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
}
.message { margin-bottom: 1rem; display: flex; flex-direction: column; }
.message-content { max-width: 90%; padding: 10px 15px; border-radius: 18px; line-height: 1.5; word-wrap: break-word; }
.message.user { align-items: flex-end; }
.message.user .message-content { background-color: var(--bubble-user-bg); color: var(--text-light); border-bottom-right-radius: 4px; }
.message.assistant { align-items: flex-start; }
.message.assistant .message-content { background-color: var(--bubble-assistant-bg); border-bottom-left-radius: 4px; }
.thinking-bubble { font-style: italic; color: #666; }

/* --- Search Results Sidebar --- */
#results-sidebar {
    background-color: #fafafa;
    border-left: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 20px;
    display: none;
}
#main-content.search-layout #results-sidebar {
    display: block;
}
#results-sidebar h2 { margin: 0 0 1rem 0; font-size: 1.1rem; color: #333; }
.result-item { margin-bottom: 1.2rem; }
.result-item a { color: var(--primary-accent); text-decoration: none; font-weight: 500; font-size: 0.95rem; }
.result-item a:hover { text-decoration: underline; }
.result-item p { font-size: 0.85rem; color: #555; margin: 0.2rem 0 0.3rem 0; line-height: 1.4; }
.result-item .url { font-size: 0.8rem; color: #777; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }


/* --- Input Form --- */
#chat-form { display: flex; align-items: flex-end; padding: 1rem; border-top: 1px solid var(--border-color); gap: 0.75rem; flex-shrink: 0; }
#message-input { flex-grow: 1; padding: 12px 16px; border: 1px solid #ddd; border-radius: 24px; font-size: 1rem; resize: none; overflow-y: hidden; height: 50px; max-height: 150px; }
#message-input:focus { outline: none; border-color: var(--primary-accent); }
#chat-form button { background-color: var(--primary-accent); color: var(--text-light); border: none; border-radius: 24px; cursor: pointer; transition: background-color 0.2s; height: 50px; flex-shrink: 0; padding: 12px 20px; }
#chat-form button:hover { background-color: var(--primary-accent-dark); }
#chat-form button:disabled { background-color: #c4b5fd; cursor: not-allowed; }

/* --- Markdown & Code Styles --- */
.message-content pre { position: relative; background-color: #1e1e1e; color: #dcdcdc; padding: 15px; padding-top: 2.5em; border-radius: 8px; overflow-x: auto; font-family: 'Consolas', monospace; font-size: 0.9em; margin: 1em 0; }
.copy-code-button { position: absolute; top: 0.5em; right: 0.5em; padding: 0.3em 0.6em; border: 1px solid #555; border-radius: 4px; background-color: #555; color: #eee; cursor: pointer; transition: background-color 0.2s; }

/* --- Responsive --- */
@media (max-width: 768px) {
    body { display: block; }
    /* THIS IS THE FIX: Use 100dvh (dynamic viewport height) instead of 100vh */
    #dde-wrapper { height: 100dvh; max-height: none; border-radius: 0; }
    #main-content.search-layout {
        grid-template-columns: 1fr;
    }
    #results-sidebar {
        border-left: none;
        border-top: 1px solid var(--border-color);
        max-height: 40vh;
    }
}

/* --- Footer and Privacy Styles --- */
#footer-info {
    width: 100%;
    max-width: 1200px;
    padding: 10px 20px;
    text-align: center;
    font-size: 0.8rem;
    color: #666;
}
.pay-off-line a {
    color: var(--primary-accent);
    text-decoration: none;
}
.pay-off-line a:hover {
    text-decoration: underline;
}
.privacy-container {
    margin-top: 8px;
}
.privacy-toggle {
    cursor: pointer;
    display: inline-block;
    user-select: none;
    font-weight: 500;
}
.privacy-toggle .arrow {
    display: inline-block;
    transition: transform 0.2s ease-in-out;
}
.privacy-content {
    margin-top: 8px;
    text-align: left;
    font-size: 0.75rem;
    line-height: 1.6;
    background-color: #f9f9f9;
    padding: 10px 15px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    white-space: pre-wrap;
}