.page-client {
    overflow-x: hidden;
}

.client-shell {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: center;
    width: min(920px, 100%);
    min-height: 100vh;
    margin: 0 auto;
    padding: 28px;
    align-items: center;
}

.client-app {
    width: 100%;
    padding: 28px;
    min-height: min(860px, calc(100vh - 56px));
    display: flex;
}

.client-stage {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.client-stage--setup {
    max-width: 760px;
    margin: 0 auto;
    gap: 20px;
}

.client-stage--chat {
    gap: 18px;
}

.client-stage__header {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.client-stage__header--setup {
    gap: 10px;
}

.client-stage__header h2 {
    margin: 0;
    font-size: clamp(2rem, 4vw, 2.55rem);
    letter-spacing: -0.05em;
    line-height: 1.02;
}

.client-stage__header--setup h2 {
    font-size: 1.85rem;
    letter-spacing: -0.04em;
    line-height: 1.08;
}

.client-stage__header p {
    margin: 0;
    color: var(--text-body);
    font-size: 1rem;
    line-height: 1.7;
}

.stage-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.mode-switch {
    display: inline-grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    width: min(360px, 100%);
    padding: 6px;
    background: linear-gradient(135deg, rgba(177, 78, 165, 0.12), rgba(76, 73, 171, 0.12));
    border-radius: 20px;
    border: 1px solid rgba(92, 73, 170, 0.12);
}

.client-stage--setup .mode-switch {
    width: auto;
    background: rgba(92, 73, 170, 0.08);
}

.mode-switch__button {
    border: none;
    border-radius: 16px;
    min-height: 48px;
    background: transparent;
    color: var(--text-muted);
    font-weight: 800;
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.mode-switch__button.is-active {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(250, 247, 255, 0.96));
    color: var(--brand-strong);
    box-shadow: 0 12px 24px -18px rgba(60, 49, 125, 0.38);
}

.mode-switch__button:hover {
    transform: translateY(-1px);
}

.expectation-card {
    padding: 20px 22px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 247, 247, 0.96));
}

.client-stage--setup .expectation-card {
    padding: 18px 20px;
    gap: 10px;
}

.expectation-card strong {
    font-size: 1rem;
}

.chat-stage__hero {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(260px, 0.7fr);
    gap: 18px;
    padding: 22px;
    background:
        radial-gradient(circle at top right, rgba(177, 78, 165, 0.14), transparent 38%),
        radial-gradient(circle at bottom left, rgba(76, 73, 171, 0.16), transparent 32%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 247, 247, 0.96));
}

.chat-stage__hero-main {
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-width: 0;
}

.chat-stage__identity {
    display: flex;
    align-items: flex-start;
    gap: 18px;
}

.chat-stage__title-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.chat-stage__title-group h2 {
    margin: 0;
    font-size: clamp(1.8rem, 3.4vw, 2.4rem);
    line-height: 1.02;
    letter-spacing: -0.05em;
}

.chat-stage__title-group p {
    margin: 0;
    color: var(--text-body);
    line-height: 1.65;
}

.chat-stage__hero-note {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 16px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(92, 73, 170, 0.12);
}

.chat-stage__hero-note p {
    margin: 0;
    color: var(--text-body);
    line-height: 1.6;
}

.chat-stage__tag-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chat-stage__hero-side {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    gap: 12px;
}

.hero-status-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 16px;
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(247, 247, 247, 0.92));
    border: 1px solid rgba(92, 73, 170, 0.12);
    box-shadow: 0 18px 26px -24px rgba(60, 49, 125, 0.24);
}

.hero-status-card__label {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hero-status-card--protocol {
    justify-content: center;
}

.session-pill {
    flex-shrink: 0;
    width: 100%;
    padding: 12px 14px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(157, 79, 165, 0.12), rgba(61, 70, 166, 0.12));
    border: 1px solid rgba(92, 73, 170, 0.14);
    color: var(--brand-strong);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.03em;
}

.presence-pill {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(92, 73, 170, 0.12);
    color: var(--text-body);
    font-size: 12px;
    font-weight: 700;
}

.presence-pill--soft {
    width: fit-content;
    background: rgba(255, 255, 255, 0.94);
}

.presence-pill__dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--action-blue));
    box-shadow: 0 0 0 6px rgba(177, 78, 165, 0.12);
}

.chat-stage__insights {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.insight-card {
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 247, 247, 0.96));
}

.insight-card__label {
    color: var(--brand-strong);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.insight-card p {
    margin: 0;
    color: var(--text-body);
    line-height: 1.65;
}

.chat-stage__conversation {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px;
    min-height: 480px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.99), rgba(247, 247, 247, 0.97));
}

.conversation-guide {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px 18px;
    border-radius: 22px;
    background: linear-gradient(135deg, rgba(177, 78, 165, 0.1), rgba(76, 73, 171, 0.1));
    border: 1px solid rgba(92, 73, 170, 0.12);
}

.conversation-guide strong,
.conversation-guide p {
    margin: 0;
}

.conversation-guide p {
    color: var(--text-body);
    line-height: 1.65;
}

.message-stream {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 280px;
    padding: 8px 6px 8px 2px;
    overflow-y: auto;
}

.page-client .message {
    max-width: min(82%, 560px);
    padding: 16px 18px;
    border-radius: 24px;
    box-shadow: 0 18px 28px -24px rgba(60, 49, 125, 0.32);
}

.page-client .message--incoming {
    background: rgba(255, 255, 255, 0.98);
}

.page-client .message--outgoing {
    background: linear-gradient(135deg, var(--accent) 0%, var(--action-blue) 100%);
}

.page-client .message__meta {
    width: 100%;
    justify-content: space-between;
}

.message__time {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 700;
    opacity: 0.78;
}

.page-client .event-note {
    padding: 12px 16px;
    border: 1px solid rgba(92, 73, 170, 0.12);
    background: rgba(92, 73, 170, 0.08);
}

.chat-composer {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-top: 6px;
    border-top: 1px solid rgba(92, 73, 170, 0.14);
}

.chat-composer__controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: end;
}

.textarea-control--chat {
    min-height: 64px;
    border-radius: 22px;
    padding: 18px 18px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 247, 247, 0.98));
}

.chat-composer__meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
}

@media (max-width: 1080px) {
    .client-shell {
        padding-top: 18px;
        padding-bottom: 18px;
    }

    .client-app {
        min-height: auto;
    }
}

@media (max-width: 860px) {
    .chat-stage__insights {
        grid-template-columns: 1fr;
    }

    .chat-stage__hero {
        grid-template-columns: 1fr;
    }

    .chat-stage__hero-side {
        align-items: stretch;
    }
}

@media (max-width: 640px) {
    .client-shell {
        padding: 12px;
        gap: 16px;
    }

    .client-app {
        padding: 18px;
        min-height: calc(100vh - 24px);
    }

    .chat-stage__identity {
        flex-direction: column;
        align-items: flex-start;
    }

    .chat-stage__hero {
        padding: 18px;
    }

    .session-pill {
        width: 100%;
    }

    .chat-composer__controls,
    .chat-composer__meta {
        grid-template-columns: 1fr;
        display: grid;
    }

    .chat-composer__meta {
        gap: 6px;
    }

    .button-icon {
        width: 100%;
    }
}
