:root {
    --input-height: 80px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f9f9f9;
}

#chatlog {
    position: fixed;
    top: 0;
    bottom: var(--input-height);
    left: 0;
    width: calc(100% - 200px);
    overflow-y: auto;
    padding: 8px;
    overflow-wrap: break-word;
    background-color: #fff;
    scroll-behavior: smooth;
}

#chatlog span.username {
    font-weight: bold;
}

#chatlog span.username.clickable:hover {
    text-decoration: underline;
}

#roster {
    position: fixed;
    right: 0;
    top: 0;
    bottom: var(--input-height);
    width: 200px;
    border-left: 1px solid #eee;
    display: flex;
    flex-direction: column;
    background-color: #fafafa;
}

#roster-users {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    font-size: 0.95em;
}

.roster-user {
    margin: 4px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.unread-badge {
    background-color: #ff4444;
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 0.75em;
    font-weight: bold;
}

#chatlog img {
    max-width: 50%;
    height: auto;
    vertical-align: middle;
}

::-webkit-scrollbar {
    display: none;
}

@media(max-width:600px) {
    #roster {
        display: none;
    }

    #chatlog,
    #chat-input-container,
    #unread-alert {
        width: 100% !important;
    }
}

#chat-input-container {
    position: fixed;
    width: calc(100% - 200px);
    bottom: 0;
    left: 0;
    background-color: #fff;
    border-top: 1px solid #ccc;
    display: flex;
    align-items: stretch;
    z-index: 3;
}

#chat-input {
    flex: 1;
    height: 80px;
    min-height: 80px;
    max-height: 50vh;
    resize: vertical;
    border: none;
    padding: 12px 12px 12px 32px;
    outline: none;
    font-family: inherit;
    font-size: 1rem;
    box-sizing: border-box;
}

#chat-input-container::before {
    z-index: 4;
    display: block;
    content: ">";
    position: absolute;
    top: 24px;
    transform: translateY(-50%);
    left: 0;
    width: 32px;
    height: 32px;
    line-height: 32px;
    text-align: center;
    font-weight: bold;
    color: #888;
    pointer-events: none;
}

.center-form-container {
    position: fixed;
    z-index: 5;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.center-form-container input,
.center-form-container button {
    font-size: 1.2rem;
    margin: 8px 0;
    text-align: center;
    border: 1px solid #bbb;
    border-radius: 4px;
    width: 16em;
    max-width: 90vw;
    height: 2.5em;
}

.center-form-container button {
    background-color: #007bff;
    color: #fff;
    cursor: pointer;
    border: none;
}

.center-form-container button:hover {
    background-color: #0056b3;
}

.center-form-container h2 {
    margin-bottom: 20px;
    color: #333;
}

.system-text {
    font-style: italic;
    color: #666;
}

.mention {
    background-color: #ffeb3b;
    padding: 2px 4px;
    border-radius: 4px;
    font-weight: bold;
    color: #000;
}

.msg-item {
    margin-bottom: 8px;
    line-height: 1.5;
    padding: 4px;
    border-radius: 4px;
}

#live-preview {
    opacity: 0.5;
    display: none;
    margin-bottom: 8px;
}

#editing-indicator {
    position: fixed;
    bottom: var(--input-height);
    left: 0;
    width: 100%;
    background: #ffeb3b;
    font-size: 0.8em;
    padding: 4px 8px;
    display: none;
    z-index: 4;
    font-weight: bold;
}

#unread-alert {
    position: fixed;
    bottom: calc(var(--input-height) + 10px);
    right: 220px;
    background-color: #007bff;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9em;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    display: none;
    z-index: 10;
}

@media(max-width:600px) {
    #unread-alert {
        right: 20px;
    }
}

#connection-status {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: #ff9800;
    color: white;
    text-align: center;
    padding: 6px;
    font-size: 0.9em;
    z-index: 1000;
    display: none;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

#typing-indicator {
    position: fixed;
    bottom: var(--input-height);
    left: 0;
    width: calc(100% - 200px);
    padding: 2px 8px;
    font-size: 0.85em;
    color: #666;
    background-color: transparent;
    display: none;
    z-index: 4;
    font-style: italic;
    pointer-events: none;
}

@media(max-width:600px) {
    #typing-indicator {
        width: 100%;
    }
}

.content p {
    display: inline;
    margin: 0;
    padding: 0;
}

.content blockquote {
    display: block;
    border-left: 4px solid #007bff;
    margin: 6px 0 6px 0;
    padding: 4px 8px;
    color: #555;
    background: #f1f1f1;
    border-radius: 0 4px 4px 0;
    font-size: 0.95em;
}

.content pre {
    display: block;
    background-color: #f6f8fa;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 0.9em;
    border: 1px solid #e1e4e8;
}

.content code {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
    background-color: #f6f8fa;
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 0.9em;
    color: #24292e;
}

.content pre code {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
    color: inherit;
}

.content a[href^="#msg_"] {
    display: block;
    background: #f1f5f9;
    color: #64748b;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85em;
    text-decoration: none;
    margin-bottom: 6px;
    border-left: 3px solid #94a3b8;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    user-select: none;
}

.content a[href^="#msg_"]:hover {
    background: #e2e8f0;
    color: #475569;
}

.heart-particle {
    position: fixed;
    bottom: 0;
    font-size: 2rem;
    user-select: none;
    pointer-events: none;
    z-index: 9999;
    animation: float-up 3s ease-out forwards;
}

@keyframes float-up {
    0% {
        transform: translateY(0) scale(0.5);
        opacity: 1;
    }

    50% {
        opacity: 1;
    }

    100% {
        transform: translateY(-100vh) scale(1.5);
        opacity: 0;
    }
}
