.kkp-card,
.kkp-chat {
    box-sizing: border-box;
    max-width: 920px;
    margin: 1.5rem auto;
    border: 1px solid #d8dde3;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 2px 10px rgba(22, 31, 42, 0.08);
}

.kkp-card {
    padding: 1.5rem;
}

.kkp-login {
    display: grid;
    max-width: 480px;
    gap: 1rem;
}

.kkp-login label:not(.kkp-login__remember) {
    display: grid;
    gap: 0.35rem;
    font-weight: 600;
}

.kkp-login input[type="email"],
.kkp-login input[type="password"],
.kkp-chat textarea {
    box-sizing: border-box;
    width: 100%;
    border: 1px solid #aab4bf;
    border-radius: 4px;
    padding: 0.75rem;
    font: inherit;
}

.kkp-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border: 0;
    border-radius: 4px;
    padding: 0.7rem 1.25rem;
    background: #17365d;
    color: #fff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.kkp-button:hover,
.kkp-button:focus {
    background: #0f2848;
    color: #fff;
}

.kkp-button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.kkp-notice {
    margin: 1rem 0;
    border-left: 4px solid #59738f;
    padding: 0.75rem 1rem;
    background: #eef3f7;
}

.kkp-notice--error {
    border-color: #b32d2e;
    background: #fbeaea;
}

.kkp-notice--success {
    border-color: #00844a;
    background: #e9f6ef;
}

.kkp-terms__content {
    max-height: 420px;
    overflow: auto;
    margin-bottom: 1.25rem;
    border: 1px solid #d8dde3;
    padding: 1rem;
    background: #f8fafb;
}

.kkp-terms__form {
    display: grid;
    gap: 1rem;
}

.kkp-terms__form .kkp-button {
    justify-self: start;
}

.kkp-chat__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 8px 8px 0 0;
    border-bottom: 1px solid #d8dde3;
    padding: 0.8rem 1rem;
    background: #fff;
    color: #1c2733;
    gap: 1rem;
}

.kkp-chat__title {
    font-weight: 700;
}

.kkp-chat__logout {
    flex: 0 0 auto;
    color: #17365d;
    font-weight: 700;
}

.kkp-chat__logout:hover,
.kkp-chat__logout:focus {
    color: #17365d;
}

.kkp-chat__messages {
    box-sizing: border-box;
    display: flex;
    height: clamp(320px, calc(100vh - 34rem), 1400px);
    height: clamp(320px, calc(100dvh - 34rem), 1400px);
    min-height: 320px;
    flex-direction: column;
    gap: 0.85rem;
    overflow-y: auto;
    scrollbar-gutter: stable;
    padding: 1.25rem;
    background: #f6f8fa;
}

.kkp-message {
    max-width: 82%;
    border-radius: 8px;
    padding: 0.8rem 1rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.kkp-message--assistant {
    align-self: flex-start;
    background: #fff;
    color: #1c2733;
}

.kkp-message--user {
    align-self: flex-end;
    background: #17365d;
    color: #fff;
}

.kkp-message--status {
    align-self: flex-start;
    color: #52606d;
    font-style: italic;
}

.kkp-message--error {
    align-self: flex-start;
    background: #fbeaea;
    color: #8b1e1e;
}

.kkp-chat__form {
    display: grid;
    gap: 0.75rem;
    border-top: 1px solid #d8dde3;
    padding: 1rem;
    background: #fff;
}

.kkp-chat__key-diagnostic {
    margin: 0;
    color: #687482;
    font-family: monospace;
    font-size: 0.78rem;
}

.kkp-chat__form .kkp-button {
    justify-self: end;
}

.kkp-chat__disclaimer {
    position: sticky;
    z-index: 1;
    bottom: 0;
    margin: 0;
    border-top: 1px solid #d8dde3;
    border-radius: 0 0 8px 8px;
    padding: 0.65rem 1rem;
    background: #fff;
    color: #687482;
    font-size: 0.78rem;
    line-height: 1.45;
}

.kkp-chat__disclaimer a {
    color: #52606d;
    text-decoration: underline;
}

@media (max-width: 700px) {
    .kkp-chat__header {
        align-items: flex-start;
        flex-direction: column;
    }

    .kkp-message {
        max-width: 95%;
    }

    .kkp-card,
    .kkp-chat {
        border-radius: 0;
    }
}
