@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500&family=JetBrains+Mono:wght@100;300;400;500&display=swap');

:root {
    --bg-base: #050505;
    --glass-bg: rgba(18, 18, 18, 0.4);
    --glass-border: rgba(255, 255, 255, 0.05);
    --glass-border-light: rgba(255, 255, 255, 0.1);
    
    --text-primary: #ededed;
    --text-secondary: #888888;
    --text-highlight: #ffffff;
    
    --accent: #e0e0e0;
    --accent-glow: rgba(255, 255, 255, 0.15);
    --danger: #ef4444;
    
    --msg-in: rgba(30, 30, 30, 0.6);
    --msg-out: rgba(255, 255, 255, 0.05);
    
    --font-ui: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --transition: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    width: 100%;
    height: 100%;
    max-width: 100%;
    overflow: hidden;
    background: var(--bg-base);
    overscroll-behavior: none;
}

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-ui);
    width: 100%;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: manipulation;
    display: flex;
    justify-content: center;
    align-items: center;
}

body.viewer-open {
    overflow: hidden;
    touch-action: none;
    overscroll-behavior: none;
}

/* Background layers */
.cipher-bg {
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='400' height='400' xmlns='http://www.w3.org/2000/svg'%3E%3Ctext x='20' y='30' fill='%23ffffff' fill-opacity='0.03' font-family='monospace' font-size='12'%3E01101001 01101110%3C/text%3E%3Ctext x='150' y='120' fill='%23ffffff' fill-opacity='0.02' font-family='monospace' font-size='10'%3ExOR BYTE PTR [RAX]%3C/text%3E%3Ctext x='40' y='250' fill='%23ffffff' fill-opacity='0.03' font-family='monospace' font-size='14'%3E0A 3C FF A1%3C/text%3E%3Ctext x='250' y='220' fill='%23ffffff' fill-opacity='0.02' font-family='monospace' font-size='11'%3EEVP_DecryptInit%3C/text%3E%3Ctext x='180' y='340' fill='%23ffffff' fill-opacity='0.02' font-family='monospace' font-size='12'%3E10010110 01111001%3C/text%3E%3C/svg%3E");
    background-size: 400px 400px;
    z-index: 1;
    animation: drift 150s linear infinite;
    opacity: 0.8;
}

@keyframes drift {
    0% { transform: translate(0, 0); }
    100% { transform: translate(200px, 200px); }
}

.ambient-light {
    position: fixed;
    width: min(600px, 120vw);
    height: min(600px, 120vw);
    background: radial-gradient(circle, rgba(255,255,255,0.03) 0%, transparent 60%);
    border-radius: 50%;
    z-index: 2;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: pulse-light 10s ease-in-out infinite alternate;
}

@keyframes pulse-light {
    0% { opacity: 0.5; transform: translate(-50%, -50%) scale(0.9); }
    100% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
}

.noise-overlay {
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.04'/%3E%3C/svg%3E");
    z-index: 3;
    pointer-events: none;
}

.app-container {
    width: var(--app-width, 100%);
    max-width: 640px;
    min-width: 0;
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
    z-index: 10;
    background: transparent;
}

@media (min-width: 601px) {
    .app-container {
        height: 90vh;
        max-height: 900px;
        margin: 5vh 0;
        border-radius: 24px;
        overflow: hidden;
        border: 1px solid var(--glass-border-light);
        box-shadow: 0 50px 100px -20px rgba(0,0,0,0.8), 0 0 40px rgba(0,0,0,0.4);
    }
}

.screen {
    position: absolute;
    inset: 0;
    min-width: 0;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition), transform var(--transition);
    transform: scale(0.98);
}

.screen.active {
    opacity: 1;
    pointer-events: all;
    transform: scale(1);
    z-index: 20;
}

/* Landing */
#landing {
    justify-content: center;
    align-items: center;
    padding: 24px;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(40px) saturate(120%);
    -webkit-backdrop-filter: blur(40px) saturate(120%);
    border: 1px solid var(--glass-border);
    border-top: 1px solid var(--glass-border-light);
    border-radius: 24px;
    padding: 60px 48px;
    text-align: center;
    box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.8), inset 0 0 0 1px rgba(255,255,255,0.02);
    transform: translateY(10px);
    transition: transform var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.screen.active .glass-panel {
    transform: translateY(0);
}

.shield-icon {
    color: var(--text-secondary);
    margin-bottom: -10px;
}

.glass-panel h1 {
    font-family: var(--font-mono);
    font-weight: 500;
    letter-spacing: -0.05em;
    font-size: 2.2rem;
    color: var(--text-primary);
}

.highlight {
    color: var(--text-secondary);
}

.glass-panel p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
    max-width: 300px;
    font-family: var(--font-mono);
}

/* Buttons */
button {
    font-family: var(--font-mono);
    border: none;
    cursor: pointer;
    outline: none;
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: transparent;
    color: var(--text-highlight);
    padding: 16px 36px;
    border-radius: 12px;
    font-weight: 500;
    font-size: 0.9rem;
    letter-spacing: 0.05em;
    border: 1px solid var(--glass-border-light);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), inset 0 0 20px rgba(255,255,255,0.02);
    margin-top: 16px;
}

.btn-primary:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(255, 255, 255, 0.05), inset 0 0 20px rgba(255,255,255,0.05);
}

.btn-primary:active {
    transform: translateY(1px);
}

/* Chat Layout */
.glass-header {
    padding: 20px 24px;
    background: linear-gradient(to bottom, rgba(5,5,5,0.9), rgba(5,5,5,0.5));
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-width: 0;
    z-index: 30;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.glass-menu {
    position: absolute;
    top: 50px;
    right: 40px;
    width: 170px;
    background: rgba(15, 15, 15, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--accent);
    box-shadow: 0 10px 40px rgba(0,0,0,0.8), 0 0 20px rgba(74, 222, 128, 0.1);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 200;
    transform: translateY(0);
    opacity: 1;
    transition: opacity 0.2s, transform 0.2s;
}

.glass-menu.hidden {
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
}

.color-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.color-swatch {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.color-swatch:hover {
    transform: scale(1.2);
    box-shadow: 0 0 10px rgba(255,255,255,0.2);
    border-color: rgba(255, 255, 255, 0.8);
}

.hex-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--glass-border-light);
    border-radius: 6px;
    padding: 6px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    text-align: center;
    outline: none;
    text-transform: uppercase;
}
.hex-input:focus {
    border-color: var(--accent);
}

.sound-settings {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--glass-border-light);
}

.sound-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    cursor: pointer;
}

.sound-toggle input {
    accent-color: var(--text-primary);
}

.menu-action {
    width: 100%;
    min-height: 30px;
    border-radius: 6px;
    border: 1px solid var(--glass-border-light);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

.menu-action:hover {
    background: rgba(255, 255, 255, 0.1);
}

.header-titles {
    display: flex;
    flex-direction: column;
}

.header-titles h2 {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.room-hash {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

.status-indicator {
    width: 6px;
    height: 6px;
    background: #4ade80;
    border-radius: 50%;
    box-shadow: 0 0 10px #4ade80;
    animation: pulse 3s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); opacity: 0.8; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.8; }
}

.icon-btn {
    background: transparent;
    color: var(--text-secondary);
    width: 44px;
    height: 44px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    border-radius: 12px;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.primary-icon {
    color: var(--text-primary);
}
.primary-icon:hover {
    background: rgba(255, 255, 255, 0.1);
}

.messages-container {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
    mask-image: linear-gradient(to bottom, transparent, black 4%, black 96%, transparent);
    -webkit-mask-image: linear-gradient(to bottom, transparent, black 4%, black 96%, transparent);
}

.messages-container::-webkit-scrollbar {
    width: 2px;
}
.messages-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
}

.system-msg {
    align-self: center;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin: 20px 0;
    opacity: 0.5;
}

.msg {
    max-width: 85%;
    min-width: 0;
    padding: 12px 16px;
    font-size: 0.95rem;
    line-height: 1.5;
    word-break: break-word;
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    border-radius: 8px;
    font-family: var(--font-mono);
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    position: relative;
    transition: all 0.3s ease;
}

/* User Identity */
.msg-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 0.75rem;
    font-family: var(--font-mono);
    opacity: 0.9;
}

.msg-name {
    font-weight: 500;
    display: flex;
    align-items: center;
}

.edit-dot {
    width: 6px;
    height: 6px;
    background: var(--danger);
    border-radius: 50%;
    margin-left: 6px;
    box-shadow: 0 0 6px var(--danger);
    animation: neonPulse 2s infinite alternate;
}
@keyframes neonPulse {
    from { opacity: 0.5; box-shadow: 0 0 2px var(--danger); }
    to { opacity: 1; box-shadow: 0 0 8px var(--danger); }
}

.msg {
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.msg.msg-selected {
    background: rgba(74, 222, 128, 0.15);
    border-color: var(--accent);
    transform: scale(0.98);
}

#selection-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(15, 15, 15, 0.9);
    border: 1px solid var(--accent);
    box-shadow: 0 0 20px rgba(74, 222, 128, 0.1);
    border-radius: 12px;
    padding: 10px 16px;
    justify-content: space-between;
}
#selection-bar.hidden {
    display: none;
}
#selection-count {
    flex: 1;
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--accent);
    text-align: center;
}
.selection-actions {
    display: flex;
    gap: 8px;
}
.danger-icon {
    color: var(--danger) !important;
}
.danger-icon:hover {
    background: rgba(239, 68, 68, 0.15) !important;
}

.quote-block {
    margin-bottom: 8px;
    padding: 6px 10px;
    border-left: 3px solid;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.2s;
    text-align: left;
}
.quote-block:hover {
    background: rgba(0, 0, 0, 0.4);
}
.quote-author {
    font-weight: 500;
    margin-bottom: 2px;
    font-size: 0.75rem;
}
.quote-text {
    opacity: 0.8;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.highlight-pulse {
    animation: pulseMsg 1.5s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes pulseMsg {
    0% { transform: scale(1); box-shadow: 0 4px 20px rgba(0,0,0,0.2); }
    30% { transform: scale(1.02); box-shadow: 0 0 20px rgba(74, 222, 128, 0.5); border-color: rgba(74, 222, 128, 0.8); }
    100% { transform: scale(1); box-shadow: 0 4px 20px rgba(0,0,0,0.2); }
}

.msg-deleted {
    animation: disintegrate 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    pointer-events: none;
}

@keyframes disintegrate {
    0% { opacity: 1; transform: scale(1); filter: blur(0); }
    100% { opacity: 0; transform: scale(0.95); filter: blur(8px); margin: 0; padding: 0; height: 0; }
}

@keyframes slideUp {
    0% { opacity: 0; transform: translateY(10px); }
    100% { opacity: 1; transform: translateY(0); }
}

.msg-out {
    align-self: flex-end;
    background: var(--msg-out);
    border: 1px solid var(--glass-border);
    border-right: 2px solid var(--text-secondary);
    text-align: right;
}

.msg-out .msg-header {
    justify-content: flex-end;
}

.msg-in {
    align-self: flex-start;
    background: var(--msg-in);
    border: 1px solid var(--glass-border);
    border-left: 2px solid var(--text-secondary);
}

.msg-img {
    max-width: 100%;
    border-radius: 4px;
    margin-top: 8px;
    display: block;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    border: 1px solid var(--glass-border);
    transition: transform 0.3s ease;
}

.msg-img:active {
    transform: scale(0.98);
}

.msg-audio {
    display: block;
    width: min(280px, 100%);
    margin-top: 8px;
    filter: invert(1) grayscale(1);
    opacity: 0.86;
}

.msg-video {
    display: block;
    width: min(360px, 100%);
    max-height: 52dvh;
    margin-top: 8px;
    border-radius: 6px;
    border: 1px solid var(--glass-border);
    background: #000;
}

.media-box {
    width: 100%;
    min-width: 210px;
    padding: 10px;
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.2);
    text-align: left;
}

.media-carousel {
    width: min(380px, 100%);
    max-width: 100%;
    margin-top: 8px;
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 4px;
}

.media-carousel::-webkit-scrollbar {
    height: 2px;
}

.media-carousel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
}

.media-carousel-item {
    position: relative;
    flex: 0 0 min(340px, 92%);
    scroll-snap-align: start;
}

.media-count {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 3px 7px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.55);
    color: var(--text-primary);
    font-size: 0.72rem;
    font-family: var(--font-mono);
    pointer-events: none;
}

.media-label {
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.78rem;
}

.media-open {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 6px;
    border: 1px solid var(--glass-border-light);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    text-decoration: none;
}

.media-open:disabled {
    cursor: wait;
    opacity: 0.6;
}

#voice-btn.is-recording {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.14);
    box-shadow: 0 0 18px rgba(239, 68, 68, 0.24);
}

#voice-btn.is-recording::after {
    content: "";
    position: absolute;
    top: 8px;
    right: 8px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--danger);
    box-shadow: 0 0 8px var(--danger);
}

.image-viewer {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.94);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.2s ease;
    overscroll-behavior: contain;
}

.image-viewer.hidden {
    opacity: 0;
    pointer-events: none;
}

.image-viewer-stage {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.image-viewer-stage:active {
    cursor: grabbing;
}

.image-viewer-img {
    max-width: calc(100vw - 24px);
    max-height: calc(100dvh - 24px);
    object-fit: contain;
    transform-origin: center center;
    will-change: transform;
    user-select: none;
    -webkit-user-select: none;
    pointer-events: none;
}

.image-viewer-close {
    position: fixed;
    top: max(14px, env(safe-area-inset-top));
    right: max(14px, env(safe-area-inset-right));
    z-index: 1001;
    min-width: 46px;
    height: 46px;
    padding: 0 14px;
    gap: 8px;
    border-radius: 999px;
    background: rgba(20, 20, 20, 0.82);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-ui);
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.45);
}

.image-viewer-close span:first-child {
    font-size: 30px;
    line-height: 0.8;
    margin-top: -2px;
}

.image-viewer-close:active {
    transform: scale(0.94);
}

.glass-footer {
    padding: 20px 24px;
    background: linear-gradient(to top, rgba(5,5,5,0.95), rgba(5,5,5,0.5));
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-top: 1px solid var(--glass-border);
    min-width: 0;
}

.input-container {
    display: flex;
    align-items: flex-end;
    min-width: 0;
    max-width: 100%;
    gap: 8px;
    background: rgba(15, 15, 15, 0.8);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 6px 6px;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.input-container:focus-within {
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.05);
}

.input-stack {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

#reply-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 30px 8px 12px;
    position: relative;
    border-left: 3px solid var(--accent);
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    margin-bottom: 8px;
    font-size: 0.8rem;
    font-family: var(--font-mono);
}

#reply-preview.hidden {
    display: none;
}

.reply-content {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 100%;
}

#reply-name {
    font-weight: 500;
    color: var(--accent);
    margin-bottom: 2px;
}

#reply-text {
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#attachment-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 8px 0 8px;
    width: fit-content;
    position: relative;
    transition: all var(--transition);
}

#attachment-preview.hidden {
    display: none;
}

#preview-img {
    height: 60px;
    border-radius: 6px;
    border: 1px solid var(--glass-border-light);
    object-fit: cover;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

#preview-img.hidden,
#preview-audio.hidden,
#preview-file.hidden {
    display: none;
}

#preview-audio {
    width: min(260px, 68vw);
    height: 38px;
    filter: invert(1) grayscale(1);
    opacity: 0.86;
}

#preview-file {
    max-width: 260px;
    padding: 8px 32px 8px 10px;
    border-radius: 6px;
    border: 1px solid var(--glass-border-light);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.remove-btn {
    position: absolute;
    top: 4px;
    right: 0px;
    background: rgba(239, 68, 68, 0.8);
    color: white;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

.remove-btn:hover {
    background: rgba(239, 68, 68, 1);
    transform: scale(1.1);
}

.input-wrapper {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: flex-start;
    background: transparent;
    padding: 10px 0;
    gap: 8px;
}

.prompt-symbol {
    font-family: var(--font-mono);
    color: var(--text-secondary);
    user-select: none;
    line-height: 1.5;
}

#message-input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.95rem;
    resize: none;
    max-height: 150px;
    outline: none;
    line-height: 1.5;
}

#message-input::placeholder {
    color: var(--text-secondary);
}

/* Loader */
#loader {
    justify-content: center;
    align-items: center;
    background: var(--bg-base);
}

.terminal-loader {
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.cursor {
    width: 8px;
    height: 16px;
    background: var(--text-secondary);
    animation: blink 1s step-end infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Toast */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px) scale(0.9);
    background: rgba(30, 30, 30, 0.9);
    border: 1px solid var(--glass-border-light);
    color: var(--text-primary);
    font-family: var(--font-mono);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.85rem;
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 100;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    backdrop-filter: blur(10px);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
}

@media (max-width: 600px) {
    html,
    body {
        position: fixed;
        inset: 0;
        height: 100dvh;
        overflow: hidden;
    }

    body {
        align-items: stretch;
        justify-content: flex-start;
        width: 100vw;
        max-width: 100vw;
    }

    .app-container {
        position: fixed;
        inset: 0;
        width: var(--app-width, 100vw);
        height: var(--app-height, 100dvh);
        min-width: 0;
        max-width: 100%;
        border-radius: 0;
        overflow: hidden;
    }

    .glass-panel {
        border: none;
        border-radius: 20px;
        padding: 40px 24px;
        background: rgba(18, 18, 18, 0.6);
    }

    .glass-panel h1 {
        font-size: 1.75rem;
    }

    .glass-header {
        padding: max(10px, env(safe-area-inset-top)) 10px 8px;
        min-height: 58px;
    }

    .header-info {
        min-width: 0;
        gap: 10px;
    }

    .header-titles {
        min-width: 0;
    }

    .header-titles h2 {
        font-size: 0.9rem;
    }

    .room-hash {
        max-width: 42vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .header-actions {
        flex-shrink: 0;
        gap: 0;
    }

    .icon-btn {
        width: 38px;
        height: 38px;
        border-radius: 10px;
    }

    .glass-menu {
        right: 8px;
        top: 46px;
    }

    .messages-container {
        padding: 12px 10px;
        gap: 10px;
        mask-image: none;
        -webkit-mask-image: none;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .msg {
        max-width: 94%;
        min-width: 0;
        padding: 10px 12px;
        font-size: 0.9rem;
        line-height: 1.45;
    }

    .media-carousel {
        width: 100%;
        max-width: 100%;
    }

    .media-carousel-item {
        flex-basis: min(300px, 88vw);
        max-width: 88vw;
    }

    .media-box {
        min-width: 0;
    }

    .msg-img {
        max-height: 46dvh;
        object-fit: contain;
        min-width: 0;
    }

    .image-viewer {
        background: rgba(0, 0, 0, 0.97);
    }

    .image-viewer-img {
        max-width: 100vw;
        max-height: 100dvh;
    }

    .image-viewer-close {
        top: max(10px, env(safe-area-inset-top));
        right: max(10px, env(safe-area-inset-right));
        height: 44px;
        min-width: 44px;
        padding: 0 12px;
        background: rgba(28, 28, 28, 0.92);
        border-color: rgba(255, 255, 255, 0.28);
    }

    .glass-footer {
        padding: 10px 10px max(10px, env(safe-area-inset-bottom));
    }

    .input-container {
        gap: 4px;
        padding: 4px;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .input-wrapper {
        padding: 8px 0;
        gap: 6px;
    }

    #message-input {
        font-size: 16px;
        max-height: 120px;
    }

    #selection-bar {
        padding: 8px 10px;
        gap: 4px;
    }

    #selection-count {
        font-size: 0.82rem;
    }

    .toast {
        width: calc(100% - 32px);
        bottom: max(88px, calc(72px + env(safe-area-inset-bottom)));
        padding: 11px 14px;
        text-align: center;
    }
}
