*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: inherit;
}

html {
    box-sizing: border-box;
    font-size: 62.5%;
    -webkit-text-size-adjust: 100%; /* Prevent font scaling in landscape */
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
    font-weight: 400;
    line-height: 1.6;
    background-color: #FFF7EE;
        min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.navbar {
    display: flex;
    align-items: center;
    height: 12vh; /* fixed header height on viewport */
    min-height: 56px;
    box-shadow: 0 .2rem 1rem rgba(0, 0, 0, .1);
    background-color: white;
    padding: 1rem;
}

.logo {
    height: 50rem;
    max-height: 56px;
    width: auto;
    display: block;
}

/* Moderation icon container in navbar (top-right) */
.moderation {
    margin-left: 1rem;
    margin-right: 0.5rem;
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.mod-btn {
    background: transparent;
    border: none;
    font-size: 2.2rem;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    border-radius: 6px;
}

.mod-btn:hover {
    background: rgba(0,0,0,0.04);
}

/* Exit modal styles */
.modal.hide { display: none; }
.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.45);
}
.modal-panel {
    position: relative;
    background: #fff;
    width: 90%;
    max-width: 520px;
    padding: 1.4rem;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}
.modal-close {
    position: absolute;
    right: 0.6rem;
    top: 0.6rem;
    border: none;
    background: transparent;
    font-size: 1.1rem;
    cursor: pointer;
}
.modal-panel h3 {
    margin: 0;
    font-size: 1.6rem;
}
.exit-textarea {
    min-height: 84px;
    resize: vertical;
    padding: 0.8rem;
    font-size: 1.4rem;
    border: 1px solid #e6e6e6;
    border-radius: 8px;
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
}
.modal-actions .btn {
    padding: 0.6rem 1.1rem;
    font-size: 1.4rem;
    border-radius: 8px;
}
.modal-actions .start {
    background-image: linear-gradient(to bottom, #6EE7B7, #10B981) !important;
    color: white !important;
}

.description {
    font-size: 2.7rem;
    margin-left: 8rem;
    margin-top: 1rem;
    transform: rotate(-6deg);
}

.online {
    margin-left: auto;
    margin-right: 1rem;
    font-size: 2.7rem;
    color: #6CB5FF;
    min-height: 2rem;
    display: block;
}

.main {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 12vh); /* fill remaining viewport under header */
    overflow: hidden;
    pointer-events: auto;
}

.conversation {
    height: calc(100vh - 12vh - 17vh); /* default conversation height: viewport minus header and form */
    min-height: 320px;
    background-color: white;
    border: 1px solid #CCCCCC;
    border-top-left-radius: 7px;
    border-top-right-radius: 7px;
    padding: 1.5rem;
    font-size: 1.6rem;
    word-break: break-word;
    overflow-y: auto;
    overflow-x: hidden;
    pointer-events: auto;
}

.message {
    font-size: 1.4rem;
    font-weight: 700;
    color: #565656;
    margin-bottom: .7rem;
}

.chat {
    margin-bottom: .7rem;
    display: flex;
    gap: .6rem;
    align-items: flex-start;
}

.chat .text {
    display: inline-block;
    padding: .6rem .9rem;
    background: #f3f4f6;
    border-radius: 12px;
    max-width: 78%;
    word-break: break-word;
    font-size: 1.45rem;
    line-height: 1.35;
}

.typing {
    font-style: italic;
    color: #9CA3AF;
    text-align: center;
    width: 100%;
}

.name {
    font-weight: 700;
}

.red {
    color: #FF0101;
}

.blue {
    color: #0101FF;
}

.form {
    height: 17vh; /* fixed composer height on viewport */
    margin-top: 1rem;
    display: grid;
    grid-template-columns: 15rem 1fr 15rem;
    gap: 1rem;
    position: relative;
    z-index: 100;
    pointer-events: auto;
}

.btn {
    min-height: 44px;
    background-color: white;
    font-size: 1.6rem;
    border: 1px solid #CCCCCC;
    cursor: pointer;
    pointer-events: auto;
    z-index: 101;
    position: relative;
    transition: opacity 0.2s ease;
    touch-action: manipulation;
}

.btn:focus {
    outline: none;
}

.btn:hover {
    opacity: 0.9;
}

.bottom-left-radius {
    border-bottom-left-radius: 7px;
}

.bottom-right-radius {
    border-bottom-right-radius: 7px;
}

.start {
    background-image: linear-gradient(to bottom, #6EE7B7, #10B981) !important; /* green */
    color: white !important;
    font-weight: 600 !important;
    border: none !important;
    pointer-events: auto !important;
    cursor: pointer !important;
    z-index: 105 !important;
}

.start:hover {
    opacity: 0.95;
}

.start:focus{
    outline: none;
}

#send {
    background-image: linear-gradient(to bottom, #C084FC, #7C3AED) !important; /* purple */
    color: white !important;
    font-weight: 600 !important;
    border: none !important;
}

#send:hover {
    opacity: 0.95;
}

#send:focus {
    outline: none;
}

/* Make the Stop button visually match the Send button */
#stop {
    background-image: linear-gradient(to bottom, #C084FC, #7C3AED) !important;
    color: white !important;
    font-weight: 600 !important;
    border: none !important;
}

#stop:hover { opacity: 0.95; }

#stop:focus { outline: none; }

/* Make the Really button visually match Send/Stop */
#really {
    background-image: linear-gradient(to bottom, #C084FC, #7C3AED) !important;
    color: white !important;
    font-weight: 600 !important;
    border: none !important;
}

#really:hover { opacity: 0.95; }

#really:focus { outline: none; }

.textarea {
    height: 100%;
    resize: none;
    font-family: inherit;
    font-size: 1.6rem;
    border: 1px solid #CCCCCC;
    padding: 1rem;
    -webkit-user-select: text;
    user-select: text;
    -webkit-tap-highlight-color: transparent;
}

.textarea:focus {
    outline: none;
}

.hide {
    display: none !important;
}

.bold {
    font-weight: 700;
}

/* Message bubble styles (professional look) */
.bubble {
    display: inline-block;
    padding: .7rem 1rem;
    margin-bottom: .8rem;
    border-radius: 18px;
    max-width: 85%;
    word-break: break-word;
    font-size: 1.5rem;
    line-height: 1.4;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.bubble.you {
    background: linear-gradient(135deg, #0581FE, #7EBFFF);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.bubble.them {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    color: #111;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    font-weight: 500;
}
.bubble.system {
    background: transparent;
    color: #9CA3AF;
    text-align: center;
    width: 100%;
    border-radius: 0;
    margin-bottom: 1.2rem;
    font-style: italic;
    align-self: center;
    box-shadow: none;
}

/* Custom scrollbar for professional look */
.conversation::-webkit-scrollbar {
    width: 6px;
}

.conversation::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.conversation::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.conversation::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}


/* Tablet Styles */
@media only screen and (max-width: 56.25em) { /* 900px */
    .description {
        margin-left: 6rem;
        font-size: 2rem;
    }

    .online {
        font-size: 2rem;
    }

    .main {
        padding: 0.5rem;
    }

    .form {
        grid-template-columns: 12rem 1fr 12rem;
        gap: 0.8rem;
    }

    .btn {
        padding: 0.8rem 1.2rem;
        font-size: 1.5rem;
    }
}

@media only screen and (max-width: 48.125em) { /* 770px */
    .online {
        font-size: 1.8rem;
        margin-right: 0.5rem;
    }

    .logo {
        height: 15rem;
        max-height: 60px;
    }
}

/* Mobile Landscape */
@media only screen and (max-width: 43.75em) and (orientation: landscape) { /* 700px */
    .navbar {
        height: 15%;
        min-height: 50px;
    }

    .main {
        height: 85%;
    }

    .conversation {
        font-size: 1.4rem;
        padding: 1rem;
    }

    .form {
        grid-template-columns: 10rem 1fr 10rem;
        gap: 0.6rem;
        min-height: 50px;
    }

    .btn {
        font-size: 1.4rem;
        padding: 0.6rem 1rem;
    }

    .textarea {
        font-size: 1.4rem;
        padding: 0.8rem;
        min-height: 40px;
    }
}
/* Mobile Portrait - Omegle style full screen */
@media only screen and (max-width: 31.25em) { /* 500px */
    html, body {
        height: 100%;
        margin: 0;
        font-size: 16px;
        background-color: #f7f7f7;
    }
    .logo {
        height: 30rem;
        max-height: 40px;
    }
    /* Navbar / header */
    .navbar {
        height: 100px;
        display: flex;
        align-items: center;
        justify-content: center;
        background-color: #ffffff;
        box-shadow: 0 1px 4px rgba(0,0,0,0.1);
        font-size: 1.6rem;
        font-weight: bold;
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .logo {
        height: 35px;
        object-fit: contain;
    }

    /* Main chat container */
    .main {
        height: 88%;
        display: flex;
        flex-direction: column;
        padding: 0.5rem;
    }

    /* Conversation area */
    .conversation {
        height: 83%;
        overflow-y: auto;
        padding: 0.5rem;
        margin-bottom: 0.5rem;
        background-color: #ffffff;
        border-radius: 10px;
        box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
        font-size: 1.4rem;
        display: flex;
        flex-direction: column;
        gap: 0.3rem;
        scroll-behavior: smooth;
    }

    /* Input + send bar */
    .form {
        display: flex;
        gap: 0.5rem;
    }

    .textarea {
    flex: 1;
    height: 45px;          /* exactly same as send/start button */
    padding: 0 0.8rem;     /* horizontal padding */
    font-size: 1.4rem;     /* matches button text */
    line-height: 1.4rem;   /* vertical alignment */
    border-radius: 10px;
    border: 1px solid #ddd;
    outline: none;
    resize: none;
    box-sizing: border-box; /* ensures height includes padding */
}


    #send {
        width: 55px;
        height: 45px; /* same as input height */
        border-radius: 10px;
        border: none;
        background-color: #28a745;
        color: #fff;
        font-size: 1.4rem; /* same as input text */
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: 0.2s;
    }

    #send:hover {
        background-color: #218838;
    }

    /* Start or other buttons */
    .start {
        height: 45px; /* match input & send button height */
        border-radius: 10px;
        padding: 0 1rem;
        font-size: 1.4rem; /* match input & send */
        border: none;
        background-color: #007bff;
        color: #fff;
        cursor: pointer;
        transition: 0.2s;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Ensure Stop button matches Send on small screens */
    #stop {
        width: 55px;
        height: 45px; /* same as input height */
        border-radius: 10px;
        border: none;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: 0.2s;
        background-image: linear-gradient(to bottom, #C084FC, #7C3AED) !important;
        color: #fff !important;
    }

    /* Ensure Really button matches Stop/Send on small screens */
    #really {
        width: 55px;
        height: 45px; /* same as input height */
        border-radius: 10px;
        border: none;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: 0.2s;
        background-image: linear-gradient(to bottom, #C084FC, #7C3AED) !important;
        color: #fff !important;
    }

    .btn:hover {
        background-color: #0056b3;
    }

    /* Optional: rounded bottom corners */
    .bottom-left-radius,
    .bottom-right-radius {
        border-radius: inherit;
    }
}

@media only screen and (max-width: 32.5em) { /* 520px */
    .description {
        display: none;
    }

    .online {
        font-size: 1.6rem;
    }
}

/* Small Mobile */
@media only screen and (max-width: 28.125em) { /* 450px */
    html {
        font-size: 60%;
    }

    .navbar {
        height: 9%;
        min-height: 45px;
        padding: 0.5rem;
    }

    .logo {
        height: 12rem;
        max-height: 50px;
    }

    .main {
        height: 91%;
        padding: 0.3rem;
    }

    .conversation {
        padding: 0.8rem;
        font-size: 1.4rem;
    }

    .form {
        gap: 0.6rem;
        margin-top: 0.6rem;
    }

    .btn:not(#send) {
        min-height: 42px;
        font-size: 1.4rem;
    }

    .textarea {
        min-height: 42px;
        font-size: 1.4rem;
        padding: 0.8rem;
    }

    #send {
        min-height: 42px;
        font-size: 1.4rem;
        padding: 0 1.2rem;
    }

    /* Small devices: keep #stop same min-height as #send */
    #stop {
        min-height: 42px;
        font-size: 1.4rem;
        padding: 0 1.2rem;
    }

    /* Small devices: keep #really same min-height as #send */
    #really {
        min-height: 42px;
        font-size: 1.4rem;
        padding: 0 1.2rem;
    }
}

/* Extra Small Mobile - iPhone SE etc. */
@media only screen and (max-width: 375px) {
    html {
        font-size: 58%;
    }

    .navbar {
        height: 8%;
        min-height: 40px;
        padding: 0.3rem;
    }

    .logo {
        height: 10rem;
        max-height: 45px;
    }

    .online {
        font-size: 1.4rem;
        margin-right: 0.5rem;
    }

    .main {
        height: 92%;
        padding: 0.2rem;
    }

    .conversation {
        padding: 0.6rem;
        font-size: 1.3rem;
    }

    .message {
        font-size: 1.2rem;
    }

    .form {
        gap: 0.4rem;
        margin-top: 0.4rem;
    }

    .btn:not(#send) {
        min-height: 40px;
        font-size: 1.3rem;
        padding: 0.8rem;
    }

    .textarea {
        min-height: 40px;
        font-size: 1.3rem;
        padding: 0.6rem;
    }

    #send {
        min-height: 40px;
        font-size: 1.3rem;
        padding: 0 1rem;
    }

    /* Extra-small devices: ensure #stop matches #send */
    #stop {
        min-height: 40px;
        font-size: 1.3rem;
        padding: 0 1rem;
    }

    /* Extra-small devices: ensure #really matches #send */
    #really {
        min-height: 40px;
        font-size: 1.3rem;
        padding: 0 1rem;
    }
}

/* Very Small Height Devices */
@media only screen and (max-height: 500px) {
    .navbar {
        height: 15%;
        min-height: 45px;
    }

    .main {
        height: 85%;
    }

    .conversation {
        font-size: 1.3rem;
    }

    .form {
        min-height: 50px;
    }

    .btn:not(#send) {
        min-height: 38px;
    }

    .textarea {
        min-height: 38px;
        max-height: 80px;
    }
}

/* Safe area insets for notched devices */
@supports(padding: max(0px)) {
    .navbar, .main {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }

    .navbar {
        padding-top: max(1rem, env(safe-area-inset-top));
    }

    .main {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}

/* Prevent zoom on iOS input focus */
@media screen and (max-width: 768px) {
    .textarea {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .btn {
        border-width: 0.5px;
    }
}