:root {
    color-scheme: dark;
    --bg: #0c0e13;
    --panel: #12151c;
    --panel-2: #181c25;
    --line: rgba(255, 255, 255, .08);
    --muted: #858b98;
    --text: #eef0f4;
    --accent: #c4f35a;
    --accent-dark: #161c0a;
    --danger: #ff7d7d;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
}
body {
    position: fixed;
    inset: 0;
    width: 100%;
    height: auto;
    touch-action: pan-x pan-y;
}
body {
    margin: 0;
    overflow: hidden;
    background:
        radial-gradient(circle at 50% -20%, rgba(196, 243, 90, .08), transparent 35%),
        var(--bg);
    color: var(--text);
}
button, input, textarea { font: inherit; }
button { color: inherit; }
svg {
    width: 1.25rem;
    height: 1.25rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.gate-shell {
    min-height: 100%;
    display: grid;
    place-items: center;
    padding: 24px;
}
.gate-card {
    width: min(430px, 100%);
    text-align: center;
    padding: 45px 42px 34px;
    background: linear-gradient(160deg, rgba(28, 32, 42, .96), rgba(17, 20, 27, .98));
    border: 1px solid var(--line);
    border-radius: 24px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
}
.gate-mark, .dialog-icon {
    width: 58px;
    height: 58px;
    margin: 0 auto 22px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    color: var(--accent);
    background: rgba(196, 243, 90, .09);
    border: 1px solid rgba(196, 243, 90, .16);
}
.gate-mark svg { width: 28px; height: 28px; }
.eyebrow {
    margin: 0 0 10px;
    color: var(--accent);
    font-size: 11px;
    font-weight: 750;
    letter-spacing: .22em;
}
.gate-card h1 {
    margin: 0;
    font-family: Georgia, "Songti SC", serif;
    font-size: 44px;
    font-weight: 500;
    letter-spacing: .12em;
}
.gate-intro {
    margin: 12px 0 32px;
    color: var(--muted);
    font-size: 14px;
}
.gate-form { text-align: left; }
.gate-form label, .name-dialog label {
    display: block;
    margin-bottom: 9px;
    color: #b7bbc5;
    font-size: 13px;
}
.password-wrap { position: relative; }
.password-wrap input, .name-dialog input {
    width: 100%;
    padding: 14px 48px 14px 15px;
    color: var(--text);
    background: #0d1016;
    border: 1px solid rgba(255,255,255,.11);
    border-radius: 11px;
    outline: none;
    transition: .2s;
}
.password-wrap input:focus, .name-dialog input:focus {
    border-color: rgba(196,243,90,.58);
    box-shadow: 0 0 0 3px rgba(196,243,90,.08);
}
.password-wrap .icon-button {
    position: absolute;
    right: 7px;
    top: 50%;
    transform: translateY(-50%);
}
.icon-button, .quiet-button, .composer-action {
    display: grid;
    place-items: center;
    padding: 8px;
    background: transparent;
    border: 0;
    border-radius: 9px;
    color: var(--muted);
    cursor: pointer;
}
.icon-button:hover, .quiet-button:hover, .composer-action:hover { color: var(--text); background: rgba(255,255,255,.06); }
.notification-toggle.active { color: var(--accent); background: rgba(196,243,90,.08); }
.notification-toggle {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    margin-inline: 2px;
}
.form-error { min-height: 20px; margin: 8px 0 3px; color: var(--danger); font-size: 12px; }
.primary-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    width: 100%;
    margin-top: 9px;
    padding: 13px 18px;
    color: #13170b;
    background: var(--accent);
    border: 0;
    border-radius: 11px;
    font-weight: 750;
    cursor: pointer;
}
.primary-button:hover { filter: brightness(1.05); }
.primary-button:disabled { opacity: .55; cursor: wait; }
.security-note {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 7px;
    margin: 28px 0 0;
    color: #686e7a;
    font-size: 11px;
}
.security-note svg { width: 14px; }

.chat-shell {
    height: 100%;
    max-height: 100%;
    width: 100%;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    max-width: 480px;
    margin: auto;
    background: rgba(15, 18, 24, .82);
    border-inline: 1px solid var(--line);
}
.topbar {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    column-gap: 8px;
    min-height: calc(64px + env(safe-area-inset-top));
    padding: calc(9px + env(safe-area-inset-top)) 12px 9px;
    background: rgba(14, 17, 23, .88);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(18px);
}
.brand, .top-actions { display: flex; align-items: center; gap: 8px; }
.top-actions { flex: 0 0 auto; }
.online-counter {
    position: static;
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 7px;
    color: #8d939e;
    background: rgba(255,255,255,.035);
    border: 1px solid var(--line);
    border-radius: 10px;
    transform: none;
}
.online-counter svg { width: 14px; height: 14px; color: var(--accent); }
.online-counter strong { color: var(--text); font-size: 13px; }
.online-counter span { display: none; }
.brand-mark {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    color: var(--accent);
    background: rgba(196,243,90,.08);
    border: 1px solid rgba(196,243,90,.13);
    border-radius: 13px;
}
.brand h1 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: 17px; font-weight: 500; letter-spacing: .08em; }
.brand p { display: none; }
.status-dot { display: inline-block; width: 6px; height: 6px; margin-right: 5px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.name-chip {
    display: flex;
    align-items: center;
    gap: 7px;
    max-width: 72px;
    padding: 7px 8px;
    color: #c5c8cf;
    background: rgba(255,255,255,.045);
    border: 1px solid var(--line);
    border-radius: 10px;
    cursor: pointer;
}
.name-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.name-chip svg { width: 13px; }
.messages {
    overflow-y: auto;
    padding: 24px 13px;
    scroll-behavior: smooth;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}
.messages::-webkit-scrollbar { width: 7px; }
.messages::-webkit-scrollbar-thumb { background: #292e38; border-radius: 9px; }
.time-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 2px 0 18px;
    color: #575e69;
}
.time-divider::before,
.time-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: rgba(255,255,255,.05);
}
.time-divider time {
    flex: 0 0 auto;
    font-size: 10px;
    font-style: normal;
}
.message-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    max-width: 88%;
    margin-bottom: 22px;
    animation: rise .25s ease-out;
}
.message-row.mine { margin-left: auto; flex-direction: row-reverse; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.message-row.incoming-new {
    animation: incoming-message .55s cubic-bezier(.18,.8,.24,1);
}
.message-row.incoming-new .bubble {
    animation: incoming-glow 1.1s ease-out;
}
@keyframes incoming-message {
    0% { opacity: 0; transform: translateX(-26px) scale(.96); }
    65% { transform: translateX(4px) scale(1.01); }
    100% { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes incoming-glow {
    0%, 100% { box-shadow: 0 8px 24px rgba(0,0,0,.12); }
    35% { box-shadow: 0 0 0 3px rgba(196,243,90,.24), 0 8px 30px rgba(196,243,90,.16); }
}
.avatar {
    flex: 0 0 auto;
    min-width: 32px;
    min-height: 32px;
    max-width: 150px;
    display: grid;
    place-items: center;
    padding: 8px 10px;
    color: #1b200e;
    background: #d9e8b6;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.25;
    overflow-wrap: anywhere;
    text-align: center;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}
.mine .avatar { background: var(--accent); }
.avatar.avatar-color-0, .notice-avatar.avatar-color-0 { color: #17200b; background: #c4f35a; }
.avatar.avatar-color-1, .notice-avatar.avatar-color-1 { color: #0c1c24; background: #79d7ff; }
.avatar.avatar-color-2, .notice-avatar.avatar-color-2 { color: #251426; background: #f0a8eb; }
.avatar.avatar-color-3, .notice-avatar.avatar-color-3 { color: #25170b; background: #ffbd76; }
.avatar.avatar-color-4, .notice-avatar.avatar-color-4 { color: #111d1a; background: #7fe0c3; }
.avatar.avatar-color-5, .notice-avatar.avatar-color-5 { color: #21160e; background: #e7c879; }
.avatar.avatar-color-6, .notice-avatar.avatar-color-6 { color: #171527; background: #bcb0ff; }
.avatar.avatar-color-7, .notice-avatar.avatar-color-7 { color: #251315; background: #ff9fa8; }
.avatar.pat-bounce {
    animation: pat-avatar .72s cubic-bezier(.2,.85,.3,1);
}
@keyframes pat-avatar {
    0%, 100% { transform: translateY(0) rotate(0); }
    20% { transform: translateY(-12px) rotate(-7deg) scale(1.08); }
    40% { transform: translateY(2px) rotate(7deg); }
    60% { transform: translateY(-7px) rotate(-4deg) scale(1.04); }
    80% { transform: translateY(0) rotate(2deg); }
}
.pat-event {
    display: flex;
    justify-content: center;
    margin: 7px 0 18px;
    animation: pat-event-in .35s ease-out;
}
.presence-event {
    display: flex;
    justify-content: center;
    margin: 7px 0 18px;
    animation: pat-event-in .35s ease-out;
}
.presence-event span {
    padding: 6px 11px;
    color: #8e949f;
    background: rgba(255,255,255,.035);
    border-radius: 999px;
    font-size: 11px;
}
.presence-event.joined span { color: #a9d65a; }
.presence-event.left span { color: #c38787; }
.pat-event span {
    padding: 6px 11px;
    color: #8e949f;
    background: rgba(255,255,255,.045);
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 11px;
}
@keyframes pat-event-in {
    from { opacity: 0; transform: translateY(5px) scale(.96); }
}
.pat-center-toast {
    position: fixed;
    z-index: 70;
    top: 50%;
    left: 50%;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: calc(100% - 36px);
    padding: 13px 18px;
    color: #171b0d;
    background: var(--accent);
    border-radius: 14px;
    box-shadow: 0 18px 60px rgba(0,0,0,.46);
    font-size: 14px;
    font-weight: 750;
    transform: translate(-50%, -50%);
    animation: pat-center .95s cubic-bezier(.2,.8,.25,1) forwards;
    pointer-events: none;
}
.presence-center-toast {
    position: fixed;
    z-index: 70;
    top: 46%;
    left: 50%;
    display: flex;
    align-items: center;
    gap: 9px;
    max-width: calc(100% - 36px);
    padding: 12px 17px;
    color: #e9ebef;
    background: rgba(25,29,38,.97);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 18px 60px rgba(0,0,0,.46);
    font-size: 13px;
    font-weight: 700;
    transform: translate(-50%, -50%);
    animation: presence-center 1.75s ease forwards;
    pointer-events: none;
}
.presence-center-toast b { font-size: 18px; }
.presence-center-toast.joined b { color: var(--accent); }
.presence-center-toast.left b { color: #ff9fa8; }
@keyframes presence-center {
    0% { opacity: 0; transform: translate(-50%, -35%) scale(.9); }
    15%, 72% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -62%) scale(.96); }
}
.pat-center-toast b { font-size: 21px; }
@keyframes pat-center {
    0% { opacity: 0; transform: translate(-50%, -40%) scale(.75) rotate(-4deg); }
    20% { opacity: 1; transform: translate(-50%, -50%) scale(1.08) rotate(3deg); }
    42% { transform: translate(-50%, -50%) scale(.98) rotate(-2deg); }
    70% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -65%) scale(.94); }
}
.message-content { min-width: 0; }
.message-meta { display: flex; align-items: center; gap: 8px; margin: 0 3px 7px; font-size: 11px; }
.mine .message-meta { justify-content: flex-end; }
.message-meta strong { color: #c7cad1; font-weight: 650; }
.message-meta time { color: #5f6570; }
.recall-button {
    padding: 0;
    color: #686e78;
    background: transparent;
    border: 0;
    font-size: 10px;
    cursor: pointer;
}
.recall-button:hover { color: var(--accent); }
.recall-entry {
    display: flex;
    justify-content: center;
    margin: 7px 0 18px;
    animation: pat-event-in .3s ease-out;
}
.recall-entry span {
    padding: 6px 11px;
    color: #777e89;
    background: rgba(255,255,255,.035);
    border-radius: 999px;
    font-size: 11px;
    font-style: italic;
}
.bubble {
    position: relative;
    overflow: hidden;
    color: #dfe1e6;
    background: var(--panel-2);
    border: 1px solid rgba(255,255,255,.065);
    border-radius: 5px 16px 16px 16px;
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    touch-action: pan-y;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}
.mine .bubble {
    color: #171a10;
    background: var(--accent);
    border-color: transparent;
    border-radius: 16px 5px 16px 16px;
}
.bubble p { margin: 0; padding: 11px 14px; line-height: 1.65; font-size: 14px; overflow-wrap: anywhere; }
.message-image { display: block; max-width: 100%; padding: 0; border: 0; background: transparent; cursor: zoom-in; }
.message-image img {
    display: block;
    max-width: min(270px, 100%);
    max-height: 330px;
    object-fit: cover;
    -webkit-touch-callout: none;
    -webkit-user-drag: none;
    -webkit-user-select: none;
    user-select: none;
}
.message-image + p { border-top: 1px solid rgba(0,0,0,.1); }
.quoted-message {
    display: block;
    width: calc(100% - 16px);
    margin: 8px 8px 0;
    padding: 8px 10px;
    color: inherit;
    background: rgba(0,0,0,.12);
    border: 0;
    border-left: 3px solid currentColor;
    border-radius: 7px;
    text-align: left;
    cursor: pointer;
}
.quoted-message strong,
.quoted-message span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.quoted-message strong { margin-bottom: 3px; font-size: 10px; }
.quoted-message span { max-width: 240px; opacity: .7; font-size: 10px; }
.bubble.hushed {
    min-width: 145px;
    min-height: 58px;
}
.bubble.hushed > :not(.hush-bandage) {
    opacity: .08;
    filter: blur(9px);
    pointer-events: none;
}
.hush-bandage {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 10px 16px;
    color: #33291d;
    background:
        repeating-linear-gradient(-10deg, transparent 0 12px, rgba(91,66,35,.09) 12px 14px),
        #dbc49d;
    border: 1px solid rgba(89,65,34,.22);
    text-align: center;
}
.hush-bandage::before,
.hush-bandage::after {
    content: "";
    position: absolute;
    left: -8%;
    width: 116%;
    height: 11px;
    background: rgba(245,229,199,.62);
    border-block: 1px dashed rgba(91,66,35,.18);
    transform: rotate(-4deg);
}
.hush-bandage::before { top: 9px; }
.hush-bandage::after { bottom: 9px; transform: rotate(4deg); }
.hush-bandage strong, .hush-bandage small { position: relative; z-index: 1; }
.hush-bandage strong { font-size: 13px; }
.hush-bandage small { color: rgba(51,41,29,.72); font-size: 9px; }
.hush-menu-layer {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: grid;
    place-items: center;
    background: rgba(0,0,0,.12);
}
.message-action-menu {
    position: relative;
    display: flex;
    gap: 8px;
    padding: 8px;
    background: #20242d;
    border: 1px solid rgba(196,243,90,.28);
    border-radius: 18px;
    box-shadow: 0 16px 45px rgba(0,0,0,.5);
    animation: hush-picker-in .2s cubic-bezier(.2,.8,.25,1);
}
.message-action-menu::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: -6px;
    width: 10px;
    height: 10px;
    background: #20242d;
    border-right: 1px solid rgba(196,243,90,.28);
    border-bottom: 1px solid rgba(196,243,90,.28);
    transform: translateX(-50%) rotate(45deg);
}
.message-action-button {
    position: relative;
    z-index: 1;
    display: grid;
    place-items: center;
    width: 52px;
    height: 48px;
    padding: 0;
    background: rgba(255,255,255,.045);
    border: 0;
    border-radius: 12px;
    font-size: 25px;
    cursor: pointer;
}
.message-action-button:active { background: rgba(196,243,90,.14); transform: scale(.95); }
.hush-picker {
    position: relative;
    display: grid;
    place-items: center;
    width: 58px;
    height: 52px;
    padding: 0;
    background: #20242d;
    border: 1px solid rgba(196,243,90,.28);
    border-radius: 16px;
    box-shadow: 0 16px 45px rgba(0,0,0,.5);
    font-size: 28px;
    cursor: pointer;
    animation: hush-picker-in .2s cubic-bezier(.2,.8,.25,1);
}
.hush-picker::after {
    content: "";
    position: absolute;
    bottom: -6px;
    width: 10px;
    height: 10px;
    background: #20242d;
    border-right: 1px solid rgba(196,243,90,.28);
    border-bottom: 1px solid rgba(196,243,90,.28);
    transform: rotate(45deg);
}
@keyframes hush-picker-in {
    from { opacity: 0; transform: translateY(7px) scale(.75); }
}
.hush-notice {
    position: fixed;
    z-index: 70;
    top: 45%;
    left: 50%;
    padding: 12px 17px;
    color: #33291d;
    background: #dbc49d;
    border-radius: 14px;
    box-shadow: 0 18px 55px rgba(0,0,0,.45);
    font-size: 13px;
    font-weight: 750;
    white-space: nowrap;
    transform: translate(-50%, -50%);
    animation: presence-center 1.75s ease forwards;
    pointer-events: none;
}
.loading-state { height: 100%; display: flex; justify-content: center; align-items: center; gap: 6px; }
.loading-state span { width: 6px; height: 6px; background: var(--accent); border-radius: 50%; animation: pulse 1s infinite alternate; }
.loading-state span:nth-child(2) { animation-delay: .2s; }
.loading-state span:nth-child(3) { animation-delay: .4s; }
@keyframes pulse { to { opacity: .2; transform: translateY(-5px); } }
.empty-state { height: 100%; min-height: 240px; display: flex; flex-direction: column; justify-content: center; align-items: center; color: var(--muted); text-align: center; }
.empty-state span { color: var(--accent); font-size: 10px; letter-spacing: .18em; }
.empty-state strong { margin-top: 12px; color: #c8cbd2; font-family: Georgia, serif; font-size: 24px; font-weight: 400; }
.empty-state p { margin: 7px 0; font-size: 13px; }

.composer-shell {
    padding: 10px 10px max(6px, calc(env(safe-area-inset-bottom) - 10px));
    background: linear-gradient(transparent, rgba(12,14,19,.95) 25%);
}
.composer-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 32px;
    margin: 0 8px 7px;
}
.voice-button {
    min-width: 0;
    min-height: 64px;
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 13px;
    color: #d9dde4;
    background: #171a22;
    border: 1px solid rgba(196,243,90,.2);
    border-radius: 15px;
    text-align: left;
    cursor: pointer;
    touch-action: manipulation;
    transition: transform .16s ease, border-color .2s ease, background .2s ease;
}
.voice-button > svg {
    flex: 0 0 auto;
    width: 27px;
    height: 27px;
    color: var(--accent);
}
.voice-button > span { min-width: 0; flex: 1; }
.voice-button strong,
.voice-button small { display: block; }
.voice-button strong { font-size: 13px; }
.voice-button small {
    overflow: hidden;
    margin-top: 2px;
    color: #818794;
    font-size: 9px;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.voice-button:active { transform: scale(.98); }
.voice-button.listening {
    color: #171b0d;
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(196,243,90,.12), 0 8px 28px rgba(196,243,90,.14);
}
.voice-button.listening > svg,
.voice-button.listening small { color: #303918; }
.voice-waves {
    flex: 0 0 auto;
    height: 24px;
    display: flex;
    align-items: center;
    gap: 3px;
}
.voice-waves b {
    width: 3px;
    height: 5px;
    background: currentColor;
    border-radius: 99px;
    opacity: .45;
}
.voice-button.listening .voice-waves b { animation: voice-wave .65s ease-in-out infinite alternate; }
.voice-button.listening .voice-waves b:nth-child(2) { animation-delay: .15s; }
.voice-button.listening .voice-waves b:nth-child(3) { animation-delay: .3s; }
@keyframes voice-wave {
    to { height: 22px; opacity: 1; }
}
.rps-button {
    flex: 0 0 auto;
    min-height: 64px;
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 10px;
    color: #cdd0d6;
    background: #171a22;
    border: 1px solid rgba(196,243,90,.16);
    border-radius: 10px;
    font-size: 11px;
    cursor: pointer;
}
.rps-button span { letter-spacing: -2px; }
.rps-button strong { color: var(--accent); font-size: 11px; }
.rps-button:active { transform: scale(.95); }
.rps-button:disabled { opacity: .5; cursor: wait; }
.rps-button.throwing { animation: rps-button-shake .55s ease; }
@keyframes rps-button-shake {
    0%, 100% { transform: rotate(0); }
    25% { transform: rotate(-5deg) scale(.96); }
    50% { transform: rotate(5deg) scale(1.03); }
    75% { transform: rotate(-3deg); }
}
.rps-bubble {
    min-width: 118px;
    padding: 13px 16px;
    text-align: center;
}
.rps-bubble .rps-emoji {
    display: block;
    margin-bottom: 5px;
    font-size: 36px;
    line-height: 1.1;
}
.rps-bubble strong {
    display: block;
    font-size: 12px;
}
.rps-bubble small {
    display: block;
    margin-top: 3px;
    opacity: .62;
    font-size: 9px;
}
.rps-bubble.rps-countdown .rps-emoji.rps-frame {
    transform-origin: 50% 100%;
    animation: rps-frame-change .27s cubic-bezier(.2,.8,.3,1);
}
.rps-bubble.rps-countdown strong { animation: rps-label-pulse .32s ease-in-out infinite alternate; }
.rps-bubble.rps-revealed {
    animation: rps-bubble-flash .75s ease-out;
}
.rps-bubble.rps-revealed .rps-emoji {
    animation: rps-reveal .6s cubic-bezier(.2,.85,.3,1);
}
@keyframes rps-frame-change {
    0% { opacity: .25; transform: translateY(10px) scale(.72) rotate(-8deg); }
    65% { opacity: 1; transform: translateY(-7px) scale(1.14) rotate(5deg); }
    100% { transform: translateY(0) scale(1) rotate(0); }
}
@keyframes rps-label-pulse {
    to { opacity: .48; }
}
@keyframes rps-bubble-flash {
    0% { box-shadow: 0 0 0 0 rgba(196,243,90,.65); }
    40% { box-shadow: 0 0 0 5px rgba(196,243,90,.2), 0 0 30px rgba(196,243,90,.24); }
    100% { box-shadow: 0 0 0 10px rgba(196,243,90,0); }
}
@keyframes rps-reveal {
    0% { opacity: 0; transform: scale(.2) rotate(-25deg); }
    65% { transform: scale(1.18) rotate(6deg); }
    100% { opacity: 1; transform: scale(1) rotate(0); }
}
.composer {
    display: flex;
    align-items: flex-end;
    gap: 7px;
    padding: 7px;
    background: #171a22;
    border: 1px solid rgba(255,255,255,.09);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
.composer:focus-within { border-color: rgba(196,243,90,.32); }
.composer-action { flex: 0 0 auto; padding: 10px; }
.composer textarea {
    flex: 1;
    min-width: 0;
    resize: none;
    padding: 10px 4px 8px;
    color: var(--text);
    background: transparent;
    border: 0;
    outline: 0;
    line-height: 1.45;
    -webkit-touch-callout: default;
    -webkit-user-select: text;
    user-select: text;
}
.composer textarea::placeholder { color: #616773; }
.send-button {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    color: #171b0d;
    background: var(--accent);
    border: 0;
    border-radius: 12px;
    cursor: pointer;
}
.send-button:hover { transform: translateY(-1px); }
.send-button:disabled { opacity: .5; }
.composer-hint { display: none; }
kbd { font: inherit; color: #777d88; }
.paste-preview {
    width: fit-content;
    max-width: 100%;
    display: flex;
    align-items: center;
    gap: 11px;
    margin: 0 0 8px 8px;
    padding: 8px;
    background: #171a22;
    border: 1px solid var(--line);
    border-radius: 13px;
}
.reply-preview {
    width: calc(100% - 16px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 0 8px 8px;
    padding: 9px 10px 9px 12px;
    background: #171a22;
    border: 1px solid rgba(196,243,90,.18);
    border-left: 3px solid var(--accent);
    border-radius: 11px;
}
.reply-preview[hidden] { display: none; }
.reply-preview div { min-width: 0; }
.reply-preview small { color: #858b98; font-size: 10px; }
.reply-preview small strong { color: var(--accent); }
.reply-preview p {
    overflow: hidden;
    margin: 3px 0 0;
    color: #c9ccd3;
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.paste-preview[hidden] { display: none; }
.paste-preview img { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; }
.paste-preview div { min-width: 110px; }
.paste-preview strong, .paste-preview small { display: block; }
.paste-preview strong { font-size: 12px; }
.paste-preview small { margin-top: 3px; color: var(--muted); font-size: 10px; }

.name-dialog {
    width: min(390px, calc(100% - 28px));
    padding: 0;
    color: var(--text);
    background: #171a22;
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 20px;
    box-shadow: 0 35px 90px rgba(0,0,0,.65);
}
.name-dialog::backdrop { background: rgba(3,4,6,.76); backdrop-filter: blur(5px); }
.name-dialog form { padding: 30px; }
.dialog-icon { width: 48px; height: 48px; margin-bottom: 17px; border-radius: 14px; }
.name-dialog h2 { margin: 0 0 7px; text-align: center; font-size: 20px; }
.name-dialog > form > p:not(.form-error) { margin: 0 0 24px; color: var(--muted); font-size: 12px; text-align: center; }
.name-dialog input { padding-right: 15px; }
.dialog-actions { display: flex; gap: 9px; margin-top: 14px; }
.dialog-actions .primary-button { margin: 0; }
.secondary-button { padding: 11px 18px; color: #aeb2bc; background: transparent; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.toast {
    position: fixed;
    left: 50%;
    bottom: 105px;
    z-index: 20;
    max-width: calc(100% - 30px);
    padding: 10px 16px;
    color: #12150b;
    background: var(--accent);
    border-radius: 10px;
    font-size: 12px;
    font-weight: 650;
    opacity: 0;
    transform: translate(-50%, 12px);
    pointer-events: none;
    transition: .2s;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.image-lightbox {
    position: fixed;
    inset: 0;
    z-index: 50;
    overflow: auto;
    background: rgba(0,0,0,.92);
    overscroll-behavior: contain;
}
.lightbox-canvas {
    width: max-content;
    min-width: 100%;
    min-height: 100%;
    display: grid;
    place-items: center;
    padding: 30px;
    cursor: zoom-out;
}
.image-lightbox img {
    display: block;
    max-width: none;
    max-height: none;
    width: auto;
    height: auto;
    cursor: default;
}
.image-lightbox button {
    position: fixed;
    top: max(18px, env(safe-area-inset-top));
    right: 24px;
    z-index: 1;
    width: 42px;
    height: 42px;
    color: white;
    background: rgba(12,14,19,.72);
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 50%;
    font-size: 30px;
    line-height: 1;
    cursor: pointer;
}

@media (max-width: 640px) {
    .gate-card { padding: 36px 24px 28px; }
    .chat-shell { border: 0; }
    .top-actions { gap: 7px; }
}

@media (display-mode: standalone) {
    .chat-shell {
        height: 100%;
        max-height: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .message-row.incoming-new,
    .message-row.incoming-new .bubble {
        animation: none;
    }
    .avatar.pat-bounce,
    .pat-center-toast,
    .pat-event,
    .presence-center-toast,
    .presence-event {
        animation: none;
    }
    .voice-button.listening .voice-waves b { animation: none; }
}
