/* ============================================
   PrivyChat — Minimal Dark Theme
   ============================================ */

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-0: #000000;
    --bg-1: #050505;
    --bg-2: #0a0a0a;
    --bg-3: #101010;
    --bg-4: #171717;
    --bg-5: #1f1f1f;
    --bg-6: #282828;

    --text-1: #f5f5f5;
    --text-2: #b0b0b0;
    --text-3: #707070;
    --text-4: #404040;

    --border-1: #151515;
    --border-2: #1f1f1f;
    --border-3: #2c2c2c;

    --accent: #ffffff;
    --accent-dim: rgba(255, 255, 255, 0.05);
    --accent-hover: rgba(255, 255, 255, 0.08);

    --green: #4ade80;
    --green-dim: rgba(74, 222, 128, 0.1);
    --red: #f87171;
    --red-dim: rgba(248, 113, 113, 0.08);
    --amber: #fbbf24;
    --amber-dim: rgba(251, 191, 36, 0.08);

    --msg-mine: #0d0d0d;
    --msg-mine-border: #1a1a1a;
    --msg-other: #080808;
    --msg-other-border: #141414;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.6);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.7);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.8);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-full: 9999px;

    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

    --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
    --duration: 0.2s;

    --header-h: 54px;
    --footer-h: 36px;
    --sidebar-w: 320px;
}

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font);
    background: #000;
    color: var(--text-1);
    line-height: 1.5;
    min-height: 100vh;
    overflow: hidden;
}

a {
    color: var(--text-1);
    text-decoration: none;
    transition: opacity var(--duration) var(--ease);
}

a:hover {
    opacity: 0.7;
}

::selection {
    background: #fff;
    color: #000;
}

::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-5);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-4);
}

/* === LAYOUT === */

.app-wrapper {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* === HEADER === */

.app-header {
    height: var(--header-h);
    background: var(--bg-1);
    border-bottom: 1px solid var(--border-1);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 14px;
    flex-shrink: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-shrink: 0;
}

.logo-icon {
    color: var(--text-2);
    display: flex;
    align-items: center;
}

.logo-icon svg,
.logo-icon i {
    width: 20px;
    height: 20px;
    stroke-width: 1.8;
}

.logo-text {
    font-size: 1.15rem;
    font-weight: 600;
    color: #fff;
    letter-spacing: -0.5px;
}

.header-tagline {
    color: var(--text-4);
    font-size: 0.78rem;
    padding-left: 14px;
    border-left: 1px solid var(--border-2);
    display: none;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    font-weight: 500;
}

@media (min-width: 768px) {
    .header-tagline {
        display: block;
    }
}

/* === Mobile UX tweaks: prevent accidental text selection/copy === */
.sidebar .chat-item,
.chat-area .message .msg-bubble,
.chat-area .msg-text,
.chat-area .msg-file-link,
.chat-area .msg-reply-preview {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    touch-action: manipulation;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

/* === FOOTER === */

.app-footer {
    height: var(--footer-h);
    background: var(--bg-1);
    border-top: 1px solid var(--border-1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-shrink: 0;
    padding: 0 16px;
    z-index: 100;
}

.footer-brand {
    font-weight: 600;
    font-size: 0.72rem;
    color: var(--text-3);
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.footer-sep {
    color: var(--border-3);
    font-size: 0.5rem;
}

.footer-text {
    color: var(--text-4);
    font-size: 0.72rem;
}

/* === MAIN === */

.app-main {
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* === BUTTONS === */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1px solid var(--border-2);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--duration) var(--ease);
    white-space: nowrap;
    text-decoration: none;
    background: transparent;
    color: var(--text-2);
    line-height: 1;
}

.btn:hover {
    text-decoration: none;
    background: var(--accent-hover);
    border-color: var(--border-3);
    color: var(--text-1);
}

.btn svg,
.btn i {
    width: 15px;
    height: 15px;
    stroke-width: 1.8;
    flex-shrink: 0;
}

.btn-primary {
    background: #fff;
    color: #000;
    border: 1px solid #fff;
    font-weight: 600;
}

.btn-primary:hover {
    background: #d4d4d4;
    border-color: #d4d4d4;
    color: #000;
}

.btn-primary:active {
    background: #a3a3a3;
}

.btn-block {
    width: 100%;
    justify-content: center;
    padding: 11px 16px;
    font-size: 0.9rem;
}

.btn-logout {
    color: var(--red);
    border-color: var(--red-dim);
}

.btn-logout:hover {
    background: var(--red-dim);
    border-color: rgba(248, 113, 113, 0.25);
    color: var(--red);
}

.btn-support {
    color: var(--amber);
    border-color: var(--amber-dim);
}

.btn-support:hover {
    background: var(--amber-dim);
    border-color: rgba(251, 191, 36, 0.25);
    color: var(--amber);
}

.btn-donate {
    background: #fff;
    color: #000;
    border: none;
    padding: 13px 24px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    width: 100%;
    justify-content: center;
}

.btn-donate:hover {
    background: #d4d4d4;
    color: #000;
}

/* === FORM === */

.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-3);
    font-size: 0.78rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 12px;
    z-index: 1;
    pointer-events: none;
    color: var(--text-4);
    display: flex;
    align-items: center;
}

.input-icon svg,
.input-icon i {
    width: 16px;
    height: 16px;
    stroke-width: 1.8;
}

.form-input {
    width: 100%;
    padding: 10px 14px 10px 38px;
    background: var(--bg-3);
    border: 1px solid var(--border-2);
    border-radius: var(--radius-sm);
    color: var(--text-1);
    font-family: var(--font);
    font-size: 0.9rem;
    transition: all var(--duration) var(--ease);
    outline: none;
}

.form-input::placeholder {
    color: var(--text-4);
}

.form-input:focus {
    border-color: var(--text-4);
    background: var(--bg-4);
}

.form-hint {
    display: block;
    margin-top: 4px;
    font-size: 0.72rem;
    color: var(--text-4);
}

.toggle-password {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--text-4);
    display: flex;
    align-items: center;
    transition: color var(--duration) var(--ease);
}

.toggle-password:hover {
    color: var(--text-2);
}

.toggle-password svg,
.toggle-password i {
    width: 16px;
    height: 16px;
    stroke-width: 1.8;
}

.password-strength {
    height: 2px;
    background: var(--bg-4);
    border-radius: var(--radius-full);
    margin-top: 8px;
    overflow: hidden;
}

.strength-bar {
    height: 100%;
    width: 0;
    border-radius: var(--radius-full);
    transition: all 0.3s var(--ease);
}

/* === ALERTS === */

.alert {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.85rem;
    line-height: 1.4;
}

.alert svg,
.alert i {
    width: 16px;
    height: 16px;
    stroke-width: 1.8;
    flex-shrink: 0;
}

.alert-error {
    background: var(--red-dim);
    border: 1px solid rgba(248, 113, 113, 0.2);
    color: var(--red);
}

.alert-success {
    background: var(--green-dim);
    border: 1px solid rgba(52, 211, 153, 0.2);
    color: var(--green);
}

.alert-link {
    color: inherit;
    font-weight: 600;
    margin-left: 6px;
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* === AUTH === */

.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--bg-2);
    border: 1px solid var(--border-1);
    border-radius: var(--radius-lg);
    padding: 32px 28px;
    box-shadow: var(--shadow-lg);
}

.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 6px;
}

.auth-logo-icon {
    color: var(--text-2);
    display: flex;
    align-items: center;
}

.auth-logo-icon svg,
.auth-logo-icon i {
    width: 28px;
    height: 28px;
    stroke-width: 1.5;
}

.auth-logo-text {
    font-size: 1.6rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.8px;
}

.auth-subtitle {
    text-align: center;
    color: var(--text-3);
    font-size: 0.85rem;
    margin-bottom: 24px;
}

.auth-form {
    margin-bottom: 18px;
}

.auth-footer {
    text-align: center;
    padding-top: 14px;
    border-top: 1px solid var(--border-1);
    margin-top: 6px;
}

.auth-footer p {
    color: var(--text-3);
    font-size: 0.85rem;
}

.auth-link {
    color: var(--text-1);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-color: var(--text-4);
}

.auth-link:hover {
    opacity: 1;
    text-decoration-color: var(--text-1);
}

.auth-info {
    display: flex;
    justify-content: center;
    gap: 18px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--text-4);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 500;
}

.info-item svg,
.info-item i {
    width: 13px;
    height: 13px;
    stroke-width: 1.8;
}

/* === CHAT LAYOUT === */

.chat-app {
    display: flex;
    height: 100%;
    overflow: hidden;
}

/* === SIDEBAR === */

.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--bg-1);
    border-right: 1px solid var(--border-1);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition:
        transform var(--duration) var(--ease),
        opacity var(--duration) var(--ease);
    z-index: 50;
}

.sidebar-header {
    padding: 12px;
    border-bottom: 1px solid var(--border-1);
    flex-shrink: 0;
}

.current-user {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    padding: 8px 10px;
    background: var(--bg-3);
    border-radius: var(--radius-sm);
}

.user-avatar-small {
    display: flex;
    align-items: center;
    color: var(--text-3);
}

.user-avatar-small svg,
.user-avatar-small i {
    width: 16px;
    height: 16px;
    stroke-width: 1.8;
}

.current-username {
    font-weight: 600;
    color: var(--text-1);
    font-size: 0.88rem;
}

.online-dot {
    width: 7px;
    height: 7px;
    background: var(--green);
    border-radius: 50%;
    margin-left: auto;
    flex-shrink: 0;
}

.search-box .form-input {
    padding-right: 34px;
    font-size: 0.85rem;
}

.search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-4);
    cursor: pointer;
    padding: 2px;
    line-height: 0;
    transition: color var(--duration) var(--ease);
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-clear:hover {
    color: var(--text-1);
}

.search-clear svg,
.search-clear i {
    width: 14px;
    height: 14px;
    stroke-width: 2;
}

/* === USER LIST === */

.user-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--duration) var(--ease);
    border: 1px solid transparent;
}

.user-item:hover {
    background: var(--bg-3);
    border-color: var(--border-2);
}

.user-item.active {
    background: var(--accent-dim);
    border-color: var(--border-3);
}

.user-avatar {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-4);
    border-radius: 50%;
    color: var(--text-3);
}

.user-avatar svg,
.user-avatar i {
    width: 18px;
    height: 18px;
    stroke-width: 1.8;
}

.user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-name {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-1);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-status {
    font-size: 0.72rem;
}

.user-status.online {
    color: var(--green);
}

.user-status.offline {
    color: var(--text-4);
}

/* === CHAT LIST ITEMS === */

.chat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--duration) var(--ease);
    border: 1px solid transparent;
}

.chat-item:hover {
    background: var(--bg-3);
    border-color: var(--border-2);
}

.chat-item.active {
    background: var(--accent-dim);
    border-color: var(--border-3);
}

.chat-item-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
    gap: 2px;
}

.chat-item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.chat-item-time {
    font-size: 0.68rem;
    color: var(--text-4);
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.chat-item-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.chat-item-preview {
    font-size: 0.78rem;
    color: var(--text-4);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1;
}

.chat-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #fff;
    color: #000;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: var(--radius-full);
    flex-shrink: 0;
    line-height: 1;
}

/* === EMPTY STATES === */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
}

.empty-icon {
    margin-bottom: 12px;
    color: var(--text-4);
    display: flex;
    align-items: center;
}

.empty-icon svg,
.empty-icon i {
    width: 32px;
    height: 32px;
    stroke-width: 1.2;
}

.empty-text {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 4px;
}

.empty-subtext {
    color: var(--text-4);
    font-size: 0.8rem;
}

/* === CHAT AREA === */

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

.chat-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-empty-content {
    text-align: center;
    padding: 40px 20px;
    max-width: 400px;
}

.chat-empty-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    color: var(--text-4);
}

.chat-empty-icon svg,
.chat-empty-icon i {
    width: 48px;
    height: 48px;
    stroke-width: 1;
}

.chat-empty-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 6px;
    letter-spacing: -0.5px;
}

.chat-empty-text {
    color: var(--text-3);
    font-size: 0.9rem;
    margin-bottom: 28px;
}

.chat-empty-features {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: var(--bg-2);
    border: 1px solid var(--border-1);
    border-radius: var(--radius-full);
    font-size: 0.78rem;
    color: var(--text-3);
    transition: all var(--duration) var(--ease);
}

.feature-item:hover {
    border-color: var(--border-3);
    color: var(--text-2);
}

.feature-item svg,
.feature-item i {
    width: 14px;
    height: 14px;
    stroke-width: 1.8;
}

/* === ACTIVE CHAT === */

.chat-active {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--bg-1);
    border-bottom: 1px solid var(--border-1);
    flex-shrink: 0;
    min-height: 50px;
}

.btn-back {
    display: none;
    background: none;
    border: 1px solid var(--border-2);
    color: var(--text-3);
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font);
    font-size: 0.8rem;
    transition: all var(--duration) var(--ease);
    align-items: center;
    gap: 4px;
}

.btn-back:hover {
    background: var(--bg-3);
    color: var(--text-1);
}

.btn-back svg,
.btn-back i {
    width: 14px;
    height: 14px;
    stroke-width: 2;
}

.chat-partner-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.partner-avatar {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-4);
    border-radius: 50%;
    flex-shrink: 0;
    color: var(--text-3);
}

.partner-avatar svg,
.partner-avatar i {
    width: 17px;
    height: 17px;
    stroke-width: 1.8;
}

.partner-details {
    display: flex;
    flex-direction: column;
}

.partner-name {
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--text-1);
}

.partner-status {
    font-size: 0.72rem;
}

.partner-status.online {
    color: var(--green);
}

.partner-status.offline {
    color: var(--text-4);
}

/* === MESSAGES === */

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-5) transparent;
}

.messages-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: auto;
}

.message {
    display: flex;
    max-width: 72%;
    animation: msgIn 0.2s var(--ease);
}

@keyframes msgIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.msg-mine {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.msg-other {
    align-self: flex-start;
}

.msg-bubble {
    padding: 8px 12px;
    border-radius: var(--radius-md);
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
    position: relative;
}

.msg-mine .msg-bubble {
    background: var(--msg-mine);
    border: 1px solid var(--msg-mine-border);
    border-bottom-right-radius: 3px;
}

.msg-other .msg-bubble {
    background: var(--msg-other);
    border: 1px solid var(--msg-other-border);
    border-bottom-left-radius: 3px;
}

.msg-sender {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-3);
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.msg-text {
    font-size: 0.9rem;
    line-height: 1.45;
    color: var(--text-1);
    white-space: pre-wrap;
}

.msg-time {
    font-size: 0.65rem;
    color: var(--text-4);
    margin-top: 3px;
    text-align: right;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

.msg-edited-badge {
    font-size: 0.6rem;
    color: var(--text-4);
    font-style: italic;
    font-weight: 400;
}

.msg-deleted-anim {
    opacity: 0;
    transform: scale(0.95);
    transition: all 0.35s var(--ease);
    max-height: 0;
    overflow: hidden;
    padding: 0;
    margin: 0;
}

.msg-highlight {
    animation: highlightPulse 1.5s var(--ease);
}

@keyframes highlightPulse {
    0% {
        background: rgba(255, 255, 255, 0.08);
    }
    50% {
        background: rgba(255, 255, 255, 0.12);
    }
    100% {
        background: transparent;
    }
}

/* === REPLY PREVIEW IN BUBBLE === */

.msg-reply-preview {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 6px 10px;
    margin-bottom: 6px;
    background: rgba(255, 255, 255, 0.04);
    border-left: 2px solid var(--text-4);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    cursor: pointer;
    transition: background var(--duration) var(--ease);
}

.msg-reply-preview:hover {
    background: rgba(255, 255, 255, 0.07);
}

.msg-reply-sender {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-2);
}

.msg-reply-text {
    font-size: 0.75rem;
    color: var(--text-3);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 220px;
}

.msg-temp-badge {
    font-size: 0.68rem;
    color: var(--amber);
    background: var(--amber-dim);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
    border: 1px solid rgba(251, 191, 36, 0.15);
}

.msg-temp-badge svg,
.msg-temp-badge i {
    width: 11px;
    height: 11px;
    stroke-width: 2;
}

.msg-deleted {
    opacity: 0;
    transform: scale(0.95);
    transition: all 0.3s var(--ease);
    max-height: 0;
    overflow: hidden;
    padding: 0;
    margin: 0;
}

/* File Messages */

.msg-file {
    margin-bottom: 4px;
}

.msg-image {
    max-width: 280px;
    max-height: 280px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: opacity var(--duration) var(--ease);
    display: block;
    object-fit: cover;
}

.msg-image:hover {
    opacity: 0.85;
}

.msg-video {
    max-width: 320px;
    max-height: 240px;
    border-radius: var(--radius-sm);
    display: block;
    background: #000;
}

.msg-audio {
    max-width: 280px;
    height: 40px;
    border-radius: var(--radius-sm);
    filter: invert(0.85) hue-rotate(180deg);
    opacity: 0.7;
}

.msg-file-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-4);
    border: 1px solid var(--border-2);
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-size: 0.85rem;
    transition: all var(--duration) var(--ease);
}

.msg-file-link:hover {
    background: var(--bg-5);
    border-color: var(--border-3);
    color: var(--text-1);
    opacity: 1;
}

.msg-file-link svg,
.msg-file-link i {
    width: 15px;
    height: 15px;
    stroke-width: 1.8;
    flex-shrink: 0;
}

.temp-viewed {
    opacity: 0.25;
    filter: blur(4px);
    pointer-events: none;
}

.temp-reveal-btn {
    background: var(--bg-4);
    border: 1px dashed var(--border-3);
    color: var(--text-3);
    padding: 16px 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font);
    font-size: 0.85rem;
    transition: all var(--duration) var(--ease);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
}

.temp-reveal-btn:hover {
    background: var(--bg-5);
    border-color: var(--text-4);
    color: var(--text-2);
}

.temp-reveal-btn svg,
.temp-reveal-btn i {
    width: 16px;
    height: 16px;
    stroke-width: 1.8;
}

/* Inline temp countdown shown in chat bubble after view */
.temp-countdown {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    color: var(--red);
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
}

.temp-countdown svg,
.temp-countdown i {
    width: 12px;
    height: 12px;
    stroke-width: 2;
}

/* === TYPING === */

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    color: var(--text-4);
    font-size: 0.78rem;
}

.typing-dots {
    display: inline-flex;
    gap: 3px;
}

.typing-dots span {
    width: 4px;
    height: 4px;
    background: var(--text-4);
    border-radius: 50%;
    animation: typDot 1.2s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes typDot {
    0%,
    60%,
    100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-3px);
    }
}

/* === REPLY BAR & EDIT BAR === */

.reply-bar,
.edit-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    margin-bottom: 6px;
    background: var(--bg-2);
    border: 1px solid var(--border-2);
    border-radius: var(--radius-sm);
    animation: slideUp 0.15s var(--ease);
}

.reply-bar-inner,
.edit-bar-inner {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
    color: var(--text-3);
}

.reply-bar-inner > svg,
.reply-bar-inner > i,
.edit-bar-inner > svg,
.edit-bar-inner > i {
    width: 14px;
    height: 14px;
    stroke-width: 1.8;
    flex-shrink: 0;
    color: var(--text-3);
}

.reply-bar-content {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.reply-bar-sender {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-2);
}

.reply-bar-text {
    font-size: 0.78rem;
    color: var(--text-4);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.edit-bar-label {
    font-size: 0.78rem;
    color: var(--text-3);
}

.reply-bar-close,
.edit-bar-close {
    background: none;
    border: 1px solid var(--border-2);
    color: var(--text-4);
    cursor: pointer;
    padding: 3px;
    border-radius: var(--radius-sm);
    transition: all var(--duration) var(--ease);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.reply-bar-close:hover,
.edit-bar-close:hover {
    background: var(--red-dim);
    border-color: rgba(248, 113, 113, 0.25);
    color: var(--red);
}

.reply-bar-close svg,
.reply-bar-close i,
.edit-bar-close svg,
.edit-bar-close i {
    width: 12px;
    height: 12px;
    stroke-width: 2;
}

/* === CONTEXT MENU === */

.msg-context-menu {
    position: fixed;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    min-width: 170px;
    background: var(--bg-2);
    border: 1px solid var(--border-3);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 4px;
    animation: fadeIn 0.12s var(--ease);
}

.ctx-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    background: none;
    border: none;
    color: var(--text-2);
    font-family: var(--font);
    font-size: 0.85rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--duration) var(--ease);
    text-align: left;
    width: 100%;
}

.ctx-item:hover {
    background: var(--accent-hover);
    color: var(--text-1);
}

.ctx-item svg,
.ctx-item i {
    width: 15px;
    height: 15px;
    stroke-width: 1.8;
    flex-shrink: 0;
}

.ctx-item.ctx-danger {
    color: var(--red);
}

.ctx-item.ctx-danger:hover {
    background: var(--red-dim);
    color: var(--red);
}

/* === CHAT INPUT === */

.chat-input-area {
    padding: 10px 14px;
    background: var(--bg-1);
    border-top: 1px solid var(--border-1);
    flex-shrink: 0;
}

.input-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-attach {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    background: var(--bg-3);
    border: 1px solid var(--border-2);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--duration) var(--ease);
    flex-shrink: 0;
    color: var(--text-3);
}

.btn-attach:hover {
    background: var(--bg-4);
    border-color: var(--border-3);
    color: var(--text-2);
}

.btn-attach svg,
.btn-attach i {
    width: 17px;
    height: 17px;
    stroke-width: 1.8;
    display: block;
}

.message-input-wrapper {
    flex: 1;
    min-width: 0;
}

.message-input {
    width: 100%;
    height: 36px;
    padding: 7px 12px;
    background: var(--bg-3);
    border: 1px solid var(--border-2);
    border-radius: var(--radius-sm);
    color: var(--text-1);
    font-family: var(--font);
    font-size: 0.9rem;
    resize: none;
    outline: none;
    line-height: 1.4;
    max-height: 120px;
    transition: border-color var(--duration) var(--ease);
    display: block;
}

.message-input::placeholder {
    color: var(--text-4);
}

.message-input:focus {
    border-color: var(--text-4);
}

.btn-send {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    background: #fff;
    border: none;
    border-radius: var(--radius-sm);
    color: #000;
    cursor: pointer;
    transition: all var(--duration) var(--ease);
    flex-shrink: 0;
}

.btn-send:hover {
    background: #d4d4d4;
}

.btn-send:active {
    background: #a3a3a3;
}

.btn-send svg,
.btn-send i {
    width: 17px;
    height: 17px;
    stroke-width: 2;
    display: block;
}

/* === FILE PREVIEW === */

.file-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: var(--bg-2);
    border: 1px solid var(--border-2);
    border-radius: var(--radius-md);
}

.file-preview-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.file-preview-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    background: var(--bg-4);
    border-radius: var(--radius-sm);
    color: var(--text-3);
}

.file-preview-icon svg,
.file-preview-icon i {
    width: 20px;
    height: 20px;
    stroke-width: 1.5;
}

.file-preview img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-2);
    flex-shrink: 0;
}

.file-preview video {
    width: 54px;
    height: 40px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-2);
    flex-shrink: 0;
}

.file-preview-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.file-preview-name {
    font-size: 0.82rem;
    color: var(--text-2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.3;
}

.file-preview-size {
    font-size: 0.7rem;
    color: var(--text-4);
    line-height: 1.3;
}

.file-preview-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.file-preview-remove {
    background: none;
    border: 1px solid var(--border-2);
    color: var(--text-4);
    cursor: pointer;
    padding: 5px;
    border-radius: var(--radius-sm);
    transition: all var(--duration) var(--ease);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}

.file-preview-remove:hover {
    background: var(--red-dim);
    border-color: rgba(248, 113, 113, 0.25);
    color: var(--red);
}

.file-preview-remove svg,
.file-preview-remove i {
    width: 14px;
    height: 14px;
    stroke-width: 2;
}

/* Temporary toggle — custom switch */

.temporary-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    flex-shrink: 0;
    user-select: none;
}

.temporary-toggle input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.temp-switch {
    position: relative;
    width: 34px;
    height: 18px;
    background: var(--bg-5);
    border-radius: var(--radius-full);
    border: 1px solid var(--border-3);
    transition: all var(--duration) var(--ease);
    flex-shrink: 0;
}

.temp-switch::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 12px;
    height: 12px;
    background: var(--text-4);
    border-radius: 50%;
    transition: all var(--duration) var(--ease);
}

.temporary-toggle input:checked + .temp-switch {
    background: var(--amber-dim);
    border-color: rgba(251, 191, 36, 0.35);
}

.temporary-toggle input:checked + .temp-switch::after {
    left: 18px;
    background: var(--amber);
}

.temp-label {
    font-size: 0.78rem;
    color: var(--text-3);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: color var(--duration) var(--ease);
}

.temporary-toggle input:checked ~ .temp-label {
    color: var(--amber);
}

.temp-label svg,
.temp-label i {
    width: 13px;
    height: 13px;
    stroke-width: 1.8;
    color: inherit;
}

/* === MODAL === */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    animation: fadeIn 0.15s var(--ease);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-card {
    background: var(--bg-2);
    border: 1px solid var(--border-2);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.2s var(--ease);
}

@keyframes slideUp {
    from {
        transform: translateY(12px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px 0;
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-1);
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-header h2 svg,
.modal-header h2 i {
    width: 18px;
    height: 18px;
    stroke-width: 1.8;
    color: var(--amber);
}

.modal-close {
    background: none;
    border: 1px solid var(--border-2);
    color: var(--text-4);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: all var(--duration) var(--ease);
    line-height: 1;
    display: flex;
    align-items: center;
}

.modal-close:hover {
    background: var(--red-dim);
    border-color: rgba(248, 113, 113, 0.25);
    color: var(--red);
}

.modal-close svg,
.modal-close i {
    width: 16px;
    height: 16px;
    stroke-width: 2;
}

.modal-body {
    padding: 18px 22px 24px;
}

.modal-text {
    color: var(--text-3);
    font-size: 0.88rem;
    line-height: 1.55;
    margin-bottom: 20px;
}

.donate-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.modal-small {
    color: var(--text-4);
    font-size: 0.78rem;
    text-align: center;
}

/* === TEMP VIEWER === */

.temp-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.97);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    cursor: pointer;
    animation: fadeIn 0.15s var(--ease);
}

.temp-viewer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    max-width: 90vw;
    max-height: 90vh;
}

.temp-badge {
    background: var(--amber-dim);
    border: 1px solid rgba(251, 191, 36, 0.2);
    color: var(--amber);
    padding: 6px 16px;
    border-radius: var(--radius-full);
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.temp-badge svg,
.temp-badge i {
    width: 14px;
    height: 14px;
    stroke-width: 1.8;
}

.temp-viewer img {
    max-width: 85vw;
    max-height: 70vh;
    border-radius: var(--radius-md);
    object-fit: contain;
}

.temp-viewer video {
    max-width: 85vw;
    max-height: 70vh;
    border-radius: var(--radius-md);
    background: #000;
}

.temp-timer {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
    background: rgba(255, 255, 255, 0.06);
    padding: 6px 20px;
    border-radius: var(--radius-full);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.temp-viewer audio {
    width: 340px;
    max-width: 85vw;
    height: 48px;
    border-radius: var(--radius-sm);
    filter: invert(0.9) hue-rotate(180deg);
}

.temp-file-view {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 22px 32px;
    background: var(--bg-3);
    border: 1px solid var(--border-3);
    border-radius: var(--radius-md);
    color: #fff;
    font-size: 1rem;
    cursor: default;
}

.temp-file-view svg,
.temp-file-view i {
    width: 28px;
    height: 28px;
    stroke-width: 1.4;
    color: var(--text-2);
    flex-shrink: 0;
}

.temp-close-hint {
    font-size: 0.72rem;
    color: var(--text-4);
    margin-top: 4px;
    letter-spacing: 0.02em;
}

.temp-viewed-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    color: var(--text-4);
    padding: 8px 12px;
    background: var(--bg-2);
    border: 1px solid var(--border-1);
    border-radius: var(--radius-sm);
    font-style: italic;
}

.temp-viewed-label svg,
.temp-viewed-label i {
    width: 13px;
    height: 13px;
    stroke-width: 1.8;
}

/* Inline temp media — shown in bubble after clicking "view" */
.temp-inline-media {
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 4px;
}

.temp-inline-media img {
    max-width: 260px;
    max-height: 240px;
    display: block;
    border-radius: var(--radius-sm);
    object-fit: cover;
}

.temp-inline-media video {
    max-width: 300px;
    max-height: 220px;
    display: block;
    border-radius: var(--radius-sm);
    background: #000;
}

.temp-inline-media audio {
    width: 260px;
    max-width: 100%;
    height: 36px;
    display: block;
    border-radius: var(--radius-sm);
    filter: invert(0.9) hue-rotate(180deg);
}

.temp-inline-media .temp-inline-file {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--bg-3);
    border: 1px solid var(--border-2);
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-size: 0.82rem;
}

.temp-inline-media .temp-inline-file svg,
.temp-inline-media .temp-inline-file i {
    width: 16px;
    height: 16px;
    stroke-width: 1.6;
    color: var(--text-3);
    flex-shrink: 0;
}

.temp-inline-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    padding: 5px 10px;
    background: rgba(248, 113, 113, 0.06);
    border: 1px solid rgba(248, 113, 113, 0.12);
    border-radius: var(--radius-full);
    width: fit-content;
}

.temp-inline-bar svg,
.temp-inline-bar i {
    width: 12px;
    height: 12px;
    stroke-width: 2;
    color: var(--red);
}

.temp-inline-bar span {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--red);
    font-variant-numeric: tabular-nums;
}

.temp-inline-progress {
    width: 60px;
    height: 3px;
    background: rgba(248, 113, 113, 0.15);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.temp-inline-progress-fill {
    height: 100%;
    background: var(--red);
    border-radius: var(--radius-full);
    transition: width 1s linear;
}

/* === RESPONSIVE === */

@media (max-width: 768px) {
    :root {
        --sidebar-w: 100%;
    }

    .chat-app {
        position: relative;
    }

    .sidebar {
        position: absolute;
        inset: 0;
        width: 100%;
        min-width: 100%;
        z-index: 60;
    }

    .sidebar.sidebar-hidden {
        transform: translateX(-100%);
        opacity: 0;
        pointer-events: none;
    }

    .btn-back {
        display: inline-flex;
    }

    .message {
        max-width: 88%;
    }

    .msg-image {
        max-width: 220px;
        max-height: 220px;
    }

    .msg-video {
        max-width: 260px;
    }

    .header-actions .btn-text {
        display: none;
    }

    .header-actions .btn {
        padding: 6px 8px;
    }

    .auth-card {
        padding: 24px 18px;
    }

    .auth-info {
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 14px;
    }

    /* Prevent iOS zoom on focus by ensuring >=16px font-size */
    .form-input,
    .message-input {
        font-size: 16px;
    }

    .app-header {
        padding: 0 12px;
    }

    .logo-text {
        font-size: 1.05rem;
    }

    .auth-logo-text {
        font-size: 1.4rem;
    }

    .modal-card {
        margin: 10px;
    }

    .modal-header {
        padding: 14px 16px 0;
    }

    .modal-body {
        padding: 14px 16px 20px;
    }
}
