body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f0f2f5;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    /* Prevent body scroll when popups are present */
    position: relative;
}

/* Base Chat Window Style */
.chat-container {
    width: 100%;
    height: 100%;
    background: white;
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 0;
    left: 0;
    overflow: hidden;
}

/* Formatting for Popups */
.chat-container.popup {
    width: 95%;
    max-width: 500px;
    height: 500px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 8px;
    border: 1px solid #ccc;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

.popup-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(255, 255, 255, 0.1);
    /* Very light background */
    backdrop-filter: blur(1px);
    z-index: 999;
    /* Just below the popup (popup starts at 1001) */
    pointer-events: auto;
    /* Blocks clicks to elements behind */
}

/* Maximized State */
/* Maximized State - Matches the main window size */
/* Maximized State - Matches the main window size */
.chat-container.maximized {
    top: 0 !important;
    left: 0 !important;
    transform: none !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    border-radius: 0 !important;
    /* z-index managed by JS */
}

.header {
    padding: 0;
    /* Removing padding from container to let children handle it */
    border-bottom: 1px solid #ddd;
    font-weight: bold;
    background: #fff;
    display: flex;
    align-items: stretch;
    /* Stretch to fill height */
    cursor: move;
    user-select: none;
    min-height: 40px;
}

.header-left {
    flex: 4;
    min-width: 0;
    overflow: hidden;
    background-color: #cecece;
    /* Dark Green */
    color: black;
    padding: 0px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    /* Added gap for icon */
    border-top-left-radius: 7px;
    /* Match container radius if needed, though strictly container has overflow hidden */
}

.header-left img {
    height: 48px;
    width: auto;
    flex-shrink: 0;
}

.header-title {
    white-space: normal;
    word-break: keep-all;
}

.header-right {
    flex: 6;
    min-width: 0;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 10px 20px;
    gap: 15px;
}

/* Badge Style for Main Window Only */
.chat-container:not(.popup) .header-instruction {
    background: linear-gradient(135deg, #fff9c4 0%, #fff176 100%);
    /* Warm yellow gradient */
    color: #f57f17;
    /* Dark yellow/orange text */
    font-weight: 800;
    /* Extra bold */
    font-size: 0.95em;
    padding: 6px 12px;
    border-radius: 20px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
    border: 1px solid #fdd835;
    white-space: normal;
    word-break: keep-all;
    text-align: right;
    margin-right: 15px;
    /* Spacing from controls */
    display: inline-block;
    /* For properties to work nicely */
    transition: transform 0.2s;
}

.chat-container:not(.popup) .header-instruction:hover {
    transform: scale(1.05);
}

/* Default/Reset for Popup Windows */
.chat-container.popup .header-instruction {
    color: #444;
    font-size: 0.9em;
    font-weight: normal;
    white-space: normal;
    word-break: keep-all;
    text-align: right;
    margin-right: 10px;
    background: none;
    box-shadow: none;
    border: none;
    padding: 0;
}

.controls {
    display: flex;
    gap: 5px;
    align-items: center;
    /* Vertically center with instruction */
}

.btn-control {
    border: 1px solid #ccc;
    outline: none;
    background: #eee;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    transition: all 0.2s;
}

@keyframes pulse-btn {
    0% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7);
        transform: scale(1);
    }

    70% {
        box-shadow: 0 0 0 6px rgba(40, 167, 69, 0);
        transform: scale(1.1);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0);
        transform: scale(1);
    }
}

.btn-plus {
    color: white;
    background-color: #28a745;
    /* Green background for better visibility */
    border-color: #218838;
    animation: pulse-btn 2s infinite;
    /* Attention grabbing pulse */
    font-size: 14px;
    /* Slightly larger symbol */
    padding: 4px 10px;
    /* Larger click area */
}

.btn-max {
    color: blue;
}

.btn-close {
    color: red;
}

.sub-header {
    font-size: 0.8em;
    color: blue;
    text-align: center;
    padding: 10px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #eee;
    /* Counteract chat-box padding */
    margin: -20px -20px 10px -20px;
    /* Ensure text wraps */
    white-space: normal;
    word-break: keep-all;
}

.chat-box {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    max-width: 80%;
    padding: 10px 15px;
    border-radius: 15px;
    line-height: 1.5;
    word-wrap: break-word;
}

.user {
    align-self: flex-end;
    background: #007bff;
    color: white;
    border-bottom-right-radius: 2px;
}

.model {
    align-self: flex-start;
    background: transparent;
    color: black;
    width: 100%;
    max-width: 100%;
    padding: 0;
}

.input-area {
    padding: 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    border-top: 1px solid #ddd;
    display: flex;
    gap: 10px;
    background: #fff;
}

input {
    flex: 1;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 20px;
    outline: none;
}

.send-btn {
    padding: 10px 20px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
}

.send-btn:disabled {
    background: #ccc;
}

/* Markdown Styles */
.model p {
    margin: 0 0 10px 0;
}

.model pre {
    background: #333;
    color: #fff;
    padding: 10px;
    border-radius: 5px;
    overflow-x: auto;
}

/* Model Selector Styles */
.model-selector-container {
    padding: 5px 20px;
    background: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85em;
    border-top: 1px solid #eee;
}

.model-options {
    display: flex;
    gap: 15px;
    align-items: center;
}

.model-options label {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
}

.model-status {
    color: #555;
    font-weight: 600;
}

/* Feedback Bar */
.feedback-bar {
    display: flex;
    background-color: #fff9c4;
    /* Pale Yellow - matching previous donate line style */
    border-top: 1px solid #fbc02d;
    border-bottom: 1px solid #fbc02d;
    font-size: 0.75rem;
    font-weight: bold;
}

.feedback-item {
    text-align: center;
    padding: 2px 0;
    cursor: pointer;
    color: #f57f17;
    border-right: 1px solid #fbc02d;
    display: flex;
    justify-content: center;
    align-items: center;
}

.feedback-item:last-child {
    border-right: none;
}

.feedback-item:hover {
    background-color: #fdd835;
    /* Darker yellow on hover */
}

/* 1:1:2 Ratio */
.item-privacy {
    flex: 1;
}

.item-contact {
    flex: 1;
}

.item-how-to {
    flex: 2;
}


/* Full Screen Information Popup */
.info-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    /* Fallback */
    height: 100dvh;
    /* Dynamic Viewport Height */
    background: #fff;
    z-index: 9999;
    /* Topmost */
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
}

.info-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}



.info-popup-title {
    font-size: 1.5rem;
    font-weight: bold;
    color: #007bff;
    border-left: 5px solid #007bff;
    padding-left: 15px;
}

.subsection-title {
    font-size: 1.1rem;
    font-weight: bold;
    color: #444;
    margin: 25px 0 15px;
    padding-bottom: 8px;
    border-bottom: 1px solid #ddd;
    margin-left: 5px;
}

.example-section-content {
    margin-left: 15px;
    width: calc(100% - 15px);
}

.info-popup-close {
    font-size: 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
}

.info-popup-content {
    flex: 1;
    overflow-y: auto;
    font-size: 1rem;
    line-height: 1.6;
}

/* Simple Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    width: 300px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.modal-btn {
    margin-top: 15px;
    padding: 8px 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
}

.btn-confirm {
    background: #007bff;
    color: white;
}

.btn-cancel {
    background: #eee;
    color: #333;
    margin-left: 10px;
}

.ad-banner {
    width: 90%;
    height: 80px;
    background: #f0f0f0;
    border: 2px dashed #ccc;
    margin: 10px auto;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
    font-weight: bold;
    font-size: 1.2em;
    border-radius: 8px;
    flex-shrink: 0;
}

.fixed-ad-container {
    width: 100%;
    background: #fff;
    border-top: 1px solid #eee;
    padding: 5px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 90px;
    /* Ensure space for the ad */
}

.fixed-ad-container .ad-banner {
    margin: 0;
    /* Override margin for the fixed container context if needed */
}

.fixed-ad-container .adsbygoogle {
    min-width: 100%;
}

/* Instruction Popup Styles */
.instruction-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 10px;
}

.instruction-step {
    display: flex;
    align-items: flex-start;
    margin-bottom: 25px;
    background: #f9f9f9;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s;
}

.instruction-step:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.step-number {
    background-color: #007bff;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 1.1rem;
    margin-right: 20px;
    flex-shrink: 0;
}

.step-content {
    flex: 1;
}

.step-title {
    font-weight: bold;
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: #333;
}

.step-description {
    color: #666;
    line-height: 1.5;
    margin: 0;
}

.example-box {
    margin-top: 30px;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
}

.example-header {
    background: #f1f3f4;
    padding: 10px 20px;
    font-weight: bold;
    color: #555;
    border-bottom: 1px solid #e0e0e0;
}

.example-content {
    padding: 20px;
    background: #fff;
}

.example-chat-bubble {
    background-color: #f1f1f1;
    padding: 15px;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    max-width: 80%;
    margin-bottom: 15px;
    line-height: 1.5;
    position: relative;
    color: #333;
}

.example-chat-bubble.user {
    background-color: #007bff;
    color: white;
    margin-left: auto;
    margin-bottom: 20px;
    /* spacing fix */
    border-bottom-left-radius: 18px;
    border-bottom-right-radius: 4px;
}

.section-title {
    font-size: 1.2rem;
    font-weight: bold;
    color: #333;
    margin: 30px 0 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #007bff;
}

/* Popup Footer for "Do not show again" */
.popup-footer {
    padding: 15px 20px;
    /* Basic padding */
    padding-bottom: calc(15px + env(safe-area-inset-bottom));
    /* Adjust for iPhone Home Indicator */
    border-top: 1px solid #eee;
    background: #f9f9f9;
    font-size: 0.9rem;
    color: #555;
    text-align: right;
    /* Or 'left' depending on preference, right is common for actions */
    display: flex;
    justify-content: flex-end;
}

.do-not-show {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
}

.do-not-show input {
    width: 16px;
    height: 16px;
    cursor: pointer;
    margin: 0;
    /* Reset global input styles if any conflict */
    flex: none;
    /* Prevent shrinking */
}

/* Cookie Consent Banner */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: #333;
    color: #fff;
    padding: 15px 20px;
    z-index: 10000;
    /* High z-index to stay on top */
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
    display: none;
    /* Hidden by default, shown by JS */
}

.cookie-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.cookie-content p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
    flex: 1;
}

.cookie-buttons {
    display: flex;
    gap: 10px;
}

.cookie-btn {
    padding: 8px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.cookie-btn.accept {
    background-color: #28a745;
    color: white;
}

.cookie-btn.accept:hover {
    background-color: #218838;
}

@media (max-width: 600px) {
    .cookie-content {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .cookie-buttons {
        justify-content: center;
        width: 100%;
    }

    .cookie-btn {
        width: 100%;
    }
}