* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    padding: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: Arial, sans-serif;
    background: #f5f5f5;
}

.chat {
    width: min(600px, 100%);
    height: min(720px, calc(100vh - 32px));
    display: flex;
    flex-direction: column;
    background: white;
    border: 1px solid #ccc;
    border-radius: 10px;
    overflow: hidden;
}

#messages {
    flex: 1;
    min-height: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    background: white;
}

.message {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 12px;
    overflow-wrap: anywhere;
}

.message .name {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    color: #666;
}

.message p {
    margin: 0;
    font-size: 16px;
    white-space: pre-wrap;
}

.other {
    align-self: flex-start;
    background: #eee;
}

.self {
    align-self: flex-end;
    background: #95d5ff;
}

.self .name {
    text-align: right;
}

.system {
    align-self: center;
    color: #888;
    font-size: 14px;
}

#chatForm {
    display: flex;
    gap: 10px;
    padding: 12px;
    border-top: 1px solid #ddd;
    background: white;
}

#message {
    flex: 1;
    min-width: 0;
    padding: 11px 12px;
    font-size: 16px;
    border: 1px solid #ccc;
    border-radius: 6px;
    outline: none;
}

#message:focus {
    border-color: #409eff;
}

#sendButton {
    padding: 0 20px;
    color: white;
    font-size: 16px;
    background: #409eff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

#sendButton:disabled,
#message:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}
