.dt-page {
    --dt-header-h: 73px;
    background: var(--tg-bg);
    min-height: 100dvh;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.dt-page::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        linear-gradient(90deg, rgba(36, 62, 101, 0.14) 1px, transparent 1px);
    background-size: 72px 72px;
    opacity: 0.14;
    z-index: 1;
}

.dt-main {
    width: min(1460px, 97vw);
    margin: 0 auto;
    padding: 0 0 14px 0;
    display: grid;
    grid-template-columns: minmax(0, 2.2fr) minmax(340px, 1fr);
    gap: 14px;
    flex: 1 1 0;
    min-height: 0;
    box-sizing: border-box;
    position: relative;
    z-index: 2;
    align-content: stretch;
}

.dt-stage-wrap {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--tg-line);
    background: #f1f3f5;
    min-height: 0;
    box-sizing: border-box;
}

.dt-stage {
    width: 100%;
    height: 100%;
    min-height: 0;
    background: #f1f3f5;
}

.dt-stage canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

.dt-chat {
    margin: 0;
    border: 1px solid var(--tg-line);
    background: rgba(244, 247, 252, 0.95);
    backdrop-filter: blur(4px);
    padding: 12px;
    color: #1f2a37;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    box-sizing: border-box;
}

.dt-chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.dt-chat-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(100, 122, 156, 0.35);
    flex-shrink: 0;
}

.dt-chat-header h2 {
    margin: 0;
    font-size: 1.05rem;
    color: #101826;
}

.dt-chat-subtitle {
    font-size: 0.78rem;
    color: #64748b;
}

.dt-chat-log {
    flex: 1 1 auto;
    min-height: 220px;
    overflow-y: auto;
    display: grid;
    align-content: start;
    gap: 8px;
    margin-bottom: 10px;
    padding-right: 4px;
    border-radius: 10px;
    background: rgba(221, 228, 237, 0.9);
    padding: 10px;
}

.dt-msg {
    max-width: 92%;
    padding: 11px 12px;
    border-radius: 12px;
    line-height: 1.35;
    border: 1px solid rgba(80, 101, 132, 0.18);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.dt-msg-user {
    margin-left: auto;
    background: rgba(31, 90, 212, 0.88);
    color: #ffffff;
}

.dt-msg-bot {
    background: rgba(255, 255, 255, 0.94);
    color: #0f2135;
}

.dt-chat-form {
    display: flex;
    gap: 8px;
}

.dt-chat-form input {
    flex: 1;
    min-width: 0;
    border-radius: 10px;
    border: 1px solid rgba(100, 122, 156, 0.45);
    background: #ffffff;
    color: #0f172a;
    padding: 10px;
}

.dt-chat-form button {
    border: 0;
    border-radius: 10px;
    padding: 0 14px;
    flex-shrink: 0;
    background: #1d4ed8;
    color: #fff;
    cursor: pointer;
}

@media (max-width: 1120px) {
    .dt-page {
        --dt-header-h: 66px;
    }

    .dt-main {
        grid-template-columns: 1fr;
        height: auto;
        min-height: 0;
        flex: 0 0 auto;
        align-content: start;
    }

    .dt-stage {
        min-height: 260px;
        height: clamp(260px, 48vh, 420px);
    }

    .dt-chat {
        min-height: 280px;
        height: auto;
    }
}

@media (min-width: 1121px) {
    .dt-main {
        margin: 50px auto;
        height: calc(100dvh - var(--dt-header-h) - 140px);
        min-height: 560px;
        grid-template-rows: minmax(0, 1fr);
    }

    .dt-stage-wrap,
    .dt-chat {
        height: 100%;
    }
}

@media (max-width: 768px) {
    .dt-page {
        --dt-header-h: auto;
        height: auto;
        overflow-x: hidden;
        overflow-y: auto;
    }

    .dt-main {
        width: min(1460px, calc(100vw - 16px));
        gap: 10px;
        padding-bottom: 12px;
        flex: 0 0 auto;
    }

    .dt-stage-wrap {
        aspect-ratio: 16 / 10;
        height: auto;
    }

    .dt-stage {
        height: 100%;
        min-height: 0;
    }

    .dt-chat {
        min-height: 280px;
        padding: 10px;
    }

    .dt-chat-avatar {
        width: 48px;
        height: 48px;
    }

    .dt-chat-log {
        min-height: 180px;
        margin-bottom: 8px;
    }

    .dt-msg {
        max-width: 95%;
    }

    .dt-chat-form input {
        padding: 9px 10px;
    }

    .dt-chat-form button {
        padding: 0 12px;
    }
}

@media (max-width: 480px) {
    .dt-stage-wrap {
        aspect-ratio: 16 / 11;
        height: auto;
    }

    .dt-stage {
        height: 100%;
        min-height: 0;
    }

    .dt-chat {
        min-height: 250px;
    }

    .dt-chat-log {
        min-height: 160px;
    }
}

.dt-page #webagent-widget {
    display: none !important;
}
