* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Arial, Helvetica, sans-serif;
    color: #18202a;
    background: #eef2f5;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: min(380px, 100%);
    display: grid;
    gap: 12px;
    padding: 24px;
    background: #ffffff;
    border: 1px solid #d8e0e7;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(24, 32, 42, 0.08);
}

.login-card h1 {
    margin-bottom: 8px;
}

.login-card label {
    font-size: 13px;
    font-weight: 700;
}

.password-row {
    display: flex;
    gap: 8px;
}

.password-toggle {
    width: 44px;
    min-width: 44px;
    display: grid;
    place-items: center;
    padding: 0;
}

.password-toggle svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.password-toggle .icon-eye-off,
.password-toggle.is-visible .icon-eye {
    display: none;
}

.password-toggle.is-visible .icon-eye-off {
    display: block;
}

.login-error {
    color: #b42318;
    font-size: 14px;
}

.chat-shell {
    width: min(980px, calc(100% - 24px));
    min-height: calc(100vh - 24px);
    margin: 12px auto;
    display: grid;
    grid-template-rows: auto 1fr auto;
    background: #ffffff;
    border: 1px solid #d8e0e7;
    border-radius: 8px;
    overflow: hidden;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px;
    background: #ffffff;
    border-bottom: 1px solid #d8e0e7;
}

h1 {
    margin: 0 0 4px;
    font-size: 24px;
}

p {
    margin: 0;
}

.topbar p,
.file-name,
.meta {
    color: #66717f;
}

.name-form {
    display: grid;
    gap: 6px;
    min-width: 280px;
}

.name-form label {
    font-size: 13px;
    font-weight: 700;
}
.logout-form {
    align-self: end;
}

.logout-form button {
    min-height: 40px;
    background: #66717f;
}

.logout-form button:hover {
    background: #4f5965;
}

.name-row,
.compose-row {
    display: flex;
    gap: 8px;
}

input,
textarea,
select,
button,
.file-button {
    font: inherit;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid #ccd6df;
    border-radius: 6px;
    padding: 10px 12px;
    color: #18202a;
    background: #ffffff;
}

textarea {
    resize: none;
}

.delay-select {
    width: 110px;
    min-width: 110px;
}

button,
.file-button {
    border: 0;
    border-radius: 6px;
    padding: 10px 14px;
    color: #ffffff;
    background: #245d7a;
    cursor: pointer;
    white-space: nowrap;
}

button:hover,
.file-button:hover {
    background: #1d4b63;
}

.chat-status {
    margin: 12px 18px 0;
    padding: 10px 12px;
    border-radius: 6px;
    color: #245d7a;
    background: #edf7f1;
    border: 1px solid #badfce;
    font-size: 14px;
}

.chat-status.error {
    color: #912018;
    background: #fff1f0;
    border-color: #f0b8b2;
}

.history-controls {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px 0;
    background: #f7f9fb;
}

.history-controls button {
    padding: 7px 12px;
    color: #245d7a;
    background: #ffffff;
    border: 1px solid #9bc2d3;
    font-size: 13px;
}

.history-controls button:hover {
    color: #ffffff;
    background: #245d7a;
}
.messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 18px;
    overflow-y: auto;
    background: #f7f9fb;
}

.empty {
    margin: auto;
    color: #66717f;
}

.message {
    width: fit-content;
    max-width: min(680px, 88%);
    padding: 12px;
    border-radius: 8px;
    background: #ffffff;
    border: 1px solid #dce4eb;
    box-shadow: 0 1px 2px rgba(24, 32, 42, 0.04);
}

.message.mine {
    align-self: flex-end;
    background: #e5f3ed;
    border-color: #badfce;
}

.message p {
    margin-top: 6px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.45;
}
.message-text a,
.reply-quote a {
    color: #1b6f9f;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.message-text a:hover,
.reply-quote a:hover {
    color: #124c6d;
}

.reply-quote,
.reply-preview {
    display: flex;
    gap: 8px;
    border-left: 3px solid #245d7a;
    background: rgba(36, 93, 122, 0.08);
}

.reply-quote {
    flex-direction: column;
    margin-top: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}

.reply-quote:hover {
    background: rgba(36, 93, 122, 0.14);
}

.reply-quote span,
.reply-preview span {
    overflow-wrap: anywhere;
}

.message-highlight {
    outline: 3px solid #f5b942;
    outline-offset: 2px;
}

.message img,
.message-external {
    display: block;
    max-width: min(420px, 100%);
    max-height: 320px;
    margin-top: 8px;
    border-radius: 6px;
    object-fit: contain;
}

.message-external {
    min-width: 180px;
    background: transparent;
}
.video-player {
    display: grid;
    gap: 6px;
    width: min(420px, 100%);
    margin-top: 8px;
}

.video-player video {
    display: block;
    width: 100%;
    max-height: 320px;
    border-radius: 6px;
    background: #0f1720;
    object-fit: contain;
}

.video-buffer {
    height: 7px;
    overflow: hidden;
    border-radius: 999px;
    background: #dfe8ef;
}

.video-buffer span {
    display: block;
    width: 0;
    height: 100%;
    background: #2d8f6f;
    transition: width 180ms ease;
}

.video-status {
    color: #66717f;
    font-size: 12px;
}

.video-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.video-actions button,
.video-actions a {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    text-decoration: none;
}

.video-actions button {
    color: #ffffff;
    background: #245d7a;
}

.video-actions a {
    color: #245d7a;
    background: rgba(36, 93, 122, 0.08);
    border: 1px solid #9bc2d3;
}

.video-actions a:hover {
    background: rgba(36, 93, 122, 0.14);
}
.youtube-preview {
    display: grid;
    gap: 8px;
    width: min(420px, 100%);
    margin-top: 8px;
}

.youtube-thumb {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: #0f1720;
    cursor: pointer;
}

.youtube-thumb img {
    width: 100%;
    height: 100%;
    margin: 0;
    max-width: none;
    max-height: none;
    border-radius: 0;
    object-fit: cover;
}

.youtube-play {
    position: absolute;
    inset: 50% auto auto 50%;
    transform: translate(-50%, -50%);
    display: grid;
    place-items: center;
    width: 58px;
    height: 40px;
    padding-left: 3px;
    color: #ffffff;
    background: rgba(220, 0, 0, 0.9);
    border-radius: 12px;
    font-size: 20px;
    line-height: 1;
}

.youtube-preview iframe {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 0;
    border-radius: 6px;
    background: #0f1720;
}

.youtube-actions a {
    display: inline-flex;
    align-items: center;
    justify-self: start;
    min-height: 30px;
    padding: 6px 10px;
    color: #245d7a;
    background: rgba(36, 93, 122, 0.08);
    border: 1px solid #9bc2d3;
    border-radius: 6px;
    font-size: 12px;
    text-decoration: none;
}

.youtube-actions a:hover {
    background: rgba(36, 93, 122, 0.14);
}
.anonmp4-preview {
    display: grid;
    gap: 8px;
    width: min(420px, 100%);
    margin-top: 8px;
}

.anonmp4-preview iframe {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 0;
    border-radius: 6px;
    background: #0f1720;
}

.anonmp4-status {
    color: #536b78;
    font-size: 12px;
}
.message-audio {
    display: block;
    width: min(100%, 360px);
    margin-top: 8px;
}

.attachment-preview audio {
    width: 100%;
    margin-top: 8px;
}

.message-file {
    display: block;
    max-width: 100%;
    margin-top: 8px;
    padding: 10px 12px;
    color: #245d7a;
    background: rgba(36, 93, 122, 0.08);
    border: 1px solid #9bc2d3;
    border-radius: 6px;
    overflow-wrap: anywhere;
    text-decoration: none;
}

.message-file:hover {
    background: rgba(36, 93, 122, 0.14);
}

.view-once-option {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    padding: 0 8px;
    color: #245d7a;
    font-size: 13px;
    white-space: nowrap;
}

.view-once-option input {
    width: auto;
    min-height: auto;
    accent-color: #245d7a;
}

.view-once-option:has(input:disabled) {
    opacity: 0.55;
}

.view-once-card {
    display: grid;
    gap: 6px;
    width: min(420px, 100%);
    margin-top: 8px;
    padding: 12px;
    color: #245d7a;
    background: rgba(36, 93, 122, 0.08);
    border: 1px solid #9bc2d3;
    border-radius: 6px;
}

.view-once-card span {
    color: #66717f;
    font-size: 13px;
}

.view-once-card button {
    justify-self: start;
    min-height: 32px;
    padding: 7px 12px;
    color: #ffffff;
    background: #245d7a;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
}

.view-once-card button:disabled {
    opacity: 0.7;
    cursor: wait;
}

.view-once-card img {
    margin-top: 0;
}
.view-once-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(15, 23, 32, 0.86);
}

.view-once-modal-content {
    display: grid;
    gap: 12px;
    justify-items: center;
    width: min(92vw, 760px);
    max-height: 92vh;
}

.view-once-modal-content img {
    display: block;
    max-width: 100%;
    max-height: 82vh;
    border-radius: 8px;
    object-fit: contain;
    background: #0f1720;
}

.view-once-modal-content button {
    min-height: 38px;
    padding: 8px 16px;
    color: #ffffff;
    background: #245d7a;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
}



.message-sticker,
.message-gif {
    display: grid;
    place-items: center;
    min-width: 140px;
    min-height: 96px;
    margin-top: 8px;
    padding: 14px;
    border-radius: 8px;
    text-align: center;
    font-weight: 700;
}

.message-sticker {
    color: #245d7a;
    background: #edf7f1;
    border: 1px solid #badfce;
}

.message-gif {
    color: #ffffff;
    background: linear-gradient(135deg, #245d7a, #2d8f6f);
    animation: gifGlow 900ms ease-in-out infinite alternate;
}

@keyframes gifGlow {
    from {
        filter: brightness(0.95);
        transform: scale(0.99);
    }

    to {
        filter: brightness(1.1);
        transform: scale(1.01);
    }
}

.message-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
}

.edit-message,
.cancel-edit {
    padding: 6px 10px;
    color: #245d7a;
    background: transparent;
    border: 1px solid #9bc2d3;
    font-size: 13px;
}

.edit-message:hover,
.cancel-edit:hover {
    color: #ffffff;
    background: #245d7a;
}

.meta {
    font-size: 12px;
    font-weight: 700;
}

#imageInput:disabled + button,
#imageInput:disabled {
    cursor: not-allowed;
}

.scheduled-panel {
    display: grid;
    gap: 8px;
    padding: 12px 18px;
    background: #fbfcfd;
    border-top: 1px solid #d8e0e7;
}

.scheduled-title {
    color: #18202a;
    font-size: 13px;
    font-weight: 700;
}

.scheduled-messages {
    display: grid;
    gap: 6px;
    color: #66717f;
    font-size: 13px;
}

.scheduled-item {
    display: grid;
    gap: 2px;
    padding: 8px 10px;
    border: 1px solid #d8e0e7;
    border-radius: 6px;
    background: #ffffff;
}

.scheduled-item span {
    overflow-wrap: anywhere;
}
.composer {
    display: grid;
    gap: 10px;
    padding: 14px;
    background: #ffffff;
    border-top: 1px solid #d8e0e7;
}

.reply-preview {
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: 6px;
}

.reply-preview-content {
    display: grid;
    gap: 2px;
    min-width: 0;
    font-size: 13px;
}

.cancel-reply,
.reply-picker {
    padding: 6px 10px;
    font-size: 13px;
}

.cancel-reply {
    color: #245d7a;
    background: transparent;
    border: 1px solid #9bc2d3;
}

.reply-picker {
    position: absolute;
    z-index: 20;
    box-shadow: 0 8px 20px rgba(24, 32, 42, 0.18);
}
.media-picker {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid #d8e0e7;
    border-radius: 8px;
    background: #f7f9fb;
}

.picker-tabs {
    display: flex;
    gap: 6px;
}

.giphy-search {
    display: flex;
    gap: 8px;
}

.giphy-search input {
    min-width: 0;
}

.giphy-search button {
    padding: 10px 12px;
}

.picker-tab {
    flex: 1;
    padding: 8px 10px;
    color: #245d7a;
    background: #edf2f6;
}

.picker-tab.active,
.picker-tab:hover {
    color: #ffffff;
    background: #245d7a;
}

.picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
    gap: 8px;
    max-height: 220px;
    overflow-x: auto;
    overflow-y: auto;
}

.giphy-results {
    grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
}

.picker-grid button {
    min-height: 48px;
    padding: 0;
    color: #18202a;
    background: #ffffff;
    border: 1px solid #d8e0e7;
}

.giphy-item {
    aspect-ratio: 1;
    overflow: hidden;
}

.giphy-item img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.picker-status {
    grid-column: 1 / -1;
    padding: 14px;
    color: #66717f;
    text-align: center;
}

.picker-grid button:hover {
    background: #dfe8ef;
}

.emoji-bar button {
    font-size: 22px;
}

.sticker-bar button {
    min-height: 58px;
    padding: 8px;
    color: #245d7a;
    font-size: 13px;
    font-weight: 700;
}

.gif-bar button {
    min-height: 64px;
    color: #ffffff;
    background: linear-gradient(135deg, #245d7a, #2d8f6f);
}

.gif-bar button:hover {
    background: linear-gradient(135deg, #1d4b63, #26785e);
}

.gif-bar span {
    display: inline-block;
    animation: gifPulse 900ms ease-in-out infinite alternate;
}

.picker-toggle {
    width: 44px;
    min-width: 44px;
    padding: 0;
    font-size: 22px;
}


.picker-toggle.active {
    background: #1d4b63;
}

@keyframes gifPulse {
    from {
        transform: scale(0.95);
    }

    to {
        transform: scale(1.08);
    }
}

#imageInput {
    display: none;
}

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

.upload-help {
    color: #66717f;
    font-size: 12px;
}

.upload-progress {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 8px;
    color: #245d7a;
    font-size: 12px;
}

.upload-progress-bar {
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: #dfe8ef;
}

.upload-progress-bar span {
    display: block;
    width: 0;
    height: 100%;
    background: #2d8f6f;
    transition: width 160ms ease;
}

button:disabled,
.file-button:has(+ input:disabled) {
    opacity: 0.65;
    cursor: not-allowed;
}

@media (max-width: 700px) {
    .chat-shell {
        width: 100%;
        min-height: 100vh;
        margin: 0;
        border: 0;
        border-radius: 0;
    }

    .topbar,
    .compose-row {
        flex-direction: column;
        align-items: stretch;
    }

    .name-form {
        min-width: 0;
    }

    .rps-choices {
        grid-template-columns: 1fr;
    }

    .rps-choice {
        min-height: 86px;
    }
}

.fun-panel {
    display: grid;
    gap: 10px;
    padding: 12px 18px;
    background: #ffffff;
    border-top: 1px solid #dce4eb;
}

.quick-actions,
.chat-options,
.profile-form,
.message-header,
.reaction-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.quick-actions button,
.chat-options button,
.profile-form button,
.reaction-bar button,
.favorite-message,
.poll-option,
.media-gallery-header button {
    min-height: 34px;
    border: 1px solid #bdd5df;
    border-radius: 8px;
    background: #f7fbfd;
    color: #245d7a;
    font-weight: 700;
    cursor: pointer;
}

.quick-actions button,
.profile-form button,
.media-gallery-header button {
    padding: 7px 10px;
}

.chat-options label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #52606d;
    font-size: 13px;
    font-weight: 700;
}

.chat-options select,
.profile-form input {
    min-height: 34px;
    border: 1px solid #c9d6df;
    border-radius: 8px;
    background: #ffffff;
    padding: 6px 8px;
}

#profileAvatar {
    width: 46px;
    text-align: center;
    font-weight: 800;
}

#profileColor {
    width: 42px;
    padding: 2px;
}

#profilePhrase {
    width: min(220px, 100%);
}

.message-header {
    align-items: flex-start;
    gap: 9px;
}

.message-avatar {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    flex: 0 0 48px;
    border-radius: 50%;
    overflow: hidden;
    color: #ffffff;
    font-size: 17px;
    font-weight: 900;
    line-height: 1;
    box-shadow: inset 0 0 0 2px rgba(255,255,255,0.48), 0 3px 10px rgba(20,32,42,0.18);
}

.avatar-animated {
    animation: avatarPulse 1.8s ease-in-out infinite;
}

.profile-phrase {
    display: block;
    margin-top: 2px;
    color: #687789;
    font-size: 11px;
    font-weight: 700;
}

.reaction-bar {
    margin-top: 8px;
    gap: 5px;
}

.reaction-bar button {
    min-height: 28px;
    padding: 4px 7px;
    background: rgba(255,255,255,0.72);
}

.favorite-message {
    width: 34px;
    padding: 4px 0;
    font-size: 18px;
    line-height: 1;
}

.favorite-message.active {
    color: #b7791f;
    background: #fff7db;
    border-color: #f2ca63;
}

.poll-card {
    display: grid;
    gap: 8px;
    margin-top: 10px;
    padding: 10px;
    border: 1px solid #b9d8e3;
    border-radius: 8px;
    background: #f3fbfd;
}

.poll-card > strong {
    color: #183642;
}

.poll-option {
    position: relative;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    padding: 8px 10px;
    text-align: left;
    background: #ffffff;
}

.poll-option span,
.poll-option strong {
    position: relative;
    z-index: 1;
}

.poll-option i {
    position: absolute;
    inset: 0 auto 0 0;
    background: rgba(45, 143, 111, 0.16);
    pointer-events: none;
}

.poll-option.selected {
    border-color: #2d8f6f;
}

.surprise-effect {
    display: inline-grid;
    place-items: center;
    margin-top: 8px;
    padding: 10px 14px;
    border-radius: 8px;
    color: #7a2e5d;
    background: #ffe6f3;
    border: 1px solid #f4a3cc;
    font-weight: 900;
    animation: surprisePop 800ms ease-in-out infinite alternate;
}

.effect-letter {
    background: #fffaf0;
    border-color: #e8c98d;
    box-shadow: 0 8px 20px rgba(113, 79, 32, 0.12);
}

.effect-spark {
    box-shadow: 0 0 0 2px rgba(245, 185, 66, 0.25), 0 8px 22px rgba(245, 185, 66, 0.18);
}

.typing-indicator {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 10px;
    border-radius: 999px;
    color: #52606d;
    background: #ffffff;
    border: 1px solid #dce4eb;
    font-size: 13px;
    font-weight: 700;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #2d8f6f;
    animation: typingDot 1s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 120ms; }
.typing-indicator span:nth-child(3) { animation-delay: 240ms; }

.media-gallery-modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(15, 23, 42, 0.45);
}

.media-gallery-box {
    width: min(760px, 96vw);
    max-height: 84vh;
    overflow: auto;
    border-radius: 10px;
    background: #ffffff;
    box-shadow: 0 22px 60px rgba(15, 23, 42, 0.22);
}

.media-gallery-header {
    position: sticky;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    background: #ffffff;
    border-bottom: 1px solid #e1e8ef;
}

.media-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
    padding: 12px;
}

.gallery-item {
    display: grid;
    gap: 6px;
    min-height: 126px;
    padding: 8px;
    border: 1px solid #dce4eb;
    border-radius: 8px;
    background: #f8fbfd;
    color: #245d7a;
    font-weight: 800;
    cursor: pointer;
}

.gallery-item img {
    width: 100%;
    height: 96px;
    object-fit: cover;
    border-radius: 6px;
}

.gallery-item span,
.gallery-empty {
    color: #687789;
    font-size: 12px;
}

.theme-night .messages,
.theme-night .composer,
.theme-night .fun-panel {
    background: #121826;
}

.theme-night .message,
.theme-night .typing-indicator,
.theme-night .media-gallery-box {
    background: #1f2937;
    color: #e5edf5;
    border-color: #334155;
}

.theme-night .message.mine {
    background: #163229;
}

.theme-love .messages,
.theme-love .composer,
.theme-love .fun-panel {
    background: #fff2f7;
}

.theme-love .message.mine {
    background: #ffe3ef;
    border-color: #f3a8c8;
}

.theme-forest .messages,
.theme-forest .composer,
.theme-forest .fun-panel {
    background: #effaf4;
}

.theme-forest .message.mine {
    background: #dbf5e6;
    border-color: #8fd0aa;
}

@keyframes avatarPulse {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-1px) scale(1.06); }
}

@keyframes surprisePop {
    from { transform: rotate(-1deg) scale(1); }
    to { transform: rotate(1deg) scale(1.04); }
}

@keyframes typingDot {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
    40% { transform: translateY(-3px); opacity: 1; }
}

@media (max-width: 640px) {
    .fun-panel {
        padding: 10px;
    }

    .quick-actions {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 2px;
    }

    .quick-actions button {
        flex: 0 0 auto;
    }

    .chat-options,
    .profile-form {
        align-items: stretch;
    }

    #profilePhrase {
        width: 100%;
        flex: 1 1 160px;
    }
}

.animations-menu {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px;
    border: 1px solid #cfe0e8;
    border-radius: 8px;
    background: #f8fcfd;
    box-shadow: 0 8px 22px rgba(24, 32, 42, 0.08);
}

.animations-menu[hidden] {
    display: none;
}

.animations-menu button {
    min-height: 34px;
    padding: 7px 10px;
    border: 1px solid #bdd5df;
    border-radius: 8px;
    background: #ffffff;
    color: #245d7a;
    font-weight: 800;
    cursor: pointer;
}

.screen-animation {
    position: fixed;
    inset: 0;
    z-index: 200;
    pointer-events: none;
    overflow: hidden;
}

.screen-particle {
    position: absolute;
    bottom: -40px;
    font-size: clamp(24px, 4vw, 48px);
    animation: particleFloat var(--duration, 3s) ease-out forwards;
    transform: translateX(0) scale(0.8);
    text-shadow: 0 8px 18px rgba(24, 32, 42, 0.16);
}

.screen-particle.heart {
    color: #e53e7f;
}

.screen-particle.star,
.screen-particle.party {
    color: #f6b73c;
}

.hug-scene {
    position: absolute;
    left: 50%;
    top: 48%;
    width: min(360px, 78vw);
    height: 220px;
    transform: translate(-50%, -50%);
}

.hug-person {
    position: absolute;
    top: 42px;
    width: 132px;
    height: 132px;
    display: grid;
    place-items: center;
    border-radius: 44% 44% 38% 38%;
    color: #ffffff;
    font-size: 58px;
    font-weight: 900;
    box-shadow: inset 0 12px 22px rgba(255,255,255,0.35), 0 16px 34px rgba(20, 32, 42, 0.18);
    animation: hugBounce 1.05s ease-in-out infinite alternate;
}

.hug-person::before {
    content: '';
    position: absolute;
    top: -58px;
    width: 92px;
    height: 92px;
    border-radius: 50%;
    background: inherit;
    box-shadow: inset 0 14px 20px rgba(255,255,255,0.35);
}

.hug-person.left {
    left: 48px;
    background: #5dbb63;
}

.hug-person.right {
    right: 48px;
    background: #5aa9e6;
    animation-delay: 160ms;
}

.hug-ribbon {
    position: absolute;
    left: 15%;
    right: 15%;
    top: 106px;
    height: 18px;
    border-radius: 999px;
    background: linear-gradient(90deg, transparent, #ffd86b, #fff6b7, #ffd86b, transparent);
    filter: drop-shadow(0 0 12px rgba(255, 216, 107, 0.9));
    animation: ribbonLoop 1.3s ease-in-out infinite;
}

.nudge-label,
.dance-effect {
    position: absolute;
    left: 50%;
    top: 45%;
    transform: translate(-50%, -50%);
    color: #ffffff;
    font-size: clamp(40px, 12vw, 96px);
    font-weight: 900;
    text-shadow: 0 8px 28px rgba(15, 23, 42, 0.45);
}

.dance-effect {
    color: #7c3aed;
    animation: danceMove 900ms ease-in-out infinite;
}

.screen-nudge {
    animation: screenNudge 120ms linear 6;
}

@keyframes particleFloat {
    0% {
        opacity: 0;
        transform: translate(0, 0) scale(0.7) rotate(-8deg);
    }
    14% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translate(var(--drift, 0), -105vh) scale(1.35) rotate(18deg);
    }
}

@keyframes hugBounce {
    from { transform: translateX(-8px) rotate(-2deg); }
    to { transform: translateX(8px) rotate(2deg); }
}

@keyframes ribbonLoop {
    0%, 100% { transform: translateY(0) scaleX(0.9); }
    50% { transform: translateY(-8px) scaleX(1.08); }
}

@keyframes screenNudge {
    0% { transform: translate(0, 0); }
    25% { transform: translate(7px, -3px); }
    50% { transform: translate(-6px, 4px); }
    75% { transform: translate(4px, 3px); }
    100% { transform: translate(0, 0); }
}

@keyframes danceMove {
    0%, 100% { transform: translate(-50%, -50%) rotate(-8deg) scale(1); }
    50% { transform: translate(-50%, -58%) rotate(8deg) scale(1.12); }
}


.pig-dancer {
    position: absolute;
    left: 50%;
    top: 45%;
    width: min(240px, 58vw);
    height: min(280px, 68vw);
    transform: translate(-50%, -50%);
    animation: pigDiscoDance 760ms ease-in-out infinite;
    filter: drop-shadow(0 24px 30px rgba(15, 23, 42, 0.25));
}

.pig-head,
.pig-body,
.pig-ear,
.pig-arm,
.pig-leg,
.pig-shadow {
    position: absolute;
    display: block;
}

.pig-head {
    left: 50%;
    top: 8%;
    width: 58%;
    aspect-ratio: 1;
    transform: translateX(-50%);
    border-radius: 48% 48% 45% 45%;
    background: #ff9fc1;
    box-shadow: inset 14px 18px 22px rgba(255,255,255,0.34), inset -10px -14px 18px rgba(187, 52, 105, 0.18);
    z-index: 3;
}

.pig-ear {
    top: 5%;
    width: 24%;
    aspect-ratio: 1;
    border-radius: 60% 35% 58% 38%;
    background: #ff8db5;
    z-index: 2;
}

.pig-ear.left {
    left: 18%;
    transform: rotate(-30deg);
}

.pig-ear.right {
    right: 18%;
    transform: rotate(30deg) scaleX(-1);
}

.pig-glasses {
    position: absolute;
    left: 50%;
    top: 35%;
    width: 70%;
    height: 20%;
    transform: translateX(-50%);
}

.pig-glasses::before {
    content: '';
    position: absolute;
    left: 47%;
    top: 45%;
    width: 10%;
    height: 12%;
    border-radius: 999px;
    background: #111827;
}

.pig-glasses i {
    position: absolute;
    top: 0;
    width: 38%;
    height: 100%;
    border-radius: 45% 45% 52% 52%;
    background: linear-gradient(135deg, #111827 0%, #111827 52%, #334155 53%, #0f172a 100%);
    box-shadow: 0 4px 0 rgba(255,255,255,0.18) inset;
}

.pig-glasses i:first-child {
    left: 0;
}

.pig-glasses i:last-child {
    right: 0;
}

.pig-snout {
    position: absolute;
    left: 50%;
    top: 57%;
    width: 42%;
    height: 26%;
    transform: translateX(-50%);
    border-radius: 50%;
    background: #ff78a6;
    box-shadow: inset 6px 8px 12px rgba(255,255,255,0.28);
}

.pig-snout i {
    position: absolute;
    top: 42%;
    width: 15%;
    height: 18%;
    border-radius: 50%;
    background: #9f2d59;
}

.pig-snout i:first-child {
    left: 28%;
}

.pig-snout i:last-child {
    right: 28%;
}

.pig-smile {
    position: absolute;
    left: 50%;
    top: 78%;
    width: 22%;
    height: 12%;
    transform: translateX(-50%);
    border-bottom: 4px solid #8f2953;
    border-radius: 0 0 999px 999px;
}

.pig-body {
    left: 50%;
    top: 44%;
    width: 62%;
    height: 43%;
    transform: translateX(-50%);
    border-radius: 48% 48% 42% 42%;
    background: #ff8ab2;
    box-shadow: inset 16px 16px 22px rgba(255,255,255,0.25), inset -12px -14px 18px rgba(160, 48, 92, 0.18);
    z-index: 1;
}

.pig-arm {
    top: 20%;
    width: 19%;
    height: 45%;
    border-radius: 999px;
    background: #ff8ab2;
    transform-origin: top center;
    animation: pigArmWave 520ms ease-in-out infinite alternate;
}

.pig-arm.left {
    left: -10%;
}

.pig-arm.right {
    right: -10%;
    animation-delay: 180ms;
}

.pig-leg {
    bottom: -15%;
    width: 22%;
    height: 30%;
    border-radius: 999px;
    background: #f472a6;
    transform-origin: top center;
    animation: pigFeetStep 380ms ease-in-out infinite alternate;
}

.pig-leg.left {
    left: 24%;
}

.pig-leg.right {
    right: 24%;
    animation-delay: 190ms;
}

.pig-shadow {
    left: 50%;
    bottom: -2%;
    width: 64%;
    height: 9%;
    transform: translateX(-50%);
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.18);
    animation: pigShadowPulse 760ms ease-in-out infinite;
}

@keyframes pigDiscoDance {
    0%, 100% { transform: translate(-50%, -50%) rotate(-7deg) scale(1); }
    25% { transform: translate(-54%, -58%) rotate(8deg) scale(1.04); }
    50% { transform: translate(-50%, -45%) rotate(0deg) scale(0.98); }
    75% { transform: translate(-46%, -58%) rotate(-8deg) scale(1.05); }
}

@keyframes pigArmWave {
    from { transform: rotate(-38deg); }
    to { transform: rotate(42deg); }
}

@keyframes pigFeetStep {
    from { transform: rotate(-16deg) translateY(0); }
    to { transform: rotate(18deg) translateY(10px); }
}

@keyframes pigShadowPulse {
    0%, 100% { transform: translateX(-50%) scaleX(1); opacity: 0.16; }
    50% { transform: translateX(-50%) scaleX(0.72); opacity: 0.26; }
}

@media (prefers-reduced-motion: reduce) {
    .screen-animation,
    .screen-particle,
    .hug-person,
    .hug-ribbon,
    .dance-effect,
    .pig-dancer,
    .pig-arm,
    .pig-leg,
    .pig-shadow,
    .screen-nudge {
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
    }
}

.profile-photo-picker {
    position: relative;
    min-height: 34px;
    padding: 7px 10px;
    border: 1px solid #bdd5df;
    border-radius: 8px;
    background: #ffffff;
    color: #245d7a;
    font-weight: 800;
    cursor: pointer;
}

.profile-photo-picker input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: inherit;
    object-fit: cover;
    object-position: center;
}

#profileDisplayName,
#profileUsername {
    width: min(150px, 100%);
}

.presence-bar {
    padding: 8px 18px;
    color: #52606d;
    background: #f4fbf8;
    border-top: 1px solid #dce4eb;
    border-bottom: 1px solid #dce4eb;
    font-size: 13px;
    font-weight: 700;
}

.attachment-preview {
    display: grid;
    gap: 8px;
    margin-bottom: 8px;
    padding: 10px;
    border: 1px solid #cfe0e8;
    border-radius: 8px;
    background: #f8fcfd;
}

.attachment-preview[hidden] {
    display: none;
}

.attachment-preview-header {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: space-between;
    color: #245d7a;
    font-size: 13px;
}

.attachment-preview-header strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-preview-header span {
    color: #66717f;
    white-space: nowrap;
}

.attachment-preview-header button,
.secret-reveal,
.screen-lock-card button {
    min-height: 34px;
    padding: 7px 10px;
    border: 1px solid #bdd5df;
    border-radius: 8px;
    background: #ffffff;
    color: #245d7a;
    font-weight: 800;
    cursor: pointer;
}

.attachment-preview img,
.attachment-preview video {
    max-width: min(360px, 100%);
    max-height: 240px;
    border-radius: 8px;
    object-fit: contain;
    background: #eef3f6;
}

.document-preview {
    display: grid;
    place-items: center;
    width: 120px;
    height: 90px;
    border-radius: 8px;
    color: #245d7a;
    background: #eaf4f8;
    border: 1px solid #bdd5df;
    font-weight: 900;
}

.secret-option {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    gap: 6px;
    margin-bottom: 8px;
    padding: 7px 10px;
    border: 1px solid #dfc9ef;
    border-radius: 8px;
    color: #6b2a7d;
    background: #fbf3ff;
    font-weight: 800;
}

.secret-message:not(.secret-revealed) > :not(.message-header):not(.secret-reveal):not(.message-actions) {
    display: none !important;
}

.secret-message:not(.secret-revealed) {
    background: #f8f0ff;
    border-color: #d9b9ef;
}

.secret-reveal {
    display: block;
    margin-top: 10px;
    background: #ffffff;
    color: #6b2a7d;
    border-color: #d9b9ef;
}

.screen-lock {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(15, 23, 42, 0.62);
    backdrop-filter: blur(4px);
}

.screen-lock[hidden] {
    display: none;
}

.screen-lock-card {
    display: grid;
    gap: 12px;
    width: min(380px, 94vw);
    padding: 20px;
    border-radius: 10px;
    background: #ffffff;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
}

.screen-lock-card h2 {
    margin: 0;
    color: #102033;
}

.screen-lock-card p {
    margin: 0;
    color: #52606d;
}

.screen-lock-card input {
    min-height: 44px;
    border: 1px solid #c9d6df;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 18px;
}

#lockStatus {
    min-height: 18px;
    color: #b42318;
    font-weight: 700;
}

@media (max-width: 640px) {
    .presence-bar {
        padding: 8px 10px;
    }

    .attachment-preview-header {
        align-items: flex-start;
        flex-wrap: wrap;
    }
}
