/* Ticket creation wizard + chat styles */

/* Custom scrollbar — subtle */
.tkt-chat-messages::-webkit-scrollbar {
    width: 4px;
}
.tkt-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.tkt-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
.tkt-chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}
[data-theme="light"] .tkt-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
}
[data-theme="light"] .tkt-chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Hide scrollbar on textareas */
.tkt-chat-textarea::-webkit-scrollbar,
.tkt-textarea::-webkit-scrollbar {
    display: none;
}
.tkt-chat-textarea,
.tkt-textarea {
    scrollbar-width: none; /* Firefox */
}

/* Ticket tabs (Active / Archive) */
.tkt-tabs {
    display: flex;
    gap: 0.3rem;
    margin-bottom: 16px;
}

.tkt-tab {
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.85rem;
    /* Keep font-weight constant across states — otherwise the active label
       grows wider and the sibling tab visibly shifts on switch. */
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}
[data-theme="light"] .tkt-tab {
    background: rgba(0, 0, 0, 0.03);
    color: rgba(0, 0, 0, 0.55);
}

.tkt-tab:hover {
    background: rgba(var(--color-orange-rgb), 0.08);
    border-color: rgba(var(--color-orange-rgb), 0.25);
    color: rgba(255, 255, 255, 0.85);
}

.tkt-tab.active {
    background: rgba(var(--color-orange-rgb), 0.15);
    border-color: rgba(var(--color-orange-rgb), 0.4);
    color: var(--color-orange);
}

/* Attach button (paperclip) */
.tkt-btn-attach {
    width: 42px;
    height: 42px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.tkt-btn-attach:hover {
    background: var(--bg-btn-hover);
    border-color: var(--border-hover);
}

.tkt-attach-icon {
    width: 20px;
    height: 20px;
    filter: var(--icon-filter);
    opacity: var(--icon-opacity);
    transition: var(--transition);
}

.tkt-btn-attach:hover .tkt-attach-icon {
    opacity: 1;
}

/* Attachments preview */
.tkt-attachments-preview {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 8px 0 0;
}

.tkt-attach-thumb {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
}

.tkt-attach-thumb img,
.tkt-attach-thumb video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tkt-attach-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    border: none;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* Attachment in message */
.tkt-msg-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.tkt-msg-attachments img,
.tkt-msg-attachments video {
    max-width: 240px;
    max-height: 180px;
    border-radius: 8px;
    object-fit: cover;
    cursor: pointer;
}

/* =============================================
   Create Ticket Modal
   ============================================= */
.tkt-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

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

.tkt-modal-content {
    background: rgba(20, 20, 22, 0.95);
    backdrop-filter: blur(30px) saturate(140%);
    -webkit-backdrop-filter: blur(30px) saturate(140%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
[data-theme="light"] .tkt-modal-content {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(0, 0, 0, 0.1);
}

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

.tkt-modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
[data-theme="light"] .tkt-modal-header {
    border-bottom-color: rgba(0, 0, 0, 0.06);
}

.tkt-modal-back,
.tkt-modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}
.tkt-modal-back:hover,
.tkt-modal-close:hover {
    background: rgba(var(--color-orange-rgb), 0.15);
    color: var(--color-orange);
}
.tkt-modal-close { font-size: 22px; }

/* Progress bar */
.tkt-progress {
    flex: 1;
    display: flex;
    gap: 6px;
    align-items: center;
}
.tkt-progress-step {
    flex: 1;
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    transition: all 0.3s;
}
[data-theme="light"] .tkt-progress-step {
    background: rgba(0, 0, 0, 0.08);
}
.tkt-progress-step.active {
    background: linear-gradient(90deg, var(--color-orange), var(--color-gold));
}

.tkt-modal-body {
    padding: 28px 24px;
    overflow-y: auto;
    flex: 1;
}

/* Steps with slide animation */
.tkt-modal-steps {
    position: relative;
}

.tkt-mstep {
    display: none;
    animation: stepIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.tkt-mstep.active {
    display: block;
}
.tkt-mstep.slide-back {
    animation: stepInBack 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes stepIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes stepInBack {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

.tkt-mstep-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 4px;
}

.tkt-mstep-text {
    font-size: 14px;
    color: var(--text-muted);
    margin: 0 0 20px;
}

/* FAQ links on first step */
.tkt-mstep-links {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
}

.tkt-mstep-link {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
}
[data-theme="light"] .tkt-mstep-link {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.08);
}
.tkt-mstep-link:hover {
    background: rgba(var(--color-orange-rgb), 0.08);
    border-color: rgba(var(--color-orange-rgb), 0.3);
    color: var(--text-primary);
}
.tkt-mstep-link img {
    width: 28px;
    height: 28px;
    filter: var(--icon-filter);
    opacity: var(--icon-opacity);
}
.tkt-mstep-link span {
    font-size: 13px;
    font-weight: 500;
}

/* Card-style options (for category) */
.tkt-card-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tkt-card-option {
    padding: 18px 20px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
[data-theme="light"] .tkt-card-option {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.08);
}
.tkt-card-option:hover {
    background: rgba(var(--color-orange-rgb), 0.08);
    border-color: rgba(var(--color-orange-rgb), 0.4);
    transform: translateX(4px);
}
.tkt-card-option::after {
    content: '→';
    color: var(--text-dim);
    transition: all 0.2s;
}
.tkt-card-option:hover::after {
    color: var(--color-orange);
    transform: translateX(4px);
}

/* Icon grid (platforms, apps) */
.tkt-icon-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.tkt-empty-error {
    grid-column: 1 / -1;
    padding: 24px 16px;
    text-align: center;
    background: rgba(248, 113, 113, 0.08);
    border: 1px solid rgba(248, 113, 113, 0.2);
    border-radius: 12px;
    color: #f87171;
    font-size: 13px;
    line-height: 1.5;
}

.tkt-icon-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}
[data-theme="light"] .tkt-icon-option {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.08);
}
.tkt-icon-option:hover {
    background: rgba(var(--color-orange-rgb), 0.08);
    border-color: rgba(var(--color-orange-rgb), 0.4);
    color: var(--text-primary);
    transform: translateY(-2px);
}
.tkt-icon-option img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    opacity: 0.95;
    transition: all 0.2s;
}
.tkt-icon-option:hover img {
    opacity: 1;
    transform: scale(1.05);
}

/* Platform icons — theme-adaptive (white in dark, black in light) */
#platform-options .tkt-icon-option img {
    filter: var(--icon-filter);
    opacity: 0.85;
}
#platform-options .tkt-icon-option:hover img {
    opacity: 1;
}

/* "Другое" icon — also theme-adaptive (uses generic instructions.svg with currentColor stroke) */
#app-options .tkt-icon-option[data-value="other"] img {
    filter: var(--icon-filter);
    opacity: 0.7;
}
#app-options .tkt-icon-option[data-value="other"]:hover img {
    opacity: 1;
}
.tkt-icon-option span {
    font-size: 12px;
    font-weight: 500;
}

/* Primary button (modal) */
.tkt-btn-primary {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, var(--color-orange), var(--color-gold));
    border: none;
    border-radius: 12px;
    color: #0a0a0a;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 20px rgba(var(--color-orange-rgb), 0.3);
    font-family: inherit;
}
.tkt-btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(var(--color-orange-rgb), 0.5);
}
.tkt-btn-primary:hover:not(:disabled) .tkt-btn-icon {
    transform: translateX(3px);
}
.tkt-btn-primary:active:not(:disabled) {
    transform: translateY(0);
}
.tkt-btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.tkt-btn-icon {
    width: 18px;
    height: 18px;
    filter: brightness(0);
    transition: transform 0.2s;
}

@media (max-width: 767px) {
    .tkt-modal {
        padding: 0 0 90px 0; /* leave space for bottom nav */
        align-items: flex-end;
    }
    .tkt-modal-content {
        max-height: calc(100vh - 110px);
        max-width: 100%;
        border-radius: 20px 20px 0 0;
        animation: slideUpMobile 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    @keyframes slideUpMobile {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }
    .tkt-modal-body {
        padding: 24px 20px;
    }
    .tkt-icon-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    .tkt-icon-option {
        padding: 14px 6px;
    }
    .tkt-icon-option img { width: 32px; height: 32px; }
    .tkt-icon-option span { font-size: 11px; }
}

/* Image preview modal */
.tkt-img-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    cursor: pointer;
}

.tkt-img-modal img {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    cursor: default;
}

.tkt-img-modal-close {
    position: fixed;
    top: 16px;
    right: 20px;
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 2001;
}

.tkt-img-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Drag-and-drop overlay */
.tkt-chat-wrap.drag-over {
    border-color: var(--color-orange);
    box-shadow: inset 0 0 40px rgba(var(--color-orange-rgb), 0.1);
}

.tkt-chat-wrap.drag-over::after {
    content: 'Перетащите файлы сюда';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    border-radius: 16px;
    color: var(--color-orange);
    font-size: 16px;
    font-weight: 600;
    z-index: 10;
    pointer-events: none;
}

.tkt-chat-wrap {
    position: relative;
}

/* Create button */
.tkt-btn-create {
    padding: 0.5rem 1.2rem;
    background: rgba(var(--color-orange-rgb), 0.15);
    border: 1px solid rgba(var(--color-orange-rgb), 0.4);
    border-radius: 10px;
    color: var(--color-orange);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.tkt-btn-create:hover {
    background: rgba(var(--color-orange-rgb), 0.25);
    border-color: rgba(var(--color-orange-rgb), 0.6);
}

.tkt-btn-create.disabled {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    cursor: pointer;
}
[data-theme="light"] .tkt-btn-create.disabled {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.08);
}
.tkt-btn-create.disabled:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
}
[data-theme="light"] .tkt-btn-create.disabled:hover {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.12);
}

/* Wizard steps */
.tkt-step {
    margin-top: 24px;
}

.tkt-step-label {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

/* Checkbox */
/* Custom animated checkbox */
.tkt-check {
    --tkt-check-size: 22px;
    --tkt-check-active: var(--color-orange);
    --tkt-check-idle: rgba(255, 255, 255, 0.15);
    display: inline-flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
    margin: 0;
    position: relative;
}

[data-theme="light"] .tkt-check {
    --tkt-check-idle: rgba(0, 0, 0, 0.15);
}

.tkt-check input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.tkt-check-box {
    position: relative;
    width: var(--tkt-check-size);
    height: var(--tkt-check-size);
    background: rgba(255, 255, 255, 0.04);
    border: 2px solid var(--tkt-check-idle);
    border-radius: 7px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

[data-theme="light"] .tkt-check-box {
    background: rgba(0, 0, 0, 0.03);
}

.tkt-check:hover .tkt-check-box {
    border-color: rgba(var(--color-orange-rgb), 0.4);
    transform: scale(1.05);
}

.tkt-check input:checked ~ .tkt-check-box {
    background: var(--tkt-check-active);
    border-color: var(--tkt-check-active);
    box-shadow: 0 4px 12px rgba(var(--color-orange-rgb), 0.35);
}

.tkt-check input:focus-visible ~ .tkt-check-box {
    outline: 3px solid rgba(var(--color-orange-rgb), 0.4);
    outline-offset: 2px;
}

.tkt-check input:active ~ .tkt-check-box {
    transform: scale(0.85);
}

.tkt-check-box svg {
    width: 70%;
    height: 70%;
    fill: none;
    stroke: #fff;
    stroke-width: 4;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 24;
    stroke-dashoffset: 24;
    transition: stroke-dashoffset 0.3s ease;
    transition-delay: 0.1s;
}

.tkt-check input:checked ~ .tkt-check-box svg {
    stroke-dashoffset: 0;
}

.tkt-check-label {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.tkt-check a {
    color: var(--color-orange);
}

/* Option buttons */
.tkt-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tkt-option {
    padding: 10px 20px;
    background: var(--bg-card);
    backdrop-filter: blur(20px) saturate(140%);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.tkt-option:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.tkt-option.selected {
    background: linear-gradient(135deg, rgba(var(--color-orange-rgb), 0.15), rgba(var(--color-gold-rgb), 0.15));
    border-color: rgba(var(--color-orange-rgb), 0.5);
    color: var(--text-primary);
}

/* Buttons */
.tkt-btn-next, .tkt-btn-submit {
    margin-top: 16px;
    padding: 12px 28px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.tkt-btn-next {
    background: rgba(var(--color-orange-rgb), 0.15);
    border: 1px solid rgba(var(--color-orange-rgb), 0.3);
    color: var(--text-primary);
}

.tkt-btn-next:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.tkt-btn-submit {
    background: linear-gradient(135deg, var(--color-orange), var(--color-gold));
    color: #fff;
    display: block;
    width: 100%;
}

.tkt-btn-submit:hover { opacity: 0.9; }
.tkt-btn-submit:disabled { opacity: 0.5; cursor: not-allowed; }

/* Textarea */
.tkt-textarea {
    width: 100%;
    padding: 14px;
    background: var(--bg-card);
    backdrop-filter: blur(20px) saturate(140%);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14px;
    resize: vertical;
    font-family: inherit;
    line-height: 1.5;
    margin-bottom: 8px;
    box-sizing: border-box;
}

.tkt-textarea:focus {
    outline: none;
    border-color: rgba(var(--color-orange-rgb), 0.4);
}

/* Ticket list cards (inside glass card) */
.tkt-list-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin-bottom: var(--space-2xs);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-sm);
}
[data-theme="light"] .tkt-list-item {
    background: rgba(0, 0, 0, 0.02);
}

.tkt-list-item:hover {
    border-color: var(--border-hover);
    background: var(--bg-card-hover);
}

.tkt-list-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

.tkt-list-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tkt-list-meta {
    font-size: 11px;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tkt-status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    border: 1px solid transparent;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}

/* Unified "in progress" — users never see the AI-vs-agent split */
.tkt-status-open, .tkt-status-ai_handling, .tkt-status-agent_handling {
    background: rgba(16, 185, 129, 0.14);
    border-color: rgba(16, 185, 129, 0.3);
    color: var(--success-fg);
}

.tkt-status-closed, .tkt-status-resolved {
    background: var(--bg-btn);
    border-color: var(--border-btn);
    color: var(--text-dim);
}

/* Chat wrapper — glassmorphism card */
.tkt-chat-wrap {
    background: var(--bg-card);
    backdrop-filter: blur(20px) saturate(140%);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
}

/* Chat */
.tkt-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-subtle);
}

.tkt-chat-messages {
    flex: 1;
    min-height: 250px;
    max-height: calc(100vh - 320px);
    overflow-y: auto;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px 4px 4px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}
[data-theme="light"] .tkt-chat-messages {
    scrollbar-color: rgba(0, 0, 0, 0.1) transparent;
}

.tkt-msg {
    position: relative;
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    overflow-wrap: break-word;
}

.tkt-msg-user {
    align-self: flex-end;
    background: linear-gradient(135deg, rgba(var(--color-orange-rgb), 0.25), rgba(var(--color-gold-rgb), 0.18));
    border: 1px solid rgba(var(--color-orange-rgb), 0.25);
    color: var(--text-primary);
    border-radius: 12px 12px 4px 12px;
}
[data-theme="light"] .tkt-msg-user {
    background: linear-gradient(135deg, rgba(var(--color-orange-rgb), 0.15), rgba(var(--color-gold-rgb), 0.1));
    border-color: rgba(var(--color-orange-rgb), 0.2);
}

.tkt-msg-support {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border-radius: 12px 12px 12px 4px;
}
[data-theme="light"] .tkt-msg-support {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.08);
}

.tkt-msg-system {
    align-self: center;
    background: transparent;
    color: var(--text-dim);
    font-size: 12px;
    text-align: center;
    font-style: italic;
}

.tkt-msg-time {
    font-size: 11px;
    color: var(--text-hint);
    margin-top: 4px;
    display: block;
}

/* Reply / quote (item 34) */
.tkt-msg-quote {
    display: flex;
    flex-direction: column;
    gap: 1px;
    margin-bottom: 6px;
    padding: 4px 8px;
    border-left: 3px solid var(--color-orange);
    border-radius: var(--radius-sm);
    background: rgba(var(--color-orange-rgb), 0.1);
    cursor: pointer;
    max-width: 100%;
}
.tkt-msg-quote:hover { background: rgba(var(--color-orange-rgb), 0.16); }
.tkt-msg-quote-author { font-size: 11px; font-weight: 700; color: var(--color-orange); }
.tkt-msg-quote-text {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.tkt-msg-reply {
    position: absolute;
    top: 2px;
    right: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: none;
    border-radius: var(--radius-full);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.12s ease, color 0.12s ease;
}
.tkt-msg:hover .tkt-msg-reply { opacity: 1; }
.tkt-msg-reply:hover { color: var(--color-orange); }
/* Touch devices have no hover — keep the affordance discoverable. */
@media (hover: none) {
    .tkt-msg-reply { opacity: 0.55; }
}

.tkt-msg-highlight { animation: tkt-msg-flash 1.5s ease; }
@keyframes tkt-msg-flash {
    0%, 30% { box-shadow: 0 0 0 2px var(--color-orange); }
    100% { box-shadow: 0 0 0 2px transparent; }
}

.tkt-reply-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 6px 10px;
    border-left: 3px solid var(--color-orange);
    border-radius: var(--radius-sm);
    background: rgba(var(--color-orange-rgb), 0.08);
}
.tkt-reply-bar-icon { display: flex; color: var(--color-orange); flex-shrink: 0; }
.tkt-reply-bar-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.tkt-reply-bar-author { font-size: 11px; font-weight: 700; color: var(--color-orange); }
.tkt-reply-bar-snippet {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tkt-reply-bar-cancel {
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    flex-shrink: 0;
}
.tkt-reply-bar-cancel:hover { color: var(--text-primary); }

/* Chat input */
.tkt-chat-input {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.tkt-chat-textarea {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-card);
    backdrop-filter: blur(20px) saturate(140%);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    line-height: 1.4;
    box-sizing: border-box;
}

.tkt-chat-textarea:focus {
    outline: none;
    border-color: rgba(var(--color-orange-rgb), 0.4);
}

.tkt-btn-send {
    width: 44px;
    height: 44px;
    border: none;
    background: linear-gradient(135deg, var(--color-orange), var(--color-gold));
    border-radius: 12px;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(var(--color-orange-rgb), 0.25);
}

.tkt-btn-send img {
    width: 20px;
    height: 20px;
    filter: brightness(0) invert(1);
    transition: transform 0.2s;
}

.tkt-btn-send:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(var(--color-orange-rgb), 0.35);
}

.tkt-btn-send:hover img {
    transform: translateX(2px);
}

.tkt-btn-send:active {
    transform: translateY(0);
}

.tkt-chat-closed {
    text-align: center;
    padding: 12px;
    color: var(--text-dim);
    font-size: 13px;
}

/* =============================================
   Mobile adaptations
   ============================================= */
@media (max-width: 767px) {
    .tkt-msg { max-width: 88%; }

    /* Hide mobile bottom nav when chat is open */
    body.chat-open .sup-mobile-nav-wrapper {
        display: none !important;
    }

    /* Chat takes full remaining height on mobile */
    body.chat-open .sup-container {
        padding-bottom: 16px;
    }

    .tkt-chat-wrap {
        border-radius: 12px;
        padding: 12px;
    }

    .tkt-chat-messages {
        min-height: 200px;
        max-height: calc(100vh - 230px);
        margin-bottom: 10px;
    }

    .tkt-chat-textarea {
        padding: 10px 12px;
        font-size: 15px; /* prevent iOS zoom */
    }

    .tkt-btn-send {
        width: 42px;
        height: 42px;
        border-radius: 10px;
        font-size: 16px;
    }

    .tkt-chat-input {
        gap: 6px;
    }

    .tkt-option {
        padding: 10px 14px;
        font-size: 13px;
    }

    .tkt-textarea {
        font-size: 15px; /* prevent iOS zoom */
    }

    .tkt-list-item {
        padding: 14px 16px;
    }

    .tkt-chat-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .tkt-chat-header h2 {
        font-size: 16px;
    }
}

/* Very small screens */
@media (max-width: 380px) {
    .tkt-options {
        gap: 6px;
    }
    .tkt-option {
        padding: 8px 12px;
        font-size: 12px;
    }
}

/* ========================================================================
   Markdown rendering inside chat bubbles (.tkt-msg-content).
   Used for AI / agent / user / system messages alike — Telegram-style.
   Whitelist: p, br, strong/b, em/i, code, pre, ul/ol/li, blockquote,
   a, del/s, hr, table. Headings (h1-h3) excluded by sanitizer.
   ======================================================================== */
.tkt-msg-content > *:first-child { margin-top: 0; }
.tkt-msg-content > *:last-child  { margin-bottom: 0; }
.tkt-msg-content p   { margin: 0 0 6px; }
.tkt-msg-content ul,
.tkt-msg-content ol  { margin: 4px 0 6px; padding-left: 20px; }
.tkt-msg-content li  { margin: 2px 0; }
.tkt-msg-content code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.9em;
    padding: 1px 4px;
    border-radius: 4px;
    background: rgba(127, 127, 127, 0.18);
}
.tkt-msg-content pre {
    margin: 6px 0;
    padding: 8px 10px;
    border-radius: 6px;
    background: rgba(127, 127, 127, 0.18);
    overflow-x: auto;
    max-height: 300px;
    font-size: 0.88em;
    line-height: 1.45;
}
.tkt-msg-content pre code { padding: 0; background: none; }
.tkt-msg-content blockquote {
    margin: 6px 0;
    padding: 4px 10px;
    border-left: 3px solid currentColor;
    opacity: 0.85;
}
.tkt-msg-content a {
    color: inherit;
    text-decoration: underline;
}
.tkt-msg-content strong, .tkt-msg-content b { font-weight: 600; }
.tkt-msg-content table {
    border-collapse: collapse;
    margin: 6px 0;
    font-size: 0.92em;
}
.tkt-msg-content th, .tkt-msg-content td {
    border: 1px solid rgba(127, 127, 127, 0.35);
    padding: 3px 6px;
}
