:root {
    --meeting-bg: #101418;
    --meeting-surface: #1b2027;
    --meeting-surface-strong: #252b33;
    --meeting-border: rgba(255, 255, 255, 0.12);
    --meeting-text: #f8fafc;
    --meeting-muted: #aeb8c4;
    --meeting-green: #20c997;
    --meeting-blue: #4c8bf5;
    --meeting-yellow: #fbbc04;
    --meeting-red: #ea4335;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

.meeting-body {
    margin: 0;
    background: var(--meeting-bg);
    color: var(--meeting-text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.entry-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(135deg, rgba(32, 201, 151, 0.18), transparent 32%),
        linear-gradient(315deg, rgba(251, 188, 4, 0.14), transparent 34%),
        #f6f8fb;
    color: #1f2937;
}

.entry-panel {
    width: min(100%, 460px);
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.16);
    padding: 32px;
}

.brand-mark,
.meeting-logo {
    display: inline-flex;
    align-items: center;
}

.brand-mark img {
    max-width: 170px;
    height: auto;
}

.entry-kicker {
    margin: 26px 0 6px;
    color: var(--meeting-blue);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
}

.entry-panel h1 {
    margin: 0 0 22px;
    font-size: 32px;
    font-weight: 750;
}

.entry-panel label {
    display: block;
    margin: 18px 0 8px;
    font-weight: 650;
    color: #344054;
}

.meeting-input {
    min-height: 50px;
    border: 1px solid #cfd6df;
    border-radius: 8px;
}

.meeting-input:focus {
    border-color: var(--meeting-blue);
    box-shadow: 0 0 0 4px rgba(76, 139, 245, 0.15);
}

.primary-entry-button {
    width: 100%;
    min-height: 52px;
    margin-top: 24px;
    border: 0;
    border-radius: 8px;
    background: #155eef;
    color: #ffffff;
    font-weight: 750;
    transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.primary-entry-button:hover {
    background: #0f49c7;
    box-shadow: 0 12px 28px rgba(21, 94, 239, 0.24);
    transform: translateY(-1px);
}

.entry-result {
    margin-top: 18px;
    color: #344054;
}

.meeting-app {
    height: 100vh;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--meeting-bg);
}

.meeting-topbar {
    height: 72px;
    flex: 0 0 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 12px 24px;
    border-bottom: 1px solid var(--meeting-border);
    background: rgba(16, 20, 24, 0.96);
    position: relative;
    z-index: 10;
}

.meeting-title-group {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 14px;
}

.meeting-logo {
    width: 44px;
    height: 44px;
    justify-content: center;
    border-radius: 8px;
    background: #ffffff;
    padding: 6px;
    flex: 0 0 auto;
}

.meeting-logo img {
    max-width: 100%;
    max-height: 100%;
}

.meeting-title {
    max-width: 58vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 18px;
    font-weight: 750;
}

.meeting-subtitle {
    margin-top: 2px;
    color: var(--meeting-muted);
    font-size: 13px;
}

.meeting-status {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--meeting-muted);
    font-size: 14px;
    white-space: nowrap;
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 999px;
    background: var(--meeting-yellow);
    box-shadow: 0 0 0 5px rgba(251, 188, 4, 0.14);
}

.meeting-status.is-connected .status-dot {
    background: var(--meeting-green);
    box-shadow: 0 0 0 5px rgba(32, 201, 151, 0.14);
}

.meeting-content {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    overflow: hidden;
}

.video-stage {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    padding: 16px 20px;
    overflow: hidden;
}

.video-grid {
    width: 100%;
    height: 100%;
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr));
    grid-auto-rows: minmax(0, 1fr);
    gap: 14px;
    align-items: center;
    justify-content: center;
}

.video-grid.participant-count-1 {
    grid-template-columns: minmax(0, min(100%, 1180px));
    grid-auto-rows: minmax(0, min(100%, 680px));
    place-content: center;
}

.video-grid.participant-count-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: minmax(0, 1fr);
}

.video-grid.participant-count-many {
    align-items: stretch;
}

.empty-call-state {
    min-height: 0;
    height: 100%;
    grid-column: 1 / -1;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 12px;
    border: 1px dashed rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    text-align: center;
    color: var(--meeting-muted);
    padding: 24px;
}

.empty-call-state h2 {
    margin: 0;
    color: var(--meeting-text);
    font-size: 24px;
    font-weight: 750;
}

.empty-call-state p {
    margin: 0;
}

.spinner-ring {
    width: 42px;
    height: 42px;
    border: 4px solid rgba(255, 255, 255, 0.18);
    border-top-color: var(--meeting-blue);
    border-radius: 50%;
    animation: meeting-spin 0.9s linear infinite;
}

.empty-call-state:not(.is-loading) .spinner-ring {
    display: none;
}

.video-grid > .card,
.video-grid > .card-sm {
    position: relative;
    width: auto !important;
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    border: 1px solid var(--meeting-border);
    border-radius: 8px;
    background: var(--meeting-surface);
    box-shadow: none;
}

.video-grid > .card.active-speaker {
    border-color: var(--meeting-green);
    box-shadow: 0 0 0 2px rgba(32, 201, 151, 0.34);
}

.remote-video,
.local-video {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    background: #0b0f13;
}

.remote-video {
    min-height: 0;
    object-fit: contain;
}

.remote-video-controls {
    position: absolute;
    right: 10px;
    bottom: 10px;
    z-index: 4;
    display: inline-flex;
    gap: 8px;
    padding: 8px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.48);
    opacity: 0;
    transition: opacity 0.18s ease;
}

.video-grid > .card:hover .remote-video-controls,
.remote-video-controls:hover {
    opacity: 1;
}

.remote-video-controls i {
    width: 34px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    cursor: pointer;
}

.video-name-tag,
.participant-name {
    position: absolute;
    left: 12px;
    bottom: 12px;
    z-index: 3;
    max-width: calc(100% - 24px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.58);
    color: #ffffff;
    padding: 7px 11px;
    font-size: 13px;
    font-weight: 650;
}

.local-video-wrap {
    position: absolute;
    right: 28px;
    bottom: 28px;
    z-index: 9;
    width: clamp(168px, 21vw, 280px);
    aspect-ratio: 16 / 10;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.24);
    border-radius: 8px;
    background: #0b0f13;
    box-shadow: 0 20px 55px rgba(0, 0, 0, 0.42);
}

.mirror-mode {
    transform: scaleX(-1);
}

.meeting-controls {
    position: relative;
    flex: 0 0 auto;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    max-width: calc(100vw - 28px);
    margin: 0 auto 14px;
    padding: 10px;
    border: 1px solid var(--meeting-border);
    border-radius: 999px;
    background: rgba(27, 32, 39, 0.94);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.36);
}

.control-button,
.icon-control,
.send-button {
    border: 0;
    color: #ffffff;
    cursor: pointer;
    transition: background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.control-button {
    position: relative;
    min-width: 76px;
    height: 52px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 999px;
    background: var(--meeting-surface-strong);
    padding: 0 16px;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
}

.control-button:hover,
.icon-control:hover,
.send-button:hover {
    color: #ffffff;
    background: #343c46;
    transform: translateY(-1px);
}

.control-button.is-off {
    background: #3b2022;
}

.control-button.is-live {
    background: #20372f;
}

.secondary-action {
    background: #27313b;
}

.leave-button {
    background: var(--meeting-red);
}

.leave-button:hover {
    background: #c5221f;
}

.badge {
    position: absolute;
    top: -4px;
    right: -4px;
    border-radius: 999px;
    background: var(--meeting-red);
    color: #ffffff;
    font-size: 10px;
    padding: 3px 6px;
}

.chat-col {
    position: absolute;
    top: 12px;
    right: -420px;
    bottom: 12px;
    z-index: 15;
    width: min(380px, calc(100vw - 24px));
    display: flex;
    flex-direction: column;
    color: var(--meeting-text);
    padding: 0;
    border: 1px solid var(--meeting-border);
    border-radius: 8px;
    background: #f8fafc;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
    transition: right 0.24s ease;
}

.chat-col.chat-opened {
    right: 12px;
}

.chat-header {
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid #e5e7eb;
    color: #111827;
}

.chat-title {
    font-size: 17px;
    font-weight: 750;
}

.chat-subtitle {
    color: #667085;
    font-size: 13px;
}

.icon-control.small-control {
    width: 38px;
    height: 38px;
    display: inline-grid;
    place-items: center;
    border-radius: 999px;
    background: #eef2f6;
    color: #344054;
}

#chat-messages {
    flex: 1;
    min-height: 0;
    margin: 0;
    padding: 16px;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
}

.chat-form {
    display: grid;
    grid-template-columns: 1fr 46px;
    gap: 10px;
    padding: 14px;
    border-top: 1px solid #e5e7eb;
    background: #ffffff;
}

.chat-box {
    min-height: 46px;
    max-height: 110px;
    resize: none !important;
    border: 1px solid #d0d5dd;
    border-radius: 8px !important;
    box-shadow: none !important;
    font-size: 14px;
}

.chat-box:focus {
    border-color: var(--meeting-blue);
    box-shadow: 0 0 0 4px rgba(76, 139, 245, 0.12) !important;
}

.send-button {
    width: 46px;
    height: 46px;
    border-radius: 999px;
    background: var(--meeting-blue);
}

.sender-info {
    display: block;
    margin-top: 6px;
    color: #667085;
    font-size: 11px;
}

.msg {
    border: 0;
    border-radius: 8px;
    color: #111827;
    background: #eef2f6;
    font-size: 13px;
    line-height: 1.45;
    padding: 10px 12px;
}

.msg.bg-white {
    background: #dff4ea !important;
}

.chat-card {
    border-radius: 8px;
}

.btn-no-effect:focus {
    box-shadow: none;
}

.pointer {
    cursor: pointer;
}

.meeting-toast {
    position: fixed;
    top: 86px;
    left: 50%;
    z-index: 30;
    max-width: calc(100vw - 32px);
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(248, 250, 252, 0.96);
    color: #111827;
    font-size: 14px;
    box-shadow: 0 16px 44px rgba(0, 0, 0, 0.26);
    transform: translateX(-50%);
}

.custom-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background: rgba(8, 12, 16, 0.68);
}

.custom-modal-content {
    width: min(92vw, 460px);
    margin: 12vh auto;
    padding: 24px;
    border: 1px solid var(--meeting-border);
    border-radius: 8px;
    background: #ffffff;
    color: #111827;
    text-align: center;
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.34);
}

.modal-heading {
    margin-bottom: 18px;
    font-size: 20px;
    font-weight: 750;
}

.record-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.record-option {
    min-height: 132px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 10px;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    background: #f8fafc;
    color: #111827;
    cursor: pointer;
    font-weight: 700;
    transition: border 0.18s ease, transform 0.18s ease, background 0.18s ease;
}

.record-option:hover {
    border-color: var(--meeting-blue);
    background: #eef4ff;
    transform: translateY(-1px);
}

.record-option i {
    color: var(--meeting-blue);
    font-size: 26px;
}

@keyframes meeting-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 900px) {
    .meeting-topbar {
        height: 64px;
        flex-basis: 64px;
        padding: 10px 14px;
    }

    .meeting-status {
        display: none;
    }

    .video-stage {
        padding: 12px;
    }

    .video-grid {
        min-height: 0;
        grid-auto-rows: minmax(0, 1fr);
        gap: 10px;
    }

    .video-grid.participant-count-1,
    .video-grid.participant-count-2 {
        grid-template-columns: 1fr;
        grid-auto-rows: minmax(0, 1fr);
        align-content: center;
    }

    .empty-call-state {
        min-height: 0;
    }

    .local-video-wrap {
        right: 16px;
        bottom: 16px;
        width: clamp(132px, 36vw, 210px);
    }

    .meeting-controls {
        width: calc(100vw - 24px);
        justify-content: space-between;
        gap: 6px;
        border-radius: 8px;
    }

    .control-button {
        min-width: 0;
        width: 52px;
        padding: 0;
    }

    .control-button span:not(.badge) {
        display: none;
    }

    .chat-col {
        top: 10px;
        bottom: 10px;
        width: calc(100vw - 20px);
    }
}

@media (max-width: 560px) {
    .entry-panel {
        padding: 24px;
    }

    .entry-panel h1 {
        font-size: 27px;
    }

    .meeting-title {
        max-width: 62vw;
        font-size: 16px;
    }

    .meeting-subtitle {
        font-size: 12px;
    }

    .meeting-logo {
        width: 38px;
        height: 38px;
    }

    .video-grid {
        grid-template-columns: 1fr;
        grid-auto-rows: minmax(0, 1fr);
    }

    .video-grid.participant-count-1,
    .video-grid.participant-count-2 {
        grid-template-columns: 1fr;
        grid-auto-rows: minmax(0, 1fr);
    }

    .video-grid > .card,
    .video-grid > .card-sm {
        min-height: 0;
    }

    .remote-video {
        min-height: 0;
    }

    .local-video-wrap {
        width: 124px;
    }

    .record-options {
        grid-template-columns: 1fr;
    }
}
