:root {
    --primary-blue: #003B5C;
    --primary-orange: #F57F20;
    --dark-bg: #111111;
    --msg-incoming: #202c33;
    --msg-outgoing: #005c4b;
    --text-white: #e9edef;
    --text-muted: #8696a0;
    --phone-border: #333333;
    --phone-shadow: rgba(0, 0, 0, 0.4);
}

/* BooksForever - mobile start screen final fix */
@media (max-width: 768px) {
    html,
    body {
        min-height: 100svh;
    }

    .phone-wrapper,
    .phone-frame,
    .phone-screen {
        min-height: 100svh;
        height: 100svh;
    }

    #welcome-screen {
        min-height: calc(100svh - 46px);
        height: calc(100svh - 46px);
        padding-bottom: 112px;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .branding-header {
        height: 24%;
        min-height: 124px;
        max-height: 160px;
        padding: 14px 16px;
        margin-bottom: 0;
        border-bottom-left-radius: 26px;
        border-bottom-right-radius: 26px;
    }

    .logo {
        max-width: 178px;
        max-height: 92px;
    }

    .welcome-content {
        padding: 18px 18px 8px;
        gap: 9px;
    }

    .chat-title {
        font-size: clamp(28px, 8vw, 36px);
        line-height: 1.1;
    }

    .chat-subtitle {
        font-size: clamp(14px, 3.8vw, 16px);
        line-height: 1.34;
        max-width: 330px;
    }

    .badge-container {
        margin-top: 10px;
    }

    .status-badge {
        padding: 8px 13px;
        font-size: 13px;
    }

    .verified-text {
        font-size: 12px;
    }

    .start-button-wrap {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
        background: linear-gradient(to top, #050505 76%, rgba(5, 5, 5, 0));
        z-index: 999;
    }

    .start-button-wrap .primary-btn {
        position: relative;
        left: auto;
        right: auto;
        bottom: auto;
        width: 100%;
        max-width: none;
        min-height: 58px;
        margin: 0;
        border-radius: 16px;
        font-size: 20px;
        font-weight: 700;
        box-shadow: 0 10px 28px rgba(255, 128, 24, 0.28);
    }

    #chat-screen.active ~ .start-button-wrap,
    body:has(#chat-screen.active) .start-button-wrap {
        display: none;
    }
}

/* Extra compact mode for short Android screens */
@media (max-width: 768px) and (max-height: 740px) {
    #welcome-screen {
        padding-bottom: 96px;
    }

    .status-bar {
        height: 40px;
        padding: calc(6px + env(safe-area-inset-top)) 24px 5px;
    }

    #welcome-screen {
        min-height: calc(100svh - 40px);
        height: calc(100svh - 40px);
    }

    .branding-header {
        min-height: 96px;
        max-height: 118px;
        padding: 10px 12px;
        border-bottom-left-radius: 22px;
        border-bottom-right-radius: 22px;
    }

    .logo {
        max-width: 138px;
        max-height: 72px;
    }

    .welcome-content {
        padding: 12px 16px 6px;
        gap: 7px;
    }

    .chat-title {
        font-size: 28px;
    }

    .chat-subtitle {
        font-size: 14px;
        line-height: 1.28;
    }

    .badge-container {
        margin-top: 7px;
        gap: 6px;
    }

    .status-badge {
        padding: 7px 12px;
        font-size: 12px;
    }

    .verified-text {
        font-size: 11px;
    }

    .start-button-wrap {
        padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    }

    .start-button-wrap .primary-btn {
        min-height: 52px;
        font-size: 18px;
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    width: 100vw;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Page Background with WhatsApp-style doodles */
.desktop-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('https://chat.booksforever.online/bg-desktop.jpg');
    background-size: 500px;
    z-index: -1;
    filter: brightness(0.95);
}

/* Phone Mockup Styling */
.phone-wrapper {
    perspective: 1000px;
}

.phone-frame {
    width: min(380px, 95vw);
    height: min(820px, 92vh);
    background: var(--phone-border);
    border-radius: 40px;
    padding: 12px;
    box-shadow: 0 50px 100px -20px var(--phone-shadow), 
                inset 0 0 4px rgba(255,255,255,0.2);
    position: relative;
    border: 1px solid rgba(255,255,255,0.1);
    display: flex;
    flex-direction: column;
}

.phone-screen {
    flex: 1;
    background: var(--dark-bg);
    border-radius: 30px;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Interaction with Notch (iPhone style) */
.notch {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 150px;
    height: 30px;
    background: var(--phone-border);
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
    z-index: 100;
}

.status-bar {
    height: 50px;
    padding: 0 40px 0 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    font-size: 14px;
    font-weight: 600;
    z-index: 99;
    padding-top: 10px;
}

.status-icons {
    display: flex;
    gap: 5px;
    opacity: 0.9;
}

/* Views Management */
#view-container {
    flex: 1;
    position: relative;
}

.view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
}

.view.active {
    display: flex;
}

/* WELCOME SCREEN STYLING */
#welcome-screen {
    background: var(--dark-bg);
}

.branding-header {
    background: white;
    height: 38%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 30px;
    border-bottom-left-radius: 40px;
    border-bottom-right-radius: 40px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.logo {
    max-width: 80%;
    object-fit: contain;
}

.welcome-content {
    flex: 1;
    padding: 20px 30px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 15px;
}

.chat-title {
    color: white;
    font-size: 28px;
    font-weight: 700;
}

.chat-subtitle {
    color: var(--text-muted);
    font-size: 16px;
    line-height: 1.4;
}

.badge-container {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.status-badge {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-white);
    padding: 8px 16px;
    border-radius: 50px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dot {
    width: 8px;
    height: 8px;
    background: #00d959;
    border-radius: 50%;
}

.dot.pulse {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 217, 89, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(0, 217, 89, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 217, 89, 0); }
}

.verified-text {
    color: var(--text-muted);
    font-size: 11px;
}

.welcome-footer {
    padding: 20px 30px;
    flex-shrink: 0;
}

.primary-btn {
    width: 100%;
    background: var(--primary-orange);
    color: white;
    border: none;
    padding: 18px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    box-shadow: 0 10px 20px rgba(245, 127, 32, 0.3);
}

.primary-btn:hover {
    transform: translateY(-2px);
    background: #e6751c;
}

/* CHAT SCREEN STYLING */
#chat-screen {
    background: #0b141a; /* WhatsApp dark mode BG */
}

.chat-header {
    background: #202c33;
    padding: 10px 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    color: white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.back-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
}

.header-info {
    display: flex;
    flex-direction: column;
}

.header-name {
    font-weight: 600;
    font-size: 15px;
}

.header-status {
    font-size: 12px;
    color: #00d959;
}

.message-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background-image: url('https://chat.booksforever.online/bg-desktop.jpg');
    background-blend-mode: overlay;
    background-color: #0b141a;
    background-size: 300px;
}

.message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 15px;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
    color: var(--text-white);
}

.message.incoming {
    align-self: flex-start;
    background: #202c33;
    border-top-left-radius: 2px;
}

.message.outgoing {
    align-self: flex-end;
    background: #005c4b;
    border-top-right-radius: 2px;
}

.message.system {
    align-self: center;
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 8px;
    margin: 10px 0;
}

.message .time {
    display: block;
    text-align: right;
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 5px;
}

.message a {
    color: #7dd3fc;
    overflow-wrap: anywhere;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.chat-footer {
    background: #202c33;
    padding: 10px 15px;
}

.input-container {
    background: #2a3942;
    border-radius: 25px;
    display: flex;
    align-items: center;
    padding: 0 10px;
    gap: 5px;
}

.attachment-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
}

#chat-input {
    flex: 1;
    background: none;
    border: none;
    color: white;
    padding: 12px 5px;
    resize: none;
    outline: none;
    font-size: 16px;
}

.send-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
}

.send-btn.active {
    color: #00a884;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    html,
    body {
        width: 100%;
        min-height: 100dvh;
        margin: 0;
        padding: 0;
        overflow: hidden;
        background: #050505;
    }

    body {
        align-items: stretch;
        justify-content: flex-start;
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }

    .desktop-bg {
        display: none;
    }

    .phone-wrapper {
        width: 100vw;
        height: 100dvh;
        perspective: none;
    }

    .phone-frame {
        width: 100vw;
        max-width: 100vw;
        height: 100dvh;
        min-height: 100dvh;
        border-radius: 0;
        padding: 0;
        border: 0;
        box-shadow: none;
        transform: none;
    }

    .phone-screen {
        border-radius: 0;
        min-height: 100dvh;
    }

    .notch {
        display: none;
    }

    .status-bar {
        height: 46px;
        padding: calc(8px + env(safe-area-inset-top)) 26px 6px;
        background: #111111;
        flex-shrink: 0;
    }

    #view-container {
        min-height: 0;
    }

    #welcome-screen {
        min-height: calc(100dvh - 46px);
        height: calc(100dvh - 46px);
        overflow: hidden;
    }

    .branding-header {
        height: 28%;
        min-height: 150px;
        max-height: 210px;
        padding: 18px 16px;
        border-bottom-left-radius: 28px;
        border-bottom-right-radius: 28px;
    }

    .logo {
        max-width: 210px;
        max-height: 120px;
    }

    .welcome-content {
        justify-content: flex-start;
        gap: 10px;
        padding: 22px 22px 8px;
    }

    .chat-title {
        font-size: 30px;
        line-height: 1.15;
        margin: 0;
    }

    .chat-subtitle {
        max-width: 320px;
        margin: 0 auto;
        font-size: 15px;
        line-height: 1.4;
    }

    .badge-container {
        margin-top: 14px;
        gap: 8px;
    }

    .status-badge {
        padding: 8px 14px;
        font-size: 12px;
    }

    .verified-text {
        font-size: 10px;
    }

    .welcome-footer {
        padding: 12px 22px calc(16px + env(safe-area-inset-bottom));
    }

    .primary-btn {
        max-width: 340px;
        min-height: 54px;
        margin: 0 auto;
        display: block;
        padding: 14px 18px;
        font-size: 16px;
    }

    #chat-screen {
        width: 100vw;
        height: calc(100dvh - 46px);
        min-height: calc(100dvh - 46px);
        overflow: hidden;
    }

    .chat-header {
        min-height: 60px;
        padding: 10px 14px;
        flex-shrink: 0;
    }

    .back-btn {
        font-size: 24px;
        min-width: 32px;
    }

    .header-name {
        font-size: 18px;
        line-height: 1.2;
    }

    .header-status {
        font-size: 13px;
    }

    .message-area {
        min-height: 0;
        padding: 14px 12px 92px;
        gap: 10px;
        overflow-y: auto;
        scroll-behavior: smooth;
    }

    .message {
        max-width: 88%;
        padding: 9px 12px;
        font-size: 15px;
        line-height: 1.42;
        word-break: break-word;
        overflow-wrap: anywhere;
    }

    .message a {
        word-break: break-word;
        overflow-wrap: anywhere;
    }

    .chat-footer {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
        background: #202c33;
        z-index: 50;
    }

    .input-container {
        min-height: 48px;
    }

    #chat-input {
        min-height: 46px;
        max-height: 92px;
        font-size: 16px;
        line-height: 1.3;
    }
}
