* {
    margin: 0;
    padding: 0;
    box-sizing: border-box
}

:root {
    --primary: #6366f1;
    --primary-glow: rgba(99, 102, 241, .5);
    --accent: #a855f7;
    --bg: #050510;
    --card: #0d0d20;
    --card-border: #1a1a35;
    --input: #12122a;
    --text: #fff;
    --text-dim: #9ca3af;
    --success: #22c55e;
    --danger: #ef4444
}

html,
body {
    height: 100%;
    overflow: hidden
}

body {
    font-family: 'Poppins', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text)
}

.app {
    height: 100%;
    width: 100%;
    position: relative
}

.screen {
    display: none;
    height: 100%;
    width: 100%;
    position: absolute;
    inset: 0
}

.screen.active {
    display: flex
}

/* Background */
.bg-effects {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: -1
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: .4
}

.blob-1 {
    width: 400px;
    height: 400px;
    background: var(--primary);
    top: -150px;
    left: -150px
}

.blob-2 {
    width: 350px;
    height: 350px;
    background: var(--accent);
    bottom: -100px;
    right: -100px
}

.blob-3 {
    width: 250px;
    height: 250px;
    background: #ec4899;
    top: 40%;
    left: 40%
}

/* Landing - Compact 90vh */
#landing-screen {
    align-items: center;
    justify-content: center;
    height: 90vh;
    margin: 5vh auto
}

.landing-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 400px;
    padding: 16px;
    gap: 14px
}

.brand {
    text-align: center
}

.logo-box {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 8px;
    font-size: 26px;
    box-shadow: 0 6px 25px var(--primary-glow)
}

.brand h1 {
    font-size: 1.7rem;
    font-weight: 800;
    background: linear-gradient(135deg, #fff, #c4b5fd);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text
}

.brand h1 span {
    background: linear-gradient(135deg, var(--accent), #ec4899);
    -webkit-background-clip: text;
    background-clip: text
}

.tagline {
    color: var(--text-dim);
    font-size: .8rem;
    margin-top: 2px
}

.hero {
    text-align: center
}

.hero h2 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 4px
}

.hero .highlight {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text
}

.hero p {
    color: var(--text-dim);
    font-size: .78rem;
    line-height: 1.4
}

.card {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 16px;
    width: 100%
}

.online-count {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-bottom: 10px;
    font-size: .75rem;
    color: var(--text-dim)
}

.pulse {
    width: 7px;
    height: 7px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite
}

@keyframes pulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, .6)
    }

    50% {
        box-shadow: 0 0 0 5px rgba(34, 197, 94, 0)
    }
}

.input-wrap {
    position: relative;
    margin-bottom: 10px
}

.input-wrap input {
    width: 100%;
    padding: 11px 12px 11px 40px;
    background: var(--input);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    color: var(--text);
    font-size: .85rem;
    font-family: inherit
}

.input-wrap input:focus {
    outline: none;
    border-color: var(--primary)
}

.input-wrap input::placeholder {
    color: #555
}

.input-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: .95rem
}

.mode-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 10px
}

.tab {
    flex: 1;
    padding: 10px 8px;
    background: var(--input);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    color: var(--text-dim);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: .2s
}

.tab.active {
    background: rgba(99, 102, 241, .15);
    border-color: var(--primary);
    color: var(--text)
}

.tab-icon {
    font-size: 1.1rem
}

.tab-text strong {
    display: block;
    font-size: .78rem;
    font-weight: 600
}

.tab-text small {
    font-size: .65rem;
    color: var(--text-dim)
}

.tab.active .tab-text small {
    color: var(--primary)
}

.start-btn {
    width: 100%;
    padding: 11px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border: none;
    border-radius: 10px;
    color: #fff;
    font-size: .85rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-transform: uppercase
}

.start-btn:disabled {
    opacity: .4;
    cursor: not-allowed
}

.start-btn:not(:disabled):hover {
    box-shadow: 0 8px 25px var(--primary-glow)
}

.start-btn .arrow {
    font-size: .95rem
}

.features {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
    justify-content: center
}

.feature {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, .02);
    border: 1px solid var(--card-border);
    padding: 6px 10px;
    border-radius: 8px;
    font-size: .7rem
}

.feature-icon {
    font-size: .9rem
}

.feature strong {
    font-weight: 600
}

.feature p {
    display: none
}

.footer {
    color: #444;
    font-size: .65rem;
    text-align: center;
    margin-top: 8px
}

/* ==================== */
/* Chat Screen - Full Size */
/* ==================== */
#chat-screen {
    flex-direction: column;
    background: var(--bg)
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    background: var(--card);
    border-bottom: 1px solid var(--card-border)
}

.btn-icon {
    width: 44px;
    height: 44px;
    background: var(--input);
    border: 2px solid var(--card-border);
    border-radius: 12px;
    color: var(--text);
    font-size: 1.3rem;
    cursor: pointer;
    transition: .2s;
    display: flex;
    align-items: center;
    justify-content: center
}

.btn-icon:hover {
    background: var(--primary);
    border-color: var(--primary)
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1
}

.avatar {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2rem
}

.user-details {
    flex: 1
}

.name {
    font-weight: 700;
    font-size: 1.1rem
}

.status {
    font-size: .9rem;
    color: var(--text-dim)
}

.status.online {
    color: var(--success)
}

.btn-next {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--input);
    border: 2px solid var(--card-border);
    border-radius: 12px;
    color: var(--text);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: .2s
}

.btn-next:disabled {
    opacity: .4;
    cursor: not-allowed
}

.btn-next:not(:disabled):hover {
    background: var(--primary);
    border-color: var(--primary)
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: flex-direction .3s ease
}

/* Chat Sidebar - wraps messages and input for side-by-side layout */
.chat-sidebar {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    transition: width .3s ease, box-shadow .3s ease
}

/* Text-only mode - full screen chat (class-based for JS toggle) */
.chat-main.text-only-mode .chat-sidebar {
    width: 100%;
    max-width: 100%;
    min-width: 100%;
    border-left: none;
    box-shadow: none
}

.chat-main.text-only-mode .messages-area {
    max-width: 900px;
    margin: 0 auto;
    width: 100%
}

.chat-main.text-only-mode .chat-input {
    max-width: 900px;
    margin: 0 auto;
    width: 100%
}

/* Video */
.video-area {
    height: 50%;
    min-height: 220px;
    background: #000;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: flex .3s ease, height .3s ease
}

.video-area.hidden {
    display: none
}

.video-area>video {
    width: 100%;
    height: 100%;
    object-fit: cover
}

.video-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--card);
    color: var(--text-dim);
    opacity: 1;
    transition: opacity .4s ease-out
}

.video-placeholder.hidden {
    opacity: 0;
    pointer-events: none
}

.video-placeholder span {
    font-size: 3rem;
    margin-bottom: 12px
}

.video-placeholder p {
    font-size: 1rem
}

.pip {
    position: absolute;
    bottom: 70px;
    right: 16px;
    width: 120px;
    height: 160px;
    border-radius: 16px;
    overflow: hidden;
    border: 3px solid var(--card);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .6);
    transition: transform .2s ease, box-shadow .2s ease
}

.pip:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 32px rgba(0, 0, 0, .8)
}

.pip video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1)
}

.pip-label {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(0, 0, 0, .7);
    padding: 4px 10px;
    border-radius: 8px;
    font-size: .75rem;
    font-weight: 600
}

.video-btns {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 12px
}

.ctrl-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: var(--card);
    color: var(--text);
    font-size: 1.3rem;
    cursor: pointer;
    transition: .2s;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .4)
}

.ctrl-btn .off {
    display: none
}

.ctrl-btn:not(.active) {
    background: var(--danger)
}

.ctrl-btn:not(.active) .on {
    display: none
}

.ctrl-btn:not(.active) .off {
    display: block
}

.ctrl-btn:hover {
    transform: scale(1.1)
}

/* Messages */
.messages-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow: hidden;
    min-height: 0
}

.messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-right: 8px
}

.messages::-webkit-scrollbar {
    width: 5px
}

.messages::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px
}

.message {
    max-width: 75%;
    padding: 14px 18px;
    border-radius: 20px;
    font-size: 1rem;
    line-height: 1.5;
    animation: msgIn .3s ease
}

@keyframes msgIn {
    from {
        opacity: 0;
        transform: translateY(10px)
    }

    to {
        opacity: 1;
        transform: translateY(0)
    }
}

.message.sent {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-bottom-right-radius: 6px
}

.message.received {
    align-self: flex-start;
    background: var(--card);
    border: 1px solid var(--card-border);
    border-bottom-left-radius: 6px
}

.message .sender {
    font-size: .8rem;
    font-weight: 600;
    margin-bottom: 4px;
    opacity: .8
}

.message.system {
    align-self: center;
    background: rgba(99, 102, 241, .1);
    color: var(--text-dim);
    font-size: .9rem;
    padding: 10px 18px;
    border: 1px dashed var(--card-border);
    border-radius: 20px;
    max-width: 90%;
    text-align: center
}

.typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    background: var(--card);
    border-radius: 20px;
    width: fit-content
}

.typing.hidden {
    display: none
}

.typing span {
    width: 8px;
    height: 8px;
    background: var(--text-dim);
    border-radius: 50%;
    animation: dot 1.4s infinite
}

.typing span:nth-child(2) {
    animation-delay: .2s
}

.typing span:nth-child(3) {
    animation-delay: .4s
}

.typing p {
    font-size: .85rem;
    color: var(--text-dim);
    margin: 0
}

@keyframes dot {

    0%,
    60%,
    100% {
        transform: translateY(0)
    }

    30% {
        transform: translateY(-6px)
    }
}

.chat-input {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    background: var(--card);
    border-top: 1px solid var(--card-border);
    flex-shrink: 0
}

.chat-input input {
    flex: 1;
    min-width: 0;
    padding: 16px 20px;
    background: var(--input);
    border: 2px solid var(--card-border);
    border-radius: 16px;
    color: var(--text);
    font-size: 1.05rem;
    font-family: inherit;
    transition: .2s
}

.chat-input input:focus {
    outline: none;
    border-color: var(--primary)
}

.chat-input input:disabled {
    opacity: .4
}

.chat-input input::placeholder {
    color: #555
}

.btn-send {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 24px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border: none;
    border-radius: 16px;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: .2s;
    flex-shrink: 0
}

.btn-send:disabled {
    opacity: .4;
    cursor: not-allowed
}

.btn-send:not(:disabled):hover {
    transform: scale(1.05);
    box-shadow: 0 8px 24px var(--primary-glow)
}

/* Mobile - Stacked video and chat layout */
@media(max-width:767px) {
    .chat-main {
        flex-direction: column
    }

    .video-area {
        height: 45%;
        min-height: 200px;
        flex: none
    }

    .chat-sidebar {
        flex: 1;
        border-left: none;
        width: 100%;
        min-width: unset;
        max-width: unset
    }

    .chat-sidebar .messages-area {
        flex: 1;
        overflow: hidden
    }

    .chat-sidebar .messages {
        overflow-y: auto
    }

    .pip {
        width: 90px;
        height: 120px;
        bottom: 60px;
        right: 12px
    }
}

/* Desktop - Side-by-side video and chat layout */
@media(min-width:768px) {
    .chat-main {
        flex-direction: row
    }

    .video-area {
        flex: 1;
        height: 100%;
        min-height: unset;
        max-height: none
    }

    .video-area>video {
        width: 100%;
        height: 100%;
        object-fit: cover
    }

    .video-area.hidden {
        display: none
    }

    .video-placeholder {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center
    }

    .video-placeholder span {
        font-size: 5rem;
        margin-bottom: 16px
    }

    .video-placeholder p {
        font-size: 1.25rem
    }

    .pip {
        width: 150px;
        height: 200px;
        bottom: 80px;
        right: 20px
    }

    .video-btns {
        bottom: 20px;
        gap: 16px
    }

    .ctrl-btn {
        width: 56px;
        height: 56px;
        font-size: 1.4rem
    }

    /* Video mode - sidebar layout */
    .chat-main:not(.text-only-mode) .chat-sidebar {
        width: 320px;
        min-width: 280px;
        max-width: 380px;
        border-left: 1px solid var(--card-border);
        flex: none;
        box-shadow: -4px 0 20px rgba(0, 0, 0, .3)
    }

    /* Text-only mode - full width centered chat */
    .chat-main.text-only-mode {
        justify-content: center
    }

    .chat-main.text-only-mode .chat-sidebar {
        width: 100%;
        max-width: 900px;
        border-left: none;
        box-shadow: none;
        flex: 1
    }

    .chat-sidebar .messages-area {
        flex: 1;
        overflow: hidden
    }

    .chat-sidebar .messages {
        overflow-y: auto
    }

    .chat-sidebar .chat-input {
        flex-shrink: 0
    }
}

/* Mobile - Landing only compact */
@media(max-width:600px) {
    #landing-screen {
        height: 100%;
        margin: 0
    }

    .landing-wrapper {
        padding: 20px;
        gap: 16px;
        justify-content: center;
        height: 100%
    }

    .features {
        display: none
    }

    .footer {
        display: none
    }

    /* Chat stays full size on mobile */
    .chat-header {
        padding: 12px 16px;
        gap: 10px
    }

    .btn-icon {
        width: 40px;
        height: 40px
    }

    .avatar {
        width: 42px;
        height: 42px
    }

    .name {
        font-size: 1rem
    }

    .btn-next {
        padding: 10px 16px;
        font-size: .9rem
    }

    .btn-next span:first-child {
        display: none
    }

    .messages-area {
        padding: 14px
    }

    .message {
        max-width: 85%;
        padding: 12px 14px;
        font-size: .95rem
    }

    .chat-input {
        padding: 10px 12px;
        gap: 8px
    }

    .chat-input input {
        padding: 12px 14px;
        font-size: .95rem;
        border-radius: 12px
    }

    .btn-send {
        padding: 12px 16px;
        border-radius: 12px;
        font-size: .9rem
    }

    .btn-send span:first-child {
        display: none
    }

    .pip {
        width: 90px;
        height: 120px;
        bottom: 60px;
        right: 12px
    }
}

@media(max-width:380px) {
    .logo-box {
        width: 48px;
        height: 48px;
        font-size: 22px
    }

    .brand h1 {
        font-size: 1.5rem
    }

    .hero h2 {
        font-size: 1rem
    }

    .card {
        padding: 14px
    }

    .tab {
        padding: 8px 6px
    }

    .tab-icon {
        font-size: 1rem
    }

    .start-btn {
        padding: 10px;
        font-size: .8rem
    }

    /* Extra small chat input */
    .chat-input {
        padding: 8px 10px;
        gap: 6px
    }

    .chat-input input {
        padding: 10px 12px;
        font-size: .9rem;
        border-radius: 10px
    }

    .btn-send {
        padding: 10px 14px;
        border-radius: 10px;
        font-size: .85rem
    }
}