:root {
    --tlk-bg: #f2f6fb;
    --tlk-panel: #ffffff;
    --tlk-text: #0f172a;
    --tlk-muted: #64748b;
    --tlk-accent: #2563eb;
    --tlk-border: #e2e8f0;
}

.tlk-dark {
    --tlk-bg: #0f172a;
    --tlk-panel: #111827;
    --tlk-text: #e2e8f0;
    --tlk-muted: #94a3b8;
    --tlk-accent: #22b07d;
    --tlk-border: #1f2937;
}

.tlk-muted {
    color: var(--tlk-muted);
    font-size: 13px;
}

.tlk-app {
    font-family: "Segoe UI", Tahoma, sans-serif;
    background: var(--tlk-bg);
    border: 1px solid var(--tlk-border);
    border-radius: 20px;
    overflow: hidden;
    width: min(1200px, 96vw);
    margin: 2vh auto;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
    color: var(--tlk-text);
    display: flex;
    flex-direction: column;
}

.tlk-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-direction: column;
    padding: 18px 24px;
    background: var(--tlk-panel);
    border-bottom: 1px solid var(--tlk-border);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.05);
}

.tlk-app:not(.tlk-dark) .tlk-header {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(12px);
}

.tlk-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tlk-logo {
    height: 28px;
    max-width: 160px;
    object-fit: contain;
}

.tlk-brand-text {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--tlk-text);
}

.tlk-header-actions {
    display: flex;
    gap: 10px;
    width: 100%;
    flex-wrap: wrap;
}

.tlk-settings-toggle {
    border: 1px solid var(--tlk-border);
    background: transparent;
    color: var(--tlk-text);
    padding: 8px 12px;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 6px 14px rgba(37, 99, 235, 0.08);
}

.tlk-settings-panel {
    display: none;
    gap: 10px;
    flex-wrap: wrap;
    width: 100%;
}

.tlk-settings-panel.open {
    display: flex;
}

.tlk-settings-save {
    border: 1px solid var(--tlk-border);
    background: var(--tlk-accent);
    color: #fff;
    padding: 8px 12px;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.25);
}

.tlk-sidebar-toggle {
    border: 1px solid var(--tlk-border);
    background: transparent;
    color: var(--tlk-text);
    padding: 8px 12px;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 6px 14px rgba(37, 99, 235, 0.08);
}

.tlk-sidebar-toggle.active {
    background: rgba(37, 99, 235, 0.15);
    border-color: rgba(37, 99, 235, 0.35);
}

.tlk-mode-toggle {
    border: 1px solid var(--tlk-border);
    background: transparent;
    color: var(--tlk-text);
    padding: 8px 12px;
    border-radius: 999px;
    cursor: pointer;
}

.tlk-notify-toggle {
    border: 1px solid var(--tlk-border);
    background: transparent;
    color: var(--tlk-text);
    padding: 8px 12px;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 6px 14px rgba(37, 99, 235, 0.08);
}

.tlk-mark-read {
    border: 1px solid var(--tlk-border);
    background: transparent;
    color: var(--tlk-text);
    padding: 8px 12px;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 6px 14px rgba(37, 99, 235, 0.08);
}

.tlk-toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    background: var(--tlk-panel);
    color: var(--tlk-text);
    border: 1px solid var(--tlk-border);
    padding: 12px 14px;
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
    z-index: 9999;
}

.tlk-body {
    display: flex;
    flex: 1;
}

.tlk-sidebar {
    width: 320px;
    background: var(--tlk-panel);
    border-right: 1px solid var(--tlk-border);
    padding: 18px;
}

.tlk-app:not(.tlk-dark) .tlk-sidebar {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(12px);
}

.tlk-section-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--tlk-muted);
    margin: 18px 0 8px;
    font-weight: 700;
}

.tlk-list {
    display: grid;
    gap: 8px;
}

.tlk-search {
    width: 100%;
    padding: 14px 16px !important;
    border-radius: 12px;
    border: 1px solid var(--tlk-border);
    margin-bottom: 8px;
    font-size: 14px;
    line-height: 1.4;
    min-height: 44px;
    box-sizing: border-box;
}

.tlk-item {
    padding: 10px 12px;
    border-radius: 10px;
    background: #f8fafc;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    transition: background 0.2s ease, border 0.2s ease, transform 0.2s ease;
}

.tlk-item-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.tlk-item-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.tlk-item-name {
    font-weight: 600;
    color: var(--tlk-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tlk-item-sub {
    font-size: 11px;
    color: var(--tlk-muted);
}

.tlk-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--tlk-border);
    background: #fff;
    flex: 0 0 auto;
}

.tlk-avatar-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--tlk-muted);
    background: rgba(148, 163, 184, 0.18);
}

.tlk-dark .tlk-item {
    background: #0b1220;
}

.tlk-item.active {
    background: rgba(37, 99, 235, 0.12);
}

.tlk-item:hover {
    transform: translateY(-1px);
}

.tlk-item.tlk-unread {
    border: 1px solid var(--tlk-accent);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.tlk-badge {
    font-size: 11px;
    color: #fff;
    background: var(--tlk-accent);
    padding: 2px 6px;
    border-radius: 999px;
}

.tlk-contact-actions {
    display: flex;
    gap: 6px;
}

.tlk-contact-action {
    border: none;
    background: transparent;
    color: var(--tlk-muted);
    cursor: pointer;
    font-size: 11px;
    padding: 2px 6px;
}

.tlk-busy {
    opacity: 0.6;
    cursor: progress;
}

.tlk-chat-contact {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tlk-chat-contact .tlk-avatar {
    width: 40px;
    height: 40px;
}

.tlk-block-contact {
    color: #ef4444;
}

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

.tlk-chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--tlk-border);
    background: var(--tlk-panel);
    box-shadow: 0 8px 16px rgba(15, 23, 42, 0.04);
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 12px;
    align-items: center;
}

.tlk-app:not(.tlk-dark) .tlk-chat-header {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
}

.tlk-typing {
    font-size: 12px;
    color: var(--tlk-muted);
    margin-top: 2px;
}

.tlk-back {
    border: 1px solid var(--tlk-border);
    background: transparent;
    color: var(--tlk-text);
    padding: 8px 12px;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 700;
}

.tlk-message-search {
    max-width: 240px;
}

.tlk-delete-chat {
    border: 1px solid var(--tlk-border);
    background: #ef4444;
    color: #fff;
    padding: 8px 12px;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 10px 22px rgba(239, 68, 68, 0.2);
    font-weight: 700;
}

.tlk-messages {
    flex: 1;
    padding: 24px;
    overflow-y: visible;
    display: grid;
    gap: 12px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(242, 246, 251, 0.95));
}

.tlk-dark .tlk-messages {
    background: linear-gradient(180deg, rgba(17, 24, 39, 0.9), rgba(15, 23, 42, 0.95));
}

.tlk-input {
    display: flex;
    gap: 12px;
    padding: 16px 24px;
    background: var(--tlk-panel);
    border-top: 1px solid var(--tlk-border);
    box-shadow: 0 -8px 16px rgba(15, 23, 42, 0.04);
    align-items: flex-start;
    flex-wrap: wrap;
}

.tlk-app:not(.tlk-dark) .tlk-input {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(12px);
}

.tlk-input-card {
    border: 1px solid var(--tlk-border);
    border-radius: 16px;
    margin: 12px 16px 16px;
    background: rgba(255, 255, 255, 0.9);
}

.tlk-app.tlk-dark .tlk-input-card {
    background: var(--tlk-panel);
}

.tlk-footer {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 24px 14px;
    font-size: 12px;
    color: var(--tlk-muted);
    border-top: 1px solid var(--tlk-border);
    background: var(--tlk-panel);
    flex-wrap: wrap;
    line-height: 1.4;
    white-space: normal;
    word-break: break-word;
    z-index: 2;
}

.tlk-app:not(.tlk-dark) .tlk-footer {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(12px);
}

.tlk-input input,
.tlk-input textarea,
.tlk-input select {
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--tlk-border);
    background: var(--tlk-panel);
    color: var(--tlk-text);
    font-family: inherit;
}

.tlk-dark .tlk-input input,
.tlk-dark .tlk-input textarea,
.tlk-dark .tlk-input select {
    color: var(--tlk-text) !important;
    background: var(--tlk-panel) !important;
}

.tlk-dark .tlk-input input:focus,
.tlk-dark .tlk-input textarea:focus,
.tlk-dark .tlk-input select:focus {
    color: var(--tlk-text) !important;
    background: var(--tlk-panel) !important;
}

.tlk-input input::placeholder,
.tlk-input textarea::placeholder {
    color: var(--tlk-muted);
}

.tlk-message-box {
    flex: 1 1 100%;
    min-height: 64px;
    max-height: 220px;
    resize: none;
    overflow-y: auto;
    box-sizing: border-box;
    align-self: stretch;
}

.tlk-message-box-prominent {
    border: 2px solid rgba(37, 99, 235, 0.35);
    box-shadow: 0 12px 24px rgba(37, 99, 235, 0.12);
    background: rgba(255, 255, 255, 0.95);
    font-size: 15px;
}

.tlk-message-box-prominent:focus {
    border-color: rgba(37, 99, 235, 0.7);
    outline: none;
}

.tlk-expiry {
    padding: 8px 12px;
    border-radius: 12px;
    border: 1px solid var(--tlk-border);
    background: var(--tlk-panel);
    color: var(--tlk-text);
    min-height: 40px;
    font-weight: 600;
    box-sizing: border-box;
    min-width: 140px;
}

.tlk-file {
    max-width: 220px;
}

.tlk-upload {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tlk-upload-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tlk-upload-toggle {
    border: 1px solid var(--tlk-border);
    background: transparent;
    color: var(--tlk-text);
    padding: 8px 12px;
    border-radius: 999px;
    cursor: pointer;
    width: fit-content;
    min-height: 40px;
    font-weight: 600;
    min-width: 140px;
}

.tlk-upload-body {
    display: none;
    gap: 12px;
    flex-wrap: wrap;
}

.tlk-upload-body.open {
    display: flex;
}

.tlk-file-label {
    display: inline-block;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px dashed var(--tlk-border);
    background: rgba(37, 99, 235, 0.06);
    color: var(--tlk-text);
    font-size: 12px;
    cursor: pointer;
    width: fit-content;
}

.tlk-upload-hint {
    font-size: 12px;
    color: var(--tlk-muted);
}

.tlk-file-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(37, 99, 235, 0.08);
    color: var(--tlk-text);
    text-decoration: none;
}

.tlk-file-link:hover {
    background: rgba(37, 99, 235, 0.14);
}

.tlk-invite-btn {
    border: 1px solid var(--tlk-border);
    background: var(--tlk-accent);
    color: #fff;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    margin-bottom: 8px;
}

.tlk-enter-toggle {
    font-size: 12px;
    color: var(--tlk-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.tlk-message {
    max-width: 72%;
    padding: 14px 16px;
    border-radius: 16px;
    background: #ffffff;
    border: 1px solid var(--tlk-border);
    display: inline-block;
    color: var(--tlk-text);
    position: relative;
}

.tlk-message.own {
    margin-left: auto;
    background: rgba(37, 99, 235, 0.12);
    border-color: rgba(37, 99, 235, 0.2);
}

.tlk-meta {
    font-size: 11px;
    color: var(--tlk-muted);
    margin-top: 4px;
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.tlk-meta-left {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.tlk-sender {
    font-weight: 600;
    color: var(--tlk-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tlk-avatar-sm {
    width: 20px;
    height: 20px;
}

.tlk-time {
    font-size: 11px;
    color: var(--tlk-muted);
}

.tlk-seen {
    font-size: 11px;
    color: var(--tlk-accent);
    margin-left: 8px;
}

.tlk-date-sep {
    text-align: center;
    font-size: 12px;
    color: var(--tlk-muted);
    margin: 8px 0 4px;
}

.tlk-delete-message {
    border: none;
    background: transparent;
    color: var(--tlk-muted);
    cursor: pointer;
    font-size: 12px;
    padding: 2px 6px;
}

.tlk-message-actions {
    display: flex;
    gap: 6px;
    margin: 6px 0 0;
    flex-wrap: wrap;
}

.tlk-delete-both {
    color: #ef4444;
}

.tlk-message-text {
    font-size: 15px;
    line-height: 1.5;
}

.tlk-message-text a {
    color: var(--tlk-accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.tlk-message-text a:hover {
    opacity: 0.85;
}

.tlk-media img,
.tlk-media video,
.tlk-media audio {
    max-width: 100%;
    border-radius: 12px;
    margin-top: 8px;
}

.tlk-media img {
    max-height: 260px;
    object-fit: cover;
}

.tlk-media video {
    max-height: 280px;
}


.tlk-profile-card {
    padding: 16px;
    border: 1px solid var(--tlk-border);
    border-radius: 12px;
    background: var(--tlk-panel);
    color: var(--tlk-text);
    max-width: 420px;
}

.tlk-profile-avatar {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 12px;
}

.tlk-avatar-img {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--tlk-border);
    background: #fff;
}

.tlk-dark .tlk-message {
    background: #0f172a;
}

.tlk-send {
    background: var(--tlk-accent);
    color: #fff;
    border: none;
    padding: 12px 18px;
    border-radius: 14px;
    cursor: pointer;
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.25);
}

.tlk-accept {
    border: none;
    background: transparent;
    color: var(--tlk-accent);
    cursor: pointer;
}

.tlk-status {
    font-size: 12px;
    color: var(--tlk-muted);
}

.tlk-reactions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.tlk-reaction {
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.15);
    color: var(--tlk-text);
}

.tlk-reaction.active {
    background: rgba(37, 99, 235, 0.18);
    color: var(--tlk-accent);
}

.tlk-react-toggle {
    color: var(--tlk-muted);
    font-size: 16px;
    line-height: 1;
    padding: 6px 8px;
}


.tlk-react-corner .tlk-reaction-panel {
    background: var(--tlk-panel);
    border: 1px solid var(--tlk-border);
    border-radius: 12px;
    padding: 6px;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
}

.tlk-react-icon {
    display: inline-block;
    width: 18px;
    height: 18px;
    background: currentColor;
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M12.1 20.3l-.1.1l-.1-.1C7.1 16 4 13.2 4 9.7C4 7.4 5.7 5.5 8 5.5c1.5 0 3 .8 4 2c1-1.2 2.5-2 4-2c2.3 0 4 1.9 4 4.2c0 3.5-3.1 6.3-7.9 10.6z'/%3E%3C/svg%3E");
    mask-repeat: no-repeat;
    mask-position: center;
    mask-size: contain;
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M12.1 20.3l-.1.1l-.1-.1C7.1 16 4 13.2 4 9.7C4 7.4 5.7 5.5 8 5.5c1.5 0 3 .8 4 2c1-1.2 2.5-2 4-2c2.3 0 4 1.9 4 4.2c0 3.5-3.1 6.3-7.9 10.6z'/%3E%3C/svg%3E");
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
    -webkit-mask-size: contain;
    opacity: 0.7;
}

.tlk-reaction-panel {
    display: none;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.tlk-reaction-panel.open {
    display: flex;
}

@media (max-width: 900px) {
    .tlk-body {
        flex-direction: column;
    }

    .tlk-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--tlk-border);
    }

    .tlk-app {
        width: 100%;
        height: 100vh;
        margin: 0;
        border-radius: 0;
    }
}

@media (max-width: 600px) {
    .tlk-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 14px 16px;
    }

    .tlk-header-actions {
        flex-wrap: wrap;
        width: 100%;
        gap: 8px;
    }

    .tlk-header-actions button {
        flex: 1 1 100%;
        width: 100%;
        text-align: center;
        font-size: 13px;
    }

    .tlk-body {
        height: auto;
        flex: 1;
        overflow: visible;
    }

    .tlk-sidebar {
        padding: 12px 14px;
        max-height: none;
        overflow-y: visible;
    }

    .tlk-chat-header {
        padding: 12px 16px;
        grid-template-columns: auto 1fr;
    }

    .tlk-message-search {
        grid-column: 1 / -1;
        max-width: 100%;
    }

    .tlk-delete-chat {
        grid-column: 1 / -1;
        width: 100%;
    }

    .tlk-messages {
        padding: 16px;
    }

    .tlk-message {
        max-width: 100%;
    }

    .tlk-input {
        padding: 12px 16px;
        gap: 10px;
    }

    .tlk-message-box {
        min-height: 80px;
    }

    .tlk-file {
        max-width: 100%;
    }

    .tlk-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
        font-size: 11px;
        position: sticky;
        bottom: 0;
    }

    .tlk-app {
        height: auto;
        min-height: 100vh;
    }
}

@media (max-width: 900px) {
    .tlk-app.tlk-sidebar-hidden .tlk-sidebar {
        display: none;
    }

    .tlk-app.tlk-sidebar-hidden .tlk-chat {
        flex: 1;
    }
}
