.direct-chat-page {
    overscroll-behavior: none;
}

.direct-chat-page .public-shell {
    min-height: 100dvh;
}

.direct-chat-app {
    --chat-surface: rgba(255, 255, 255, 0.9);
    --chat-soft: rgba(238, 245, 255, 0.92);
    --chat-line: rgba(124, 146, 180, 0.22);
    height: 100dvh;
    max-width: none;
    padding: 14px 18px max(14px, env(safe-area-inset-bottom));
    grid-template-columns: minmax(340px, 0.88fr) minmax(420px, 1.12fr);
    grid-template-rows: auto auto auto minmax(0, 1fr) auto;
    align-items: stretch;
    overflow: hidden;
}

.direct-chat-app.is-chat-open::before {
    content: none;
    display: none;
    backdrop-filter: none;
}

.direct-chat-app .direct-app-bar,
.direct-chat-app .direct-assurance,
.direct-chat-app .direct-title {
    grid-column: 1 / -1;
}

.direct-chat-app .direct-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-inline: min(1vw, 12px);
}

.direct-chat-app .direct-title h1 {
    font-size: clamp(2rem, 3vw, 3.4rem);
}

.direct-chat-app .direct-overview {
    grid-column: 1 / 2;
    grid-row: 4 / 5;
    align-self: start;
}

.direct-chat-app .direct-livebar {
    grid-column: 2 / 3;
    grid-row: 4 / 5;
    justify-content: flex-end;
    align-self: start;
}

.direct-chat-app .direct-chat-panel {
    position: relative;
    z-index: 1;
    inset: auto;
    grid-column: 2 / 3;
    grid-row: 4 / 5;
    width: auto;
    min-height: 0;
    border-radius: 18px;
    background: var(--chat-surface);
    box-shadow: 0 22px 70px rgba(31, 60, 114, 0.12);
}

.direct-chat-app .direct-chat-head {
    padding: 14px 16px;
}

.direct-chat-app .direct-chat-head .direct-icon-button {
    display: none;
}

.direct-chat-app .direct-chat-messages {
    background:
        linear-gradient(180deg, rgba(248, 251, 255, 0.96), rgba(244, 249, 255, 0.96)),
        var(--chat-soft);
}

.direct-chat-app .direct-chat-compose {
    position: relative;
    grid-template-columns: 42px minmax(0, 1fr) 42px 42px 42px 42px;
}

.direct-chat-app .direct-chat-compose input {
    min-height: 42px;
    border-radius: 16px;
}

.direct-chat-app .direct-emoji-panel {
    position: absolute;
    left: 10px;
    bottom: calc(100% + 8px);
    z-index: 8;
    display: grid;
    grid-template-columns: repeat(6, 34px);
    gap: 6px;
    padding: 10px;
    border: 1px solid var(--chat-line);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 14px 36px rgba(31, 60, 114, 0.16);
}

.direct-chat-app .direct-emoji-panel[hidden] {
    display: none;
}

.direct-chat-app .direct-emoji-panel button {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 10px;
    background: #f3f7ff;
    cursor: pointer;
    font-size: 1.05rem;
}

.direct-chat-app .direct-panels {
    grid-column: 1 / 2;
    grid-row: 4 / 5;
    min-height: 0;
}

.direct-chat-app .direct-panel-scroll {
    height: 100%;
    min-height: 0;
    overflow: auto;
    scrollbar-width: thin;
}

.direct-chat-app .direct-card {
    border-radius: 18px;
    box-shadow: 0 18px 52px rgba(31, 60, 114, 0.1);
}

.direct-chat-app .direct-insight-card,
.direct-chat-app .direct-connection-steps {
    display: none;
}

.direct-chat-app .direct-tabbar {
    grid-column: 1 / -1;
    width: min(720px, 100%);
}

.direct-chat-app .direct-size-inputs {
    display: inline-grid;
    grid-template-columns: 92px 82px;
    gap: 8px;
}

.direct-chat-app .direct-size-inputs input,
.direct-chat-app .direct-size-inputs select {
    min-height: 42px;
    border: 1px solid var(--chat-line);
    border-radius: 14px;
    padding: 0 12px;
    background: #fff;
    color: var(--ds-ink);
    font: inherit;
    font-weight: 800;
}

.direct-chat-app .direct-contact-rules {
    display: grid;
    gap: 8px;
}

.direct-chat-app .direct-contact-rule {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    min-height: 58px;
    padding: 9px 10px;
    border: 1px solid var(--chat-line);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.78);
}

.direct-chat-app .direct-contact-rule input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--ds-accent);
}

.direct-chat-app .direct-contact-rule strong,
.direct-chat-app .direct-contact-rule small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.direct-chat-app .direct-contact-rule strong {
    color: var(--ds-ink);
    font-size: 0.92rem;
}

.direct-chat-app .direct-contact-rule small {
    color: var(--ds-muted);
    font-size: 0.74rem;
    font-weight: 750;
}

.direct-chat-app .direct-contact-limit {
    display: grid;
    grid-template-columns: 70px 68px;
    gap: 6px;
}

.direct-chat-app .direct-contact-limit input,
.direct-chat-app .direct-contact-limit select {
    min-height: 38px;
    border: 1px solid var(--chat-line);
    border-radius: 12px;
    padding: 0 9px;
    background: #fff;
    color: var(--ds-ink);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 800;
}

.direct-chat-app .direct-contact-rules-empty {
    margin: 0;
    color: var(--ds-muted);
    font-weight: 750;
}

@media (max-width: 820px) {
    .direct-chat-page {
        height: 100dvh;
        overflow: hidden;
        touch-action: manipulation;
    }

    .direct-chat-app {
        padding: 8px 10px max(8px, env(safe-area-inset-bottom));
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto auto minmax(0, 1fr) auto;
        gap: 7px;
    }

    .direct-chat-app .direct-app-bar {
        display: none;
    }

    .direct-chat-app .direct-title {
        min-height: auto;
        padding: 2px 4px 0;
    }

    .direct-chat-app .direct-title h1 {
        font-size: 1.6rem;
    }

    .direct-chat-app .direct-assurance {
        gap: 5px;
        overflow: auto hidden;
        scrollbar-width: none;
    }

    .direct-chat-app .direct-assurance span {
        min-height: 30px;
        padding: 6px 10px;
        font-size: 0.76rem;
        white-space: nowrap;
    }

    .direct-chat-app .direct-overview,
    .direct-chat-app .direct-livebar {
        display: none;
    }

    .direct-chat-app .direct-panels,
    .direct-chat-app .direct-chat-panel {
        grid-column: 1;
        grid-row: 3 / 4;
    }

    .direct-chat-app.is-chat-open .direct-panels {
        display: none;
    }

    .direct-chat-app:not(.is-chat-open) .direct-chat-panel {
        display: none;
    }

    .direct-chat-app .direct-chat-panel {
        position: relative;
        inset: auto;
        width: auto;
        border-radius: 18px;
    }

    .direct-chat-app .direct-chat-head {
        padding: 12px 14px;
    }

    .direct-chat-app .direct-chat-head .direct-icon-button {
        display: inline-grid;
    }

    .direct-chat-app .direct-chat-compose {
        grid-template-columns: 38px minmax(0, 1fr) 38px 38px 38px;
        padding: 8px;
        gap: 6px;
    }

    .direct-chat-app .direct-chat-compose [data-audio-start],
    .direct-chat-app .direct-chat-compose [data-video-start] {
        display: none;
    }

    .direct-chat-app .direct-emoji-panel {
        grid-template-columns: repeat(4, 34px);
        left: 8px;
        bottom: calc(100% + 6px);
    }

    .direct-chat-app .direct-panel-scroll {
        overflow: auto;
    }

    .direct-chat-app .direct-card {
        border-radius: 18px;
        padding: 14px;
    }

    .direct-chat-app .direct-file-card .direct-section-head,
    .direct-chat-app .direct-connect-card .direct-section-head {
        align-items: center;
    }

    .direct-chat-app .direct-transfer-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .direct-chat-app .direct-tabbar {
        min-height: 62px;
        border-radius: 20px;
        padding: 5px;
    }

    .direct-chat-app .direct-tabbar button {
        min-height: 50px;
        border-radius: 16px;
        font-size: 0.76rem;
    }

    .direct-chat-app .direct-contact-rule {
        grid-template-columns: 20px minmax(0, 1fr);
    }

    .direct-chat-app .direct-contact-limit {
        grid-column: 2;
        width: 100%;
        grid-template-columns: minmax(0, 1fr) 72px;
    }
}
