:root {
    --primary: #6366f1;
    --bg: #f8fafc;
    --text: #1e293b;
}

/* Prevent horizontal scroll on ALL screens — absolute lock */
html {
    overflow-x: hidden;
    max-width: 100vw;
}
body {
    font-family: sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding-bottom: 50px;
    overflow-x: hidden;
    max-width: 100vw;
    box-sizing: border-box;
}

.container {
    max-width: 500px;
    margin: 0 auto;
    padding: 15px;
}

/* ========================
   HEADER & AD BANNER
   ======================== */
header {
    text-align: center;
    padding: 30px 10px 0 10px;
    /* prevent any child from overflowing the viewport */
    overflow: hidden;
}
header h1 { color: var(--primary); margin: 0; }
header > p { margin: 8px 0 0 0; color: #64748b; }

/* AD BANNER - fully contained, never overflows mobile */
.ad-banner-wrap {
    width: calc(100% - 24px);
    max-width: 728px;
    margin: 12px auto 6px auto;
    padding: 0;
    box-sizing: border-box;
    display: block;
    overflow: hidden;
}

.ad-banner-link {
    display: block;
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    line-height: 0;
    box-shadow:
        0 0 8px rgba(99, 102, 241, 0.5),
        0 0 18px rgba(99, 102, 241, 0.25);
    animation: adGlow 3s ease-in-out infinite alternate;
    transition: transform 0.2s;
}

.ad-banner-link:hover { transform: translateY(-2px); }

.ad-banner-img {
    display: block;
    width: 100%;        /* always fill container width */
    height: 60px;       /* fixed height — never taller, never wider */
    object-fit: cover;  /* crop to fit, never stretch outside */
    object-position: center;
    border-radius: 8px;
}

@keyframes adGlow {
    from {
        box-shadow:
            0 0 6px rgba(99, 102, 241, 0.4),
            0 0 15px rgba(99, 102, 241, 0.2);
    }
    to {
        box-shadow:
            0 0 12px rgba(99, 102, 241, 0.65),
            0 0 28px rgba(168, 85, 247, 0.35),
            0 0 45px rgba(168, 85, 247, 0.15);
    }
}

/* ========================
   PREMIUM MODAL OVERLAY
   Fixed center-screen popup
   ======================== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9998;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 20px;
    box-sizing: border-box;
    margin: 0 !important;
    transform: none !important;
}

.modal-overlay.hidden {
    display: none !important;
}

.modal-card {
    background: white;
    border-radius: 20px;
    padding: 35px 30px 30px;
    max-width: 380px;
    width: 100%;
    text-align: center;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    border: 2px solid var(--primary);
    animation: modalPop 0.25s ease-out;
}

@keyframes modalPop {
    from { transform: scale(0.85); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

.modal-close {
    position: absolute;
    top: 12px; right: 16px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #94a3b8;
    line-height: 1;
    padding: 0;
}
.modal-close:hover { color: var(--text); }

.modal-badge {
    display: inline-block;
    background: linear-gradient(to right, #6366f1, #a855f7);
    color: white;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    margin-bottom: 14px;
    letter-spacing: 1px;
}

.modal-card h2 {
    margin: 0 0 10px;
    font-size: 24px;
    color: var(--text);
}
.modal-card p { color: #64748b; margin: 0 0 10px; }

.price {
    font-size: 36px;
    font-weight: bold;
    color: var(--primary);
    margin: 15px 0 !important;
}
.price-sub {
    font-size: 14px;
    font-weight: normal;
    color: #94a3b8;
}

.modal-note {
    font-size: 12px !important;
    color: #94a3b8 !important;
    margin-top: 10px !important;
}

/* ========================
   CARDS & LAYOUT
   ======================== */
.card {
    background: white;
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.drop-zone {
    border: 2px dashed #cbd5e1;
    padding: 40px 20px;
    text-align: center;
    border-radius: 10px;
    cursor: pointer;
    background: #fdfdfd;
    transition: border-color 0.2s, background 0.2s;
    user-select: none;
}
.drop-zone:hover { border-color: var(--primary); background: #eef2ff; }
.drop-zone p { margin: 0; font-size: 16px; color: #64748b; pointer-events: none; }

#image-preview {
    width: 100%;
    border-radius: 10px;
    margin-top: 15px;
    border: 1px solid #ddd;
    display: block;
}

/* ========================
   BUTTONS
   ======================== */
.btn-primary, .btn-premium {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 10px;
    font-size: 16px;
    transition: opacity 0.2s, transform 0.1s;
}
.btn-primary:hover, .btn-premium:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); color: white; }
.btn-premium { background: linear-gradient(to right, #6366f1, #a855f7); color: white; font-size: 16px; }

.btn-secondary {
    padding: 10px 20px;
    background: var(--text);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.2s;
}
.btn-secondary:hover { opacity: 0.85; }
.btn-secondary:disabled { opacity: 0.6; cursor: not-allowed; }

/* ========================
   CHAT
   ======================== */
.chat-box {
    height: 200px;
    overflow-y: auto;
    background: #f1f5f9;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
    font-size: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.chat-message {
    padding: 8px 12px;
    border-radius: 8px;
    line-height: 1.5;
    max-width: 92%;
    word-break: break-word;
}
.user-msg {
    background: var(--primary);
    color: white;
    align-self: flex-end;
    margin-left: auto;
}
.ai-msg {
    background: white;
    color: var(--text);
    align-self: flex-start;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.error-msg { background: #fee2e2 !important; color: #991b1b !important; border-color: #fca5a5 !important; }

.chat-input-area { display: flex; gap: 5px; }
.chat-input-area input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}
.chat-input-area input:focus { border-color: var(--primary); }

/* ========================
   AI CONTENT & STATES
   ======================== */
.ai-content { line-height: 1.7; font-size: 15px; }
.ai-content p { margin: 0 0 10px 0; }
.ai-content h4 { color: var(--primary); margin: 15px 0 5px 0; }

.loading-text {
    text-align: center;
    color: #64748b;
    padding: 20px;
    font-style: italic;
    animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.error-text {
    color: #dc2626;
    background: #fee2e2;
    padding: 15px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.6;
}

/* ========================
   USAGE & MISC
   ======================== */
.usage-card { text-align: center; font-weight: bold; color: var(--primary); padding: 10px 0; }
.hidden { display: none !important; }

footer {
    text-align: center;
    padding: 20px;
    color: #94a3b8;
    font-size: 13px;
}
footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}
footer a:hover { text-decoration: underline; }

/* Responsive: shrink ad slightly on desktop */
@media (min-width: 500px) {
    .ad-banner-img { height: 90px; }
}
@media (max-width: 500px) {
    .modal-card { padding: 30px 20px 25px; }
}