* { box-sizing: border-box; }

html {
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--wa-bg);
    color: var(--wa-text);
    margin: 0;
}

body.whyai-chat-app {
    display: flex;
    justify-content: center;
    width: 100%;
    height: 100%;
    height: 100dvh;
    min-height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

button,
a,
input,
textarea,
select,
label,
[role="button"],
.conv-item,
.mode-option,
#pricing-btn,
#settings-btn,
#sidebar-toggle,
#online-indicator,
#offline-indicator {
    -webkit-tap-highlight-color: transparent;
    tap-highlight-color: transparent;
}

:root,
html[data-theme="dark"] {
    color-scheme: dark;
    --wa-bg: #1c1c1c;
    --wa-bg-sidebar: #161616;
    --wa-bg-panel: #2a2a2a;
    --wa-bg-input: #2b2b2b;
    --wa-text: #f0f0f0;
    --wa-text-soft: #ececec;
    --wa-text-muted: #888;
    --wa-border: #2a2a2a;
    --wa-border-soft: #444;
    --wa-accent: #4ade80;
}

html[data-theme="light"] {
    color-scheme: light;
    --wa-bg: #f3f3f3;
    --wa-bg-sidebar: #ffffff;
    --wa-bg-panel: #ffffff;
    --wa-bg-input: #ffffff;
    --wa-text: #1a1a1a;
    --wa-text-soft: #222222;
    --wa-text-muted: #666666;
    --wa-border: #dddddd;
    --wa-border-soft: #cccccc;
    --wa-accent: #16a34a;
}

#app {
    display: flex;
    width: 100%;
    height: 100%;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
}

/* ─── SIDEBAR ─── */
#sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--wa-bg-sidebar);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--wa-border);
    height: 100%;
    min-height: 0;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--wa-border);
}

.sidebar-header h2 {
    color: var(--wa-text-soft);
    font-size: 1.2rem;
    margin: 0 0 12px 0;
}

#new-conv-btn {
    width: 100%;
    padding: 10px;
    background: #2a2a2a;
    color: #ececec;
    border: 1px solid #444;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-family: inherit;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

#new-conv-btn:hover {
    background: #333;
    border-color: #4ade80;
}

#conv-search-wrap {
    margin-top: 10px;
}

#conv-search-wrap[hidden] {
    display: none !important;
}

#conv-search {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    background: #1a1a1a;
    color: #ececec;
    border: 1px solid #444;
    border-radius: 8px;
    font-size: 0.85rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

#conv-search::placeholder {
    color: #888;
}

#conv-search:focus {
    outline: none;
    border-color: #4ade80;
}

#conv-search::-webkit-search-cancel-button {
    cursor: pointer;
}

#conv-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.conv-item {
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 4px;
    border: 1px solid transparent;
    position: relative;
}

.conv-item:hover {
    background: #222;
    border-color: #333;
}

.conv-item .del-conv-btn {
    display: none;
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    background: #2a2a2a;
    border: 1px solid #444;
    color: #999;
    cursor: pointer;
    font-size: 0.8rem;
    padding: 2px 7px;
    border-radius: 4px;
    transition: all 0.2s;
    line-height: 1.4;
}

.conv-item .del-conv-btn:hover {
    color: #ff6b6b;
    background: #222;
    border-color: #ff6b6b;
}

.conv-item:hover .del-conv-btn {
    display: block;
}

.conv-item.active {
    background: transparent;
    border-left: 2px solid #4ade80;
    border-radius: 0;
}

.conv-title {
    color: #ececec;
    font-size: 0.9rem;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conv-preview {
    color: #888;
    font-size: 0.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conv-time {
    color: #666;
    font-size: 0.65rem;
    margin-top: 4px;
}

#conv-list-empty {
    color: #666;
    text-align: center;
    padding: 40px 16px;
    font-size: 0.85rem;
}

/* ─── SIDEBAR FOOTER ─── */
#sidebar-footer {
    border-top: 1px solid #2a2a2a;
}

.sidebar-footer-section {
    padding: 10px 16px;
    border-bottom: 1px solid #2a2a2a;
}

.sidebar-footer-section:last-child {
    border-bottom: none;
}

#profile-sign-in {
    width: 100%;
    background: none;
    border: 1px solid #555;
    color: #ccc;
    padding: 8px 14px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
    font-family: inherit;
    display: inline-block;
    text-align: center;
}

#profile-sign-in:hover {
    border-color: #4ade80;
    color: #4ade80;
}

#profile-logged-in {
    display: none;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.profile-user-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.profile-user-main {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    background: none;
    border: none;
    padding: 4px 0;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    color: inherit;
    border-radius: 8px;
    transition: background-color 0.2s;
}

.profile-user-main:hover {
    background: rgba(255, 255, 255, 0.04);
}

#profile-name {
    display: block;
    font-size: 0.82rem;
    color: var(--wa-text-soft, #ececec);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.3;
}

#profile-plan {
    display: block;
    font-size: 0.72rem;
    color: var(--wa-text-muted, #888);
    line-height: 1.3;
}

.profile-upgrade-btn {
    flex-shrink: 0;
    background: var(--wa-bg-panel, #2a2a2a);
    border: 1px solid var(--wa-border-soft, #444);
    color: var(--wa-text-soft, #ececec);
    padding: 7px 12px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.2s, color 0.2s;
}

.profile-upgrade-btn:hover {
    border-color: var(--wa-accent, #4ade80);
    color: var(--wa-accent, #4ade80);
}

.profile-upgrade-btn[hidden] {
    display: none !important;
}

.sidebar-user-wrap {
    position: relative;
    width: 100%;
}

.profile-user-menu {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(100% + 8px);
    z-index: 40;
    background: var(--wa-bg-panel, #2a2a2a);
    border: 1px solid var(--wa-border-soft, #444);
    border-radius: 12px;
    overflow-x: hidden;
    overflow-y: auto;
    max-height: min(70vh, 320px);
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
    padding: 6px 0;
}

.profile-user-menu[hidden] {
    display: none !important;
}

.profile-menu-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: none;
    border: none;
    color: var(--wa-text-soft, #ececec);
    font-size: 0.85rem;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    box-sizing: border-box;
}

.profile-menu-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--wa-accent, #4ade80);
}

.profile-menu-item--danger:hover {
    color: #ff6b6b;
}

.profile-menu-icon {
    width: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.9rem;
    opacity: 0.85;
}

.help-menu-icon {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid currentColor;
    font-size: 0.65rem;
    font-weight: 700;
}

.profile-menu-label {
    flex: 1;
    min-width: 0;
}

.profile-menu-chevron {
    color: var(--wa-text-muted, #888);
    font-size: 1rem;
    line-height: 1;
}

.profile-menu-help-wrap {
    position: relative;
}

.profile-menu-submenu {
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid var(--wa-border, #2a2a2a);
}

.profile-menu-submenu[hidden] {
    display: none !important;
}

.profile-menu-submenu a {
    display: block;
    padding: 9px 14px 9px 42px;
    color: var(--wa-text-muted, #aaa);
    text-decoration: none;
    font-size: 0.8rem;
    transition: background-color 0.2s, color 0.2s;
}

.profile-menu-submenu a:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--wa-accent, #4ade80);
}

.sidebar-footer-auth {
    position: relative;
}

#profile-email {
    display: none;
}

#profile-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #4ade80;
    color: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.user-details {
    flex: 1;
    min-width: 0;
}

#sidebar-guest-actions[hidden] {
    display: none !important;
}

#profile-sign-out.profile-menu-item {
    display: flex;
}

/* ─── MAIN ─── */
#main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    background: var(--wa-bg);
}

#main-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid var(--wa-border);
    flex-shrink: 0;
    background: var(--wa-bg-sidebar);
}

#sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: #ececec;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px 8px;
}

.main-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-btns {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    max-width: 100%;
}

#image-gen-btn {
    width: 33px; height: 33px; cursor: pointer; border-radius: 50%;
    background: linear-gradient(135deg,#1a1a1a,#2a2a2a);
    border: 1px solid #444; padding: 2px;
    display: none; align-items: center; justify-content: center;
    transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

#image-gen-btn:hover {
    border-color: #4ade80;
    background: linear-gradient(135deg,#202020,#2f2f2f);
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 4px 12px rgba(74,222,128,0.2);
}

#image-gen-btn:active { transform: scale(0.95); }

#pricing-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: none;
    border: 1px solid #888;
    color: #ccc;
    padding: 6px 14px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
    line-height: 1;
    transition: border-color 0.2s, background-color 0.2s, color 0.2s;
    white-space: nowrap;
}

.pricing-btn-star {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
    flex-shrink: 0;
}

.pricing-star-icon {
    width: 12px;
    height: 12px;
    display: block;
}

#pricing-btn:hover {
    border-color: #aaa;
    background-color: rgba(255, 255, 255, 0.05);
    color: #ececec;
}

#pricing-btn.is-pro-hidden {
    display: none !important;
}

@media (max-width: 768px) {
    #main-header {
        padding: 10px 12px;
        align-items: center;
    }

    .main-header-left {
        gap: 8px;
        align-items: center;
    }

    .header-btns {
        align-items: center;
    }

    #sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 30px;
        height: 30px;
        min-width: 30px;
        padding: 0;
        margin: 0;
        line-height: 1;
        font-size: 1.15rem;
        text-align: center;
        box-sizing: border-box;
    }

    #pricing-btn {
        gap: 0;
        width: 30px;
        height: 30px;
        min-width: 30px;
        max-width: 30px;
        padding: 0;
        margin: 0;
        border-radius: 15px;
        flex-shrink: 0;
        align-self: center;
        box-sizing: border-box;
    }

    .pricing-btn-label {
        display: none;
    }

    .pricing-star-icon {
        width: 12px;
        height: 12px;
    }

    #online-indicator,
    #subscribe-now-btn {
        font-size: 0.78rem;
        height: 30px;
        padding: 0 10px;
        border-radius: 15px;
        gap: 5px;
        box-sizing: border-box;
        align-self: center;
    }

    #online-indicator::before {
        font-size: 0.65rem;
    }
}

/* --- INDICADOR ONLINE --- */
#online-indicator,
#subscribe-now-btn {
    background-color: transparent;
    border-radius: 20px;
    padding: 6px 14px;
    font-family: ui-sans-serif, system-ui, sans-serif;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s, color 0.2s;
    white-space: nowrap;
    box-sizing: border-box;
    line-height: 1;
}

#online-indicator {
    border: 1px solid #888;
    color: #ccc;
}

#online-indicator:hover {
    border-color: #aaa;
    background-color: rgba(255, 255, 255, 0.05);
}

#online-indicator::before {
    content: "\25CF";
    color: #4ade80;
    font-size: 0.75rem;
}

#subscribe-now-btn {
    border: 1px solid #4ade80;
    color: #4ade80;
}

#subscribe-now-btn:hover {
    border-color: #6ee8a0;
    background-color: rgba(74, 222, 128, 0.08);
    color: #6ee8a0;
}

#subscribe-now-btn[hidden] {
    display: none !important;
}

/* ─── CHAT ─── */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    max-width: 100%;
}

.chat-box {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: none;
    flex-direction: column;
    gap: 15px;
}

#pro-banner {
    display: none;
    padding: 10px 16px;
    background: rgba(255, 152, 0, 0.08);
    border-top: 1px solid rgba(255, 152, 0, 0.2);
    border-bottom: 1px solid rgba(255, 152, 0, 0.2);
    text-align: center;
    font-size: 0.8rem;
    color: var(--wa-text-muted, #ccc);
    line-height: 1.4;
    flex-shrink: 0;
}

#pro-banner a {
    color: #4ade80;
    text-decoration: underline;
    cursor: pointer;
}

#pro-banner a:hover {
    color: #5ae890;
}

#chat-form,
.input-area {
    --form-bg: var(--wa-bg-sidebar, #1c1c1c);
    --form-text: var(--wa-text, #f0f0f0);
    --form-muted: var(--wa-text-muted, #666);
    --form-border: var(--wa-border, #333);
    --form-border-soft: var(--wa-border-soft, #444);
    --form-input-bg: var(--wa-bg-input, #2b2b2b);
    --form-btn-bg: var(--wa-bg-panel, #333);
    --form-btn-text: var(--wa-text-soft, #ececec);
    --form-accent: var(--wa-accent, #4ade80);
    --form-attach-bg: rgba(128, 128, 128, 0.15);
    --form-attach-hover: rgba(128, 128, 128, 0.25);
    border-top: 1px solid var(--form-border);
    padding: 16px 20px max(12px, env(safe-area-inset-bottom, 0px));
    background: var(--form-bg);
    color: var(--form-text);
    flex-shrink: 0;
    display: none;
}

#chat-form .input-wrapper,
#guest-chat-form .input-wrapper,
.input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

#chat-form #user-input,
#chat-form textarea,
#guest-chat-form #guest-input,
#guest-chat-form textarea {
    flex: 1;
    border: 1px solid var(--form-border-soft);
    background: var(--form-input-bg);
    color: var(--form-text);
    border-radius: 12px;
    padding: 10px 16px;
    font-size: 1rem;
    outline: none;
    resize: none;
    min-height: 24px;
    max-height: 200px;
    overflow-y: hidden;
    line-height: 1.5;
    font-family: inherit;
}

#chat-form #user-input::placeholder,
#chat-form textarea::placeholder,
#guest-chat-form #guest-input::placeholder,
#guest-chat-form textarea::placeholder {
    color: var(--form-muted);
    opacity: 1;
}

#chat-form #user-input:focus,
#chat-form textarea:focus,
#guest-chat-form #guest-input:focus,
#guest-chat-form textarea:focus {
    border-color: var(--form-accent);
}

#chat-form #send-button,
#guest-chat-form #guest-send-btn {
    background: var(--form-btn-bg);
    color: var(--form-btn-text);
    border: 1px solid var(--form-border-soft);
    border-radius: 12px;
    padding: 10px 20px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    height: 44px;
    flex-shrink: 0;
    font-family: inherit;
}

#chat-form #send-button:hover,
#guest-chat-form #guest-send-btn:hover {
    background: var(--form-border-soft);
}

#chat-form #send-button:disabled,
#guest-chat-form #guest-send-btn:disabled {
    background: var(--form-input-bg);
    color: var(--form-muted);
    cursor: not-allowed;
    opacity: 0.7;
}

#chat-form #image-button,
#guest-chat-form #guest-image-button {
    font-size: 22px;
    cursor: pointer;
    padding: 0;
    border-radius: 12px;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    color: var(--form-btn-text);
    background: var(--form-attach-bg);
    border: 1px solid var(--form-border-soft);
    flex-shrink: 0;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    box-sizing: border-box;
    text-align: center;
}

#chat-form #image-button:hover,
#guest-chat-form #guest-image-button:hover {
    background: var(--form-attach-hover);
}

#chat-form #image-button:disabled,
#guest-chat-form #guest-image-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#chat-form .disclaimer,
#guest-chat-form .disclaimer {
    text-align: center;
    color: var(--form-muted);
    font-size: 0.8rem;
    margin-top: 8px;
    opacity: 0.9;
}

#chat-form #user-input::-webkit-scrollbar,
#guest-chat-form #guest-input::-webkit-scrollbar {
    width: 6px;
}

#chat-form #user-input::-webkit-scrollbar-track,
#guest-chat-form #guest-input::-webkit-scrollbar-track {
    background: var(--form-input-bg);
    border-radius: 10px;
}

#chat-form #user-input::-webkit-scrollbar-thumb,
#guest-chat-form #guest-input::-webkit-scrollbar-thumb {
    background-color: var(--form-border-soft);
    border-radius: 10px;
    border: 1px solid var(--form-input-bg);
}

#chat-form #user-input::-webkit-scrollbar-thumb:hover {
    background-color: var(--form-muted);
}

/* Legacy selectors (same element / outside form scope) */
.input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

#user-input {
    flex: 1;
    border: 1px solid var(--wa-border-soft, #444);
    background: var(--wa-bg-input, #2b2b2b);
    color: var(--wa-text, #f0f0f0);
    border-radius: 12px;
    padding: 10px 16px;
    font-size: 1rem;
    outline: none;
    resize: none;
    min-height: 24px;
    max-height: 200px;
    overflow-y: hidden;
    line-height: 1.5;
    font-family: inherit;
}

#user-input::placeholder {
    color: var(--wa-text-muted, #888);
    opacity: 1;
}

#user-input:focus {
    border-color: var(--wa-accent, #4ade80);
}

#send-button {
    background: var(--wa-bg-panel, #333);
    color: var(--wa-text-soft, #ececec);
    border: 1px solid var(--wa-border-soft, #444);
    border-radius: 12px;
    padding: 10px 20px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: background 0.2s;
    height: 44px;
    flex-shrink: 0;
    font-family: inherit;
}

#send-button:hover { background: var(--wa-border-soft, #444); }
#send-button:disabled {
    background: var(--wa-bg-panel, #2a2a2a);
    color: var(--wa-text-muted, #555);
    cursor: not-allowed;
    opacity: 0.7;
}

.disclaimer {
    text-align: center;
    color: var(--wa-text-muted, #666);
    font-size: 0.8rem;
    margin-top: 8px;
    opacity: 0.8;
}

/* ─── SWITCH MODE MODAL ─── */
.switch-modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 100001;
    display: flex; justify-content: center; align-items: center;
    backdrop-filter: blur(5px);
    opacity: 0; visibility: hidden; transition: opacity 0.3s ease;
}
.switch-modal-overlay.active { opacity: 1; visibility: visible; }
.switch-modal-box {
    background: #2a2a2a; border: 1px solid #444;
    padding: 20px; border-radius: 12px; max-width: 90%; width: 400px;
    text-align: center; color: #ececec;
    font-family: ui-sans-serif, system-ui, sans-serif;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5); margin: 20px;
}
.switch-modal-box h2 { margin-top: 0; color: #fff; margin-bottom: 20px; }
.mode-option {
    margin-bottom: 15px; padding: 16px;
    background: #1a1a1a; border-radius: 8px;
    border: 1px solid #444; cursor: pointer;
    transition: all 0.2s; position: relative;
}
.mode-option:last-child { margin-bottom: 0; }
.mode-option:hover { border-color: #666; background: #202020; }
.mode-option.disabled {
    opacity: 0.5; cursor: not-allowed;
    background: #151515; border-color: #333;
}
.mode-option.disabled:hover { border-color: #333; background: #151515; }
.mode-option .current-badge {
    position: absolute; top: 8px; right: 8px;
    background: #4ade80; color: #1a1a1a;
    padding: 4px 10px; border-radius: 4px;
    font-size: 0.75rem; font-weight: bold;
}
.mode-option h3 { margin: 0 0 8px 0; font-size: 1.1rem; color: #4ade80; }
.mode-option p { margin: 0; font-size: 0.9rem; color: #aaa; line-height: 1.4; }
.close-switch-btn {
    background: transparent; color: #888;
    border: 1px solid #444; padding: 8px 16px;
    border-radius: 6px; cursor: pointer;
    margin-top: 15px; font-family: inherit;
    transition: all 0.2s; font-size: 0.9rem;
    display: inline-block;
}
.close-switch-btn:hover { border-color: #666; color: #ccc; }

/* ─── EMPTY STATE ─── */
#empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    padding: 40px 20px;
    text-align: center;
    color: #666;
}

#empty-state.hidden {
    display: none;
}

.empty-welcome {
    margin: 0 0 24px;
    font-size: clamp(1.35rem, 4vw, 1.75rem);
    font-weight: 600;
    color: var(--wa-text, #e8e8e8);
    letter-spacing: -0.02em;
    line-height: 1.35;
    text-align: center;
    max-width: 520px;
}

.empty-start-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 160px;
    padding: 12px 32px;
    margin: 0 0 8px;
    background: var(--wa-bg-panel, #2a2a2a);
    color: var(--wa-text-soft, #ececec);
    border: 1px solid var(--wa-border-soft, #444);
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.95rem;
    font-family: inherit;
    font-weight: 600;
    line-height: 1.2;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.empty-start-btn:hover {
    border-color: var(--wa-accent, #4ade80);
    color: var(--wa-accent, #4ade80);
}

#empty-state-sub,
.empty-trust {
    margin-top: 14px !important;
    font-size: 0.72rem !important;
    color: #555 !important;
    max-width: 360px;
}

html[data-theme="light"] .empty-welcome {
    color: var(--wa-text, #1a1a1a);
}

html[data-theme="light"] .empty-start-btn {
    background: #ffffff;
    color: #222222;
    border-color: #cccccc;
}

html[data-theme="light"] .empty-start-btn:hover {
    border-color: var(--wa-accent, #16a34a);
    color: var(--wa-accent, #16a34a);
}

html[data-theme="light"] #empty-state-sub,
html[data-theme="light"] .empty-trust {
    color: #888 !important;
}

/* ─── GUEST DEMO ─── */
#guest-demo {
    display: none;
    flex-direction: column;
    flex-shrink: 0;
    min-height: 0;
}

#guest-demo.active {
    display: flex;
}

#guest-demo.guest-mode-signin {
    flex: 1;
}

.chat-container.guest-landing {
    position: relative;
}

.chat-container.guest-landing #guest-demo.active {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

.guest-landing-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
    width: 100%;
    max-width: 720px;
    padding: 0 20px;
    box-sizing: border-box;
}

.chat-container.guest-landing #guest-welcome {
    padding: 0;
    text-align: center;
    transition: opacity 0.28s ease, transform 0.28s ease;
}

.guest-welcome.is-leaving {
    opacity: 0;
    transform: translateY(-14px);
    pointer-events: none;
}

.chat-container.guest-landing #guest-chat-form {
    border-top: none;
    background: transparent;
    padding: 0;
    width: 100%;
    display: block !important;
    will-change: transform;
}

.chat-container.guest-landing #guest-chat-form .input-wrapper {
    background: none;
    border: none;
    box-shadow: none;
    padding: 0;
    border-radius: 0;
}

.chat-container.guest-landing #guest-chat-form .disclaimer {
    display: none;
}

.chat-container.guest-exhausted #guest-chat-form {
    display: none !important;
}

.chat-container.guest-conversation.guest-exhausted #guest-login-bar,
.chat-container.guest-exhausted #guest-login-bar {
    display: block !important;
}

.chat-container.guest-exhausted.guest-landing #guest-demo.active {
    flex: 1;
    display: flex !important;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

.chat-container.guest-exhausted.guest-landing #chat-box {
    display: none !important;
}

.chat-container.guest-exhausted.guest-conversation #chat-box {
    display: flex !important;
}

.guest-login-bar {
    text-align: center;
    padding: 16px 20px 12px;
}

.guest-login-bar-title {
    margin: 0 0 6px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--wa-text, #e8e8e8);
}

.guest-login-bar-sub {
    margin: 0 0 14px;
    font-size: 0.875rem;
    color: var(--wa-text-muted, #888);
    line-height: 1.4;
}

.guest-login-bar-btn {
    border: none;
    background: var(--wa-accent, #4ade80);
    color: #1a1a1a;
    font-weight: 600;
    font-size: 0.95rem;
    font-family: inherit;
    padding: 12px 32px;
    border-radius: 999px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.guest-login-bar-btn:hover {
    opacity: 0.9;
}

.chat-container.guest-landing #chat-box {
    display: none !important;
}

.chat-container.guest-conversation #guest-landing-stack {
    display: none;
}

.chat-container.guest-conversation #guest-demo.active:not(.guest-mode-signin) {
    display: none;
}

.chat-container.guest-conversation #chat-box {
    display: flex;
}

#guest-chat-form.guest-docking {
    z-index: 5;
}

.guest-welcome {
    padding: 28px 20px 12px;
    text-align: center;
    flex-shrink: 0;
}

.guest-tagline {
    margin: 0;
    font-size: clamp(1.25rem, 3.5vw, 1.6rem);
    font-weight: 600;
    color: var(--wa-text, #e8e8e8);
    letter-spacing: -0.02em;
    line-height: 1.35;
}

html[data-theme="light"] .guest-tagline,
html[data-theme="light"] .guest-login-bar-title {
    color: var(--wa-text, #1a1a1a);
}

@media (max-width: 768px) {
    .chat-container.guest-landing,
    .chat-container.guest-exhausted.guest-landing {
        flex: 1;
        min-height: 0;
    }

    .chat-container.guest-landing #guest-demo.active,
    .chat-container.guest-exhausted.guest-landing #guest-demo.active {
        flex: 1 1 auto;
        width: 100%;
        max-width: 100%;
        align-self: stretch;
        justify-content: center;
        align-items: center;
        padding-left: max(16px, env(safe-area-inset-left, 0px));
        padding-right: max(16px, env(safe-area-inset-right, 0px));
        box-sizing: border-box;
    }

    .guest-landing-stack {
        width: 100%;
        max-width: 100%;
        margin: 0 auto;
        padding: 0;
        gap: 22px;
        align-items: center;
        justify-content: center;
    }

    .guest-welcome {
        width: 100%;
        padding: 0;
        text-align: center;
    }

    .guest-tagline {
        width: 100%;
        max-width: 340px;
        margin: 0 auto;
        text-align: center;
    }

    .chat-container.guest-landing #guest-chat-form,
    .chat-container.guest-exhausted.guest-landing #guest-chat-form {
        width: 100%;
        max-width: 100%;
        margin: 0 auto;
    }

    .chat-container.guest-landing #guest-chat-form .input-wrapper {
        width: 100%;
    }
}

@media (max-width: 768px) {
    #empty-state {
        padding: 24px 20px 16px;
        justify-content: center;
    }

    .empty-welcome {
        font-size: clamp(1.2rem, 5.5vw, 1.5rem);
        max-width: 340px;
        margin-bottom: 28px;
    }

    .empty-start-btn {
        width: min(100%, 300px);
        min-height: 48px;
        font-size: 1rem;
    }
}

/* ─── RESPONSIVE ─── */
@media (max-width: 768px) {
    #sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 100;
        transform: translateX(-100%);
    }
    #sidebar.open { transform: translateX(0); }
    #sidebar.open + #sidebar-overlay { display: block; }
    #sidebar-toggle { display: block; }
    #main-header {
        padding: 10px 12px;
        gap: 8px;
    }
    .main-header-left {
        min-width: 0;
        flex: 1 1 auto;
    }
    .header-btns {
        gap: 6px;
        flex: 0 1 auto;
    }
    #subscribe-now-btn,
    #online-indicator {
        font-size: 0.72rem;
        padding: 5px 10px;
    }
    .chat-container { max-width: 100%; }
    .chat-box { padding: 12px; }
    .input-area { padding: 12px 10px max(10px, env(safe-area-inset-bottom, 0px)); }
}

#sidebar-overlay {
    display: none; position: fixed; inset: 0; z-index: 99;
    background: rgba(0,0,0,0.5);
}
@media (min-width: 769px) { #sidebar-overlay { display: none !important; } }

/* ─── IMAGE ATTACH ─── */
#image-input { display: none; }
#preview-container {
    display: none; align-items: center; gap: 10px; padding: 10px;
    background: var(--wa-bg-panel, rgba(255,255,255,0.05));
    border: 1px solid var(--wa-border-soft, transparent);
    border-radius: 8px;
    margin: 0 20px 8px;
}
#image-preview {
    max-width: 100px; max-height: 100px; border-radius: 6px;
    object-fit: cover; border: 2px solid rgba(255,255,255,0.1);
}
.image-info { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.image-filename {
    font-size: 13px; color: var(--wa-text-soft, #fff); font-weight: 500;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.image-hint { font-size: 11px; color: var(--wa-text-muted, rgba(255,255,255,0.6)); }
#remove-image {
    background: rgba(255,59,48,0.8); border: none; color: white;
    width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
    font-size: 16px; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
#remove-image:hover { background: rgba(255,59,48,1); }
/* ─── IMAGE MODAL ─── */
.image-modal-box {
    background: linear-gradient(135deg, #2a2a2a, #1f1f1f);
    border: 1px solid #555;
    padding: 25px;
    border-radius: 16px;
    max-width: 95%;
    width: 550px;
    max-height: 90vh;
    overflow-y: auto;
    text-align: center;
    color: #ececec;
    font-family: ui-sans-serif, system-ui, sans-serif;
    box-shadow: 0 20px 60px rgba(0,0,0,0.7);
    margin: 20px;
}
.image-modal-box::-webkit-scrollbar { width: 8px; }
.image-modal-box::-webkit-scrollbar-track { background: #1a1a1a; border-radius: 10px; }
.image-modal-box::-webkit-scrollbar-thumb { background: #4ade80; border-radius: 10px; }
.image-modal-box h2 {
    margin-top: 0; color: #fff; margin-bottom: 8px; font-size: 1.8rem;
    background: linear-gradient(135deg, #4ade80, #3bc96f);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
}
.image-modal-subtitle { color: #999; font-size: 0.9rem; margin-bottom: 25px; font-weight: normal; }
.suggestions { margin-bottom: 20px; }
.suggestions-title { font-size: 0.85rem; color: #999; margin-bottom: 10px; text-align: left; }
.suggestion-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.suggestion-chip {
    background: #1a1a1a; border: 1px solid #444; color: #aaa;
    padding: 6px 12px; border-radius: 16px; font-size: 0.8rem;
    cursor: pointer; transition: all 0.2s;
}
.suggestion-chip:hover { background: #4ade80; color: #1a1a1a; border-color: #4ade80; }
.prompt-container { position: relative; margin-bottom: 25px; }
#image-prompt {
    width: 100%; padding: 14px 16px; border-radius: 10px;
    border: 2px solid #444; background: #1a1a1a; color: #fff;
    font-family: ui-sans-serif, system-ui, sans-serif; font-size: 0.95rem;
    box-sizing: border-box; transition: all 0.3s ease;
    resize: vertical; min-height: 80px;
}
#image-prompt:focus { outline: none; border-color: #4ade80; background: #1f1f1f; box-shadow: 0 0 0 3px rgba(74,222,128,0.1); }
#image-prompt::placeholder { color: #666; }
.char-counter { position: absolute; bottom: -20px; right: 8px; font-size: 0.75rem; color: #666; }
.option-group { text-align: left; margin-bottom: 20px; }
.option-label { display: block; font-size: 0.85rem; color: #aaa; margin-bottom: 6px; font-weight: 500; }
.option-select {
    width: 100%; padding: 10px; border-radius: 8px; border: 1px solid #444;
    background: #1a1a1a; color: #fff; font-family: ui-sans-serif, system-ui, sans-serif;
    font-size: 0.9rem; cursor: pointer; transition: all 0.2s;
}
.option-select:hover { border-color: #555; background: #1f1f1f; }
.option-select:focus { outline: none; border-color: #4ade80; }
.generate-btn {
    background: linear-gradient(135deg, #4ade80, #3bc96f); color: #1a1a1a; border: none;
    padding: 14px 40px; border-radius: 10px; font-weight: bold; cursor: pointer;
    font-size: 1rem; font-family: ui-sans-serif, system-ui, sans-serif;
    transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
    box-shadow: 0 4px 12px rgba(74,222,128,0.3); width: 100%; margin-bottom: 20px;
}
.generate-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #5ae890, #4bd980);
    transform: translateY(-2px); box-shadow: 0 6px 16px rgba(74,222,128,0.4);
}
.generate-btn:active:not(:disabled) { transform: translateY(0); }
.generate-btn:disabled { opacity: 0.6; cursor: not-allowed; background: #444; }
.loading-spinner {
    display: none; margin: 20px auto; width: 50px; height: 50px;
    border: 4px solid #333; border-top-color: #4ade80;
    border-radius: 50%; animation: spin 1s linear infinite;
}
.loading-spinner.active { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { display: none; color: #aaa; font-size: 0.9rem; margin-top: 10px; }
.loading-text.active { display: block; }
#image-result { margin-top: 25px; display: none; animation: fadeInUp 0.5s ease; }
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
#generated-image { width: 100%; display: block; border-radius: 12px; margin-bottom: 15px; border: 2px solid #333; transition: border-color 0.3s; }
#generated-image:hover { border-color: #4ade80; }
.action-buttons { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.action-btn {
    background: #1a1a1a; color: #4ade80; border: 1px solid #4ade80;
    padding: 10px 20px; border-radius: 8px; font-weight: 600; cursor: pointer;
    font-size: 0.9rem; font-family: ui-sans-serif, system-ui, sans-serif;
    transition: all 0.2s; text-decoration: none; display: inline-flex; align-items: center; gap: 8px;
}
.action-btn:hover { background: #4ade80; color: #1a1a1a; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(74,222,128,0.3); }
@media (max-width: 768px) {
    .image-modal-box { padding: 20px; width: 95%; }
    .action-buttons { flex-direction: column; }
    .action-btn { width: 100%; justify-content: center; }
}

/* ========================================
   ESTILOS ADICIONALES (desde style.css original)
   ======================================== */

h1 {
    text-align: left;
    color: #ececec;
    padding: 20px 20px 10px 20px;
    margin: 0;
    font-size: 1.25rem;
    border-bottom: none;
    opacity: 0.8;
}

/* Burbujas de chat */
.message {
    padding: 12px 18px;
    border-radius: 20px;
    max-width: 85%;
    word-wrap: break-word;
}

.message p {
    margin: 0;
    line-height: 1.5;
}

.message.user {
    background-color: #3a3a3a;
    color: #ececec;
    align-self: flex-end;
    border-bottom-right-radius: 5px;
}

.message.ia {
    background-color: #2a2a2a;
    color: #ececec;
    align-self: flex-start;
    border-bottom-left-radius: 5px;
}

/* Spinner */
.spinner {
    width: 70px;
    text-align: center;
    padding-top: 5px;
}

.spinner > div {
    width: 12px;
    height: 12px;
    background-color: #888;
    border-radius: 100%;
    display: inline-block;
    -webkit-animation: sk-bouncedelay 1.4s infinite ease-in-out both;
    animation: sk-bouncedelay 1.4s infinite ease-in-out both;
}

.spinner .bounce1 {
    -webkit-animation-delay: -0.32s;
    animation-delay: -0.32s;
}

.spinner .bounce2 {
    -webkit-animation-delay: -0.16s;
    animation-delay: -0.16s;
}

@-webkit-keyframes sk-bouncedelay {
    0%, 80%, 100% { -webkit-transform: scale(0); }
    40% { -webkit-transform: scale(1.0); }
}

@keyframes sk-bouncedelay {
    0%, 80%, 100% {
        -webkit-transform: scale(0);
        transform: scale(0);
    }
    40% {
        -webkit-transform: scale(1.0);
        transform: scale(1.0);
    }
}

/* Bloques de código */
.message.ia pre {
    background-color: #121212;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 16px;
    overflow-x: auto;
    font-family: "Courier New", Courier, monospace;
    font-size: 0.9rem;
    line-height: 1.4;
    white-space: pre;
}

.message.ia code {
    font-family: inherit;
    color: #d0d0d0;
}

/* Scrollbar del chat */
.chat-box::-webkit-scrollbar {
    width: 8px;
}

.chat-box::-webkit-scrollbar-track {
    background: #1c1c1c;
    border-radius: 10px;
}

.chat-box::-webkit-scrollbar-thumb {
    background-color: #444;
    border-radius: 10px;
    border: 2px solid #1c1c1c;
}

.chat-box::-webkit-scrollbar-thumb:hover {
    background-color: #555;
}

html[data-theme="light"] .chat-box::-webkit-scrollbar-track {
    background: #eeeeee;
}

html[data-theme="light"] .chat-box::-webkit-scrollbar-thumb {
    background-color: #bbbbbb;
    border-color: #eeeeee;
}

html[data-theme="light"] .chat-box::-webkit-scrollbar-thumb:hover {
    background-color: #999999;
}

html[data-theme="light"] .message.ia pre {
    background-color: #f5f5f5;
    border-color: #dddddd;
}

html[data-theme="light"] .message.ia code {
    color: #333333;
}

html[data-theme="light"] .message.ia pre::-webkit-scrollbar-track {
    background: #eeeeee;
}

html[data-theme="light"] .message.ia pre::-webkit-scrollbar-thumb {
    background: #bbbbbb;
}

/* Scrollbar del textarea */
#user-input::-webkit-scrollbar {
    width: 6px;
}

#user-input::-webkit-scrollbar-track {
    background: var(--wa-bg-input, #2b2b2b);
    border-radius: 10px;
}

#user-input::-webkit-scrollbar-thumb {
    background-color: var(--wa-border-soft, #444);
    border-radius: 10px;
    border: 1px solid var(--wa-bg-input, #2b2b2b);
}

#user-input::-webkit-scrollbar-thumb:hover {
    background-color: #555;
}

/* Scrollbar horizontal global */
::-webkit-scrollbar {
    width: 0px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #1a1a1a;
    border-radius: 8px;
    margin: 0 8px;
}

::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 8px;
    border: 2px solid #1a1a1a;
    transition: background 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
    cursor: pointer;
}

::-webkit-scrollbar-thumb:active {
    background: #666;
}

/* Scrollbar horizontal para código */
.message.ia pre::-webkit-scrollbar {
    width: 0px;
    height: 8px;
}

.message.ia pre::-webkit-scrollbar-track {
    background: #0a0a0a;
    border-radius: 6px;
    margin: 0 6px;
}

.message.ia pre::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 6px;
    border: 2px solid #0a0a0a;
}

.message.ia pre::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: #444 #1a1a1a;
}

.message.ia pre {
    scrollbar-width: thin;
    scrollbar-color: #333 #0a0a0a;
}

/* Scroll suave */
html {
    scroll-behavior: smooth;
}

/* Responsive adicional */
@media (max-width: 768px) {
    .chat-container {
        max-width: 100%;
    }

    h1 {
        padding: 15px 15px 10px 15px;
        font-size: 1.15rem;
    }

    #chat-form,
    .input-area {
        padding: 15px 10px 10px 10px;
    }

    .message {
        max-width: 90%;
        padding: 10px 15px;
    }

    #chat-form #user-input,
    #user-input,
    #guest-chat-form #guest-input {
        padding: 9px 15px;
        font-size: 0.95rem;
        max-height: 150px;
    }

    #chat-form #send-button,
    #send-button,
    #guest-chat-form #guest-send-btn {
        padding: 10px 15px;
        font-size: 0.95rem;
        height: 40px;
    }

    #chat-form #image-button,
    #guest-chat-form #guest-image-button {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
        font-size: 20px;
    }

    .message.ia pre {
        padding: 12px;
    }

    #chat-form .disclaimer,
    .disclaimer {
        font-size: 0.8rem;
        margin-top: 8px;
    }
}
