* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
}

body {
    font-family: Arial, sans-serif;
    background: #fff;
    overflow: hidden;
}

button,
textarea,
input {
    font: inherit;
}

/*
 * Isle is a three-part viewport: the header and composer never scroll;
 * only the message viewport does.
 */
.chat-app {
    width: 100%;
    height: 100dvh;
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
}

.chat-header {
    padding: 12px 16px 10px;
    border-bottom: 1px solid #999;
    background: #fff;
}

.chat-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.chat-header h1 {
    margin: 0;
    font-size: 28px;
    line-height: 1.15;
}

.isle-brand {
    display: flex;
    align-items: center;
    gap: 7px;
}

.diya-icon {
    display: block;
    width: 38px;
    height: 38px;
    object-fit: contain;
}

.login-brand {
    margin: 8px 0 16px;
}

.login-brand h1 {
    margin: 0;
}

.diwali-greeting {
    margin: 8px 0 0;
    color: #a65b00;
    font-weight: bold;
}

.chat-header-top a {
    color: inherit;
    font-size: 16px;
}

.chat-header-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
}

.clear-conversation-link {
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    font-size: 14px;
    text-decoration: underline;
    cursor: pointer;
}

.chat-header-info {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 24px;
    margin-top: 10px;
    font-size: 15px;
    line-height: 1.4;
}

/* This is the only scrolling region in the application. */
.chat-messages {
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    border-bottom: 0;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.empty-chat {
    margin: 0;
}

.message {
    margin-bottom: 15px;
    padding: 8px;
    max-width: 500px;
}

.message-mine {
    margin-left: auto;
}

.message-theirs {
    margin-right: auto;
}

.message-sender {
    font-weight: bold;
}

.message-text {
    margin-top: 4px;
    overflow-wrap: anywhere;
}

.message-time {
    color: #666;
    font-size: 11px;
    line-height: 1.35;
    margin-top: 4px;
}

.message form {
    margin-top: 6px;
}

.message button {
    padding: 4px 8px;
}

.message-attachment {
    margin-top: 8px;
}

.chat-image {
    display: block;
    max-width: min(400px, 100%);
    max-height: 400px;
    width: auto;
    height: auto;
}

.chat-video {
    display: block;
    max-width: 500px;
    width: 100%;
    height: auto;
}

/*
 * Composer is the bottom, non-scrolling part of the viewport.
 */
.chat-composer {
    min-width: 0;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid #999;
    background: #fff;
}

.message-form {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.message-form textarea {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    max-width: none;
    min-height: 42px;
    max-height: 120px;
    padding: 8px;
    resize: vertical;
}

.message-form button,
.file-form button {
    padding: 6px 12px;
    white-space: nowrap;
}

.file-form {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.file-label {
    display: inline-block;
    padding: 6px 12px;
    border: 1px solid #767676;
    border-radius: 2px;
    background: #efefef;
    cursor: pointer;
    white-space: nowrap;
}

.file-name {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 600px) {
    .chat-header {
        padding: 10px 12px 8px;
    }

    .chat-header h1 {
        font-size: 24px;
    }

    .chat-header-info {
        display: block;
        margin-top: 7px;
    }

    .chat-header-info span {
        display: block;
    }

    .chat-header-info span + span {
        margin-top: 2px;
    }

    .chat-messages {
        padding: 12px;
        border-left: 0;
        border-right: 0;
    }

    .chat-composer {
        padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
    }

    .message {
        max-width: 90%;
    }

    .message-form textarea {
        min-height: 40px;
    }

    .file-form {
        gap: 6px;
    }

    .file-label,
    .file-form button {
        flex: 0 0 auto;
    }

    .file-name {
        font-size: 13px;
    }
}
