.chat-screen {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.chat-app {
    display: flex;
    flex: 1;
    min-height: 0;
    height: calc(100vh - 3.5rem);
    background: hsl(var(--bg));
}

.chat-list {
    display: flex;
    flex-direction: column;
    width: 100%;
    background: hsl(var(--card));
    border-inline-end: 1px solid hsl(var(--line));
}

.chat-list-head {
    padding: 1rem;
    border-bottom: 1px solid hsl(var(--line));
}

.chat-list-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.chat-list-title h1 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 700;
}

.chat-list-title .glyph {
    color: hsl(var(--p));
    font-size: 1.125rem;
}

.auth-page a.chat-new {
    padding: 0.375rem 0.75rem;
    border-radius: 0.5rem;
    background: hsl(var(--p));
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
}

.auth-page a.chat-new:hover {
    color: white;
    opacity: 0.9;
}

.chat-search {
    position: relative;
}

.chat-search .glyph {
    position: absolute;
    inset-inline-end: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: hsl(var(--muted));
    font-size: 0.875rem;
    pointer-events: none;
}

.chat-search input,
.chat-compose input,
.chat-dialog input {
    width: 100%;
    height: 2.25rem;
    border: 1px solid hsl(var(--line));
    border-radius: 0.5rem;
    background: hsl(var(--bg));
    font-size: 0.75rem;
}

.chat-search input {
    padding-inline: 0.75rem 2.25rem;
}

.chat-rows {
    flex: 1;
    overflow: auto;
}

.chat-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem;
    border: 0;
    border-bottom: 1px solid hsl(var(--line) / 0.5);
    border-inline-start: 2px solid transparent;
    background: transparent;
    color: inherit;
    text-align: start;
}

.chat-row:hover {
    background: hsl(var(--accent) / 0.5);
}

.chat-row.is-on {
    background: hsl(var(--p) / 0.05);
    border-inline-start-color: hsl(var(--p));
}

.chat-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    flex: none;
    border-radius: 999px;
    background: hsl(var(--accent));
    color: hsl(var(--muted));
}

.chat-avatar.small {
    width: 2.25rem;
    height: 2.25rem;
}

.chat-row-body,
.chat-person-body {
    flex: 1;
    min-width: 0;
}

.chat-row-top,
.chat-row-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.chat-row-top strong,
.chat-person-body strong {
    overflow: hidden;
    font-size: 0.875rem;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-when {
    flex: none;
    color: hsl(var(--muted));
    font-size: 10px;
}

.chat-row-bottom {
    margin-top: 0.125rem;
}

.chat-preview,
.chat-person-body span,
.chat-empty p,
.chat-sub {
    color: hsl(var(--muted));
    font-size: 0.75rem;
}

.chat-preview {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-unread {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    flex: none;
    border-radius: 999px;
    background: hsl(var(--p));
    color: white;
    font-size: 10px;
    font-weight: 700;
}

.chat-empty {
    padding: 4rem 1rem;
    text-align: center;
}

.chat-empty .glyph,
.chat-blank .glyph {
    color: hsl(var(--muted) / 0.35);
    font-size: 2.5rem;
}

.chat-empty strong,
.chat-blank strong {
    display: block;
    margin-top: 0.75rem;
    font-size: 0.875rem;
}

.chat-pane {
    display: none;
    flex: 1;
    flex-direction: column;
    min-width: 0;
    background: hsl(var(--bg));
}

.chat-app.is-open .chat-pane {
    display: flex;
}

.chat-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-bottom: 1px solid hsl(var(--line));
    background: hsl(var(--card));
}

.chat-back {
    display: inline-flex;
    padding: 0.375rem;
    border-radius: 0.5rem;
    color: hsl(var(--muted));
}

.chat-back:hover {
    background: hsl(var(--accent));
}

[dir="ltr"] .chat-back .glyph {
    transform: scaleX(-1);
}

.chat-head strong {
    display: block;
    font-size: 0.875rem;
}

.chat-head span,
.chat-time {
    color: hsl(var(--muted));
    font-size: 10px;
}

.chat-log {
    flex: 1;
    overflow: auto;
    padding: 1rem;
}

.chat-bubble-row {
    display: flex;
    margin-bottom: 0.75rem;
}

.chat-bubble-row.mine {
    justify-content: flex-start;
}

.chat-bubble-row.theirs {
    justify-content: flex-end;
}

.chat-bubble {
    max-width: 75%;
    padding: 0.625rem 1rem;
    border-radius: 1rem;
    font-size: 0.875rem;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.chat-bubble p {
    margin: 0;
}

.mine .chat-bubble {
    background: hsl(var(--p));
    color: white;
    border-end-start-radius: 0.375rem;
}

.theirs .chat-bubble {
    background: hsl(var(--accent));
    color: hsl(var(--fg));
    border-end-end-radius: 0.375rem;
}

.chat-meta {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.25rem;
}

.mine .chat-meta {
    color: hsl(0 0% 100% / 0.65);
}

.chat-meta .glyph {
    font-size: 0.75rem;
}

.chat-compose {
    padding: 0.75rem;
    border-top: 1px solid hsl(var(--line));
    background: hsl(var(--card));
}

.chat-compose form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-compose input {
    flex: 1;
    width: auto;
    height: 2.5rem;
    padding-inline: 0.75rem;
    font-size: 0.875rem;
}

.chat-send {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    flex: none;
    border: 0;
    border-radius: 0.75rem;
    background: hsl(var(--p));
    color: white;
    cursor: pointer;
}

.chat-send:hover {
    opacity: 0.9;
}

.chat-blank {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1.5rem;
}

.chat-notice {
    margin: 0.75rem 1rem 0;
    padding: 0.625rem 0.75rem;
    border-radius: 0.5rem;
    background: hsl(var(--accent));
    color: hsl(var(--fg));
    font-size: 0.75rem;
}

.chat-modal {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: hsl(var(--fg) / 0.4);
}

.chat-dialog {
    display: flex;
    flex-direction: column;
    width: min(28rem, 100%);
    max-height: 70vh;
    overflow: hidden;
    border: 1px solid hsl(var(--line));
    border-radius: 1rem;
    background: hsl(var(--card));
}

.chat-dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid hsl(var(--line));
}

.chat-dialog-head h2 {
    font-size: 0.875rem;
}

.chat-close {
    color: hsl(var(--muted));
    font-size: 1.5rem;
    line-height: 1;
}

.chat-dialog form,
.chat-person {
    padding: 0.75rem;
}

.chat-person {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    border: 0;
    background: transparent;
    color: inherit;
    text-align: start;
    cursor: pointer;
}

.chat-person:hover {
    background: hsl(var(--accent) / 0.5);
}

.chat-people {
    overflow: auto;
}

.chat-none {
    padding: 2rem 1rem;
    text-align: center;
    color: hsl(var(--muted));
    font-size: 0.875rem;
}

@media (min-width: 768px) {
    .chat-list {
        width: 20rem;
    }

    .chat-pane {
        display: flex;
    }

    .chat-back {
        display: none;
    }
}

@media (min-width: 1024px) {
    .chat-list {
        width: 24rem;
    }
}

@media (max-width: 767px) {
    .chat-app.is-open .chat-list {
        display: none;
    }
}
