#cdti-avatar-upload-wrapper {
    background: #f9f9f9;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 20px;
}

#cdti-avatar-upload-wrapper label {
    display: block;
    font-weight: 600;
    margin-bottom: 10px;
}

.cdti-upload-area {
    display: flex;
    align-items: center;
    gap: 15px;
}

#cdti-avatar-preview img {
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    display: block;
}

#cdti-upload-status {
    margin-top: 10px;
    font-size: 0.9em;
}

.cdti-cropper-modal-container {
    display: none !important;
    position: fixed;
    z-index: 999999;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    overflow: auto;
    background-color: rgba(0,0,0,0.8);
    align-items: center;
    justify-content: center;
}

.cdti-cropper-modal-container.cdti-modal-active {
    display: flex !important;
}

.cdti-plugin-addons-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    width: 100%;
    clear: both;
    grid-column: 1 / -1;
    margin-bottom: 15px;
}

.cdti-plugin-addons-container > div,
.cdti-plugin-addons-container > p {
    flex: 1 1 calc(50% - 20px);
    min-width: 250px;
    margin-bottom: 0 !important;
}

/* Ensure native fields are always on top of injected wrappers */
#commentform p.comment-form-author, 
#commentform p.comment-form-email, 
#commentform p.comment-form-url,
#commentform .comment-form-comment {
    position: relative !important;
    z-index: 100 !important;
}


/* Ensure our injected containers don't cover native fields accidentally */
.cdti-addons-wrapper, 
.cdti-avatar-upload-box, 
.cdti-footer-tools {
    position: relative !important;
    z-index: 10 !important;
    clear: both !important;
}

/* Fix mobile spacing and alignment */
@media (max-width: 768px) {
    .cdti-footer-tools {
        flex-direction: column;
    }
    .cdti-premium-block {
        width: 100% !important;
    }
}

/* ========================================================================
   Comment Actions Row (Like/Dislike/Report/Pin/Pick)
   ======================================================================== */
.cdti-comment-actions {
    margin-top: 10px;
    display: flex;
    gap: 15px;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.cdti-like-btn,
.cdti-pin-btn,
.cdti-pick-btn,
.cdti-report-btn {
    background: none;
    border: none;
    outline: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    font-weight: 600;
    transition: all 0.2s;
    box-shadow: none;
    padding: 4px 8px;
    border-radius: 4px;
}

.cdti-like-btn {
    color: #646970;
    gap: 6px;
    font-size: 13px;
}

.cdti-report-btn {
    color: #8c8f94;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
    padding: 4px;
}

.cdti-pin-btn,
.cdti-pick-btn {
    gap: 4px;
    font-size: 12px;
    padding: 4px;
}

.cdti-action-separator {
    border-left: 1px solid #ddd;
    height: 14px;
    margin: 0 5px;
}

.cdti-action-separator--narrow {
    border-left: 1px solid #ddd;
    height: 14px;
    margin: 0 2px;
}

/* ========================================================================
   Pinned & Editor's Pick Badges
   ======================================================================== */
.cdti-pinned-emoji {
    font-size: 18px !important;
    display: inline-block !important;
    vertical-align: middle !important;
    margin-right: 5px !important;
    cursor: default;
    background: none !important;
}

.cdti-editors-pick-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 3px 10px;
    border-radius: 4px;
    margin-bottom: 10px;
}

/* ========================================================================
   Comment Attachment Thumbnail
   ======================================================================== */
.cdti-attachment-wrap {
    margin-bottom: 15px;
}

.cdti-attachment-thumb {
    max-width: 150px;
    max-height: 150px;
    object-fit: cover;
    border-radius: 6px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    border: 2px solid #eaeaea;
    transition: transform 0.2s;
}

/* ========================================================================
   Gamification Badge — Image Type Override
   ======================================================================== */
.cdti-author-badge.cdti-img-badge {
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    height: 16px;
    width: auto;
}

.cdti-img-badge img {
    height: 16px;
    width: auto;
    border-radius: 2px;
    vertical-align: middle;
    display: inline-block;
}

/* ========================================================================
   Lightbox Modal
   ======================================================================== */
.cdti-lightbox-modal {
    display: none !important;
    position: fixed;
    z-index: 9999999;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    box-sizing: border-box;
}

.cdti-lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #fff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.cdti-lightbox-img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    object-fit: contain;
}

/* ========================================================================
   Frontend Cropper Modal
   ======================================================================== */
.cdti-cropper-modal {
    display: none !important;
    position: fixed;
    z-index: 999999;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.cdti-cropper-dialog {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    width: 400px;
    max-width: 100%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.cdti-cropper-title--front {
    margin-top: 0;
    font-size: 16px;
    font-weight: 600;
    color: #1d2327;
}

.cdti-cropper-canvas--front {
    width: 100%;
    height: 300px;
    background: #f0f0f1;
    border: 1px solid #dcd7ca;
    margin-bottom: 15px;
    position: relative;
}

.cdti-cropper-canvas--front img {
    max-width: 100%;
    display: block;
}

.cdti-cropper-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.cdti-cropper-cancel--front {
    padding: 6px 12px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    cursor: pointer;
    background: #f6f7f7;
    color: #333;
}

.cdti-cropper-save--front {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    background: var(--cdti-primary-color, #2271b1);
    color: #fff;
}

/* ========================================================================
   History Hub
   ======================================================================== */
.cdti-history-hub {
    width: 100%;
    margin-bottom: 15px;
    background: #fcfcfc;
    border: 1px solid #e1e1e1;
    border-radius: 6px;
    padding: 15px 20px;
    box-sizing: border-box;
}

.cdti-history-toggle {
    background: none;
    border: none;
    color: #d63638;
    font-weight: 800;
    font-size: 12px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    outline: none;
    padding: 0;
    transition: opacity 0.2s;
}

.cdti-history-drawer {
    display: none;
    margin-top: 15px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 5px;
    border-top: 1px solid #eaeaea;
    padding-top: 15px;
}

.cdti-history-loader {
    text-align: center;
    padding: 20px;
    color: #888;
    font-size: 13px;
    font-style: italic;
}

/* ========================================================================
   Avatar Upload Box — Frontend
   ======================================================================== */
.cdti-avatar-upload-box {
    margin-top: 0 !important;
    margin-bottom: 15px !important;
    padding: 15px 20px !important;
    background: #fcfcfc !important;
    border-radius: 6px !important;
    border: 1px solid #eaeaea !important;
    box-sizing: border-box !important;
    width: 100% !important;
    clear: both !important;
    grid-column: 1 / -1 !important;
}

.cdti-avatar-guest-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cdti-avatar-guest-icon {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    background: #e2e4e7;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #dcdcdc;
}

.cdti-avatar-guest-col {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.cdti-avatar-label {
    font-weight: 600;
    color: #3c434a;
    font-size: 13px;
    margin-bottom: 4px;
}

.cdti-avatar-login-link {
    font-size: 12px;
    font-weight: 600;
    color: var(--cdti-primary-color, #2271b1);
    text-decoration: none;
}

.cdti-avatar-flex-row {
    display: flex !important;
    align-items: flex-start !important;
    gap: 15px !important;
    flex-wrap: nowrap !important;
}

.cdti-avatar-thumb--front {
    width: 50px !important;
    height: 50px !important;
    min-width: 50px !important;
    min-height: 50px !important;
    max-width: 50px !important;
    max-height: 50px !important;
    border-radius: 6px;
    background: #f0f0f1;
    border: 1px solid #dcdcdc;
    overflow: hidden !important;
    flex-shrink: 0 !important;
}

.cdti-avatar-thumb--front img {
    width: 100% !important;
    height: 100% !important;
    max-width: 50px !important;
    max-height: 50px !important;
    object-fit: cover !important;
    border-radius: 6px !important;
}

.cdti-avatar-config-col--front {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-top: 2px;
}

.cdti-avatar-label--front {
    font-weight: 600;
    color: #3c434a;
    font-size: 13px;
    margin-bottom: 5px;
}

.cdti-avatar-trigger--front {
    font-size: 11px;
    font-weight: 700;
    color: #2271b1;
    cursor: pointer;
    text-transform: uppercase;
}

.cdti-avatar-remove-btn--front {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font-size: 11px;
    font-weight: 700;
    color: #d63638;
    cursor: pointer;
    text-transform: uppercase;
}

.cdti-avatar-input-hidden {
    position: absolute !important;
    left: -9999px !important;
    opacity: 0 !important;
    width: 1px !important;
    height: 1px !important;
}

.cdti-avatar-separator {
    color: #ccc;
    margin: 0 4px;
    font-size: 11px;
    user-select: none;
}

.cdti-upload-status--front {
    font-size: 11px;
    margin-top: 6px;
    font-weight: 600;
    color: #666;
}

/* ========================================================================
   Footer Tools Row (Attachment + CAPTCHA)
   ======================================================================== */
.cdti-footer-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    width: 100% !important;
    margin-bottom: 15px;
    box-sizing: border-box;
    grid-column: 1 / -1 !important;
    clear: both !important;
}

.cdti-attach-wrap {
    flex: 1 !important;
    min-width: 250px !important;
    margin: 0 !important;
    background: #fcfcfc !important;
    border: 1px solid #e1e1e1 !important;
    border-radius: 6px !important;
    padding: 12px 15px !important;
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    text-align: center !important;
}

.cdti-attach-header {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    font-weight: 700 !important;
    color: #555 !important;
    margin: 0 0 10px 0 !important;
    font-size: 13px !important;
    line-height: 1 !important;
    padding: 0 !important;
}

.cdti-attach-input {
    font-size: 13px !important;
    outline: none !important;
    display: inline-block !important;
    max-width: 100% !important;
    cursor: pointer !important;
    margin: 0 !important;
    padding: 0 !important;
}

.cdti-captcha-wrap {
    flex: 1 !important;
    min-width: 250px !important;
    margin: 0 !important;
    background: #fcfcfc !important;
    border: 1px solid #e1e1e1 !important;
    border-radius: 6px !important;
    padding: 12px 15px !important;
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    text-align: center !important;
}

.cdti-captcha-inner {
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* ========================================================================
   CAPTCHA Container & Prompts
   ======================================================================== */
.cdti-captcha-container {
    width: 100% !important;
    max-width: 100% !important;
    text-align: center !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

.cdti-honeypot-trap {
    position: absolute !important;
    left: -9999px !important;
    top: -9999px !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

#commentform label.cdti-captcha-prompt,
#commentform label.cdti-captcha-prompt--block,
.cdti-captcha-container label.cdti-captcha-prompt,
.cdti-captcha-container label.cdti-captcha-prompt--block,
.cdti-captcha-prompt {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    color: #333 !important;
    font-weight: bold !important;
    margin: 0 0 8px 0 !important;
    padding: 0 !important;
    font-size: 14px !important;
    line-height: 1.2 !important;
    height: auto !important;
    width: auto !important;
    clip: auto !important;
    position: static !important;
}

.cdti-captcha-prompt--block {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    color: #333 !important;
    font-weight: bold !important;
    margin: 0 0 8px 0 !important;
    padding: 0 !important;
    text-align: center !important;
    font-size: 14px !important;
    line-height: 1 !important;
}

.cdti-math-input {
    width: 120px !important;
    display: inline-block !important;
    text-align: center !important;
    margin: 0 !important;
    padding: 6px 12px !important;
}

.cdti-word-input {
    width: 100% !important;
    max-width: 300px !important;
    text-align: center !important;
    margin: 0 auto !important;
    display: block !important;
    padding: 6px 12px !important;
}

.cdti-api-scaler {
    margin: 0 auto;
    overflow: visible;
}

.cdti-api-scaler--recaptcha {
    width: 304px;
    height: 78px;
}

.cdti-api-scaler--turnstile {
    width: 300px;
    height: 65px;
}

.cdti-captcha-loading {
    text-align: center;
    padding: 10px;
    color: #999;
    font-size: 12px;
}

/* ========================================================================
   AJAX Handler — History List
   ======================================================================== */
.cdti-history-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.cdti-history-item {
    background: #fefefe;
    padding: 12px;
    margin-bottom: 10px;
    border-radius: 6px;
    border: 1px solid #eee;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.cdti-history-meta {
    font-size: 12px;
    color: #888;
    margin-bottom: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cdti-history-title {
    color: var(--cdti-primary-color, #2271b1);
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70%;
}

.cdti-history-excerpt {
    font-size: 14px;
    margin-bottom: 8px;
    color: #444;
    line-height: 1.4;
}

.cdti-history-link {
    font-size: 12px;
    text-decoration: none;
    font-weight: 600;
    display: inline-block;
}

.cdti-history-empty {
    padding: 15px;
    color: #666;
    text-align: center;
    font-style: italic;
}

/* ========================================================================
   Comment Sort Dropdown (JS-Injected)
   ======================================================================== */
.cdti-comment-sorter {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eaeaea;
}

.cdti-sort-label {
    font-weight: 700;
    color: #646970;
    margin-right: 12px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cdti-sort-dropdown {
    padding: 8px 14px;
    border-radius: 6px;
    border: 1px solid #dcdcdc;
    font-size: 14px;
    font-weight: 600;
    color: #2c3338;
    outline: none;
    cursor: pointer;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

/* ========================================================================
   CAPTCHA Validation Error (JS-Injected)
   ======================================================================== */
.cdti-captcha-error {
    color: #d63638;
    font-size: 14px;
    text-align: center;
    padding: 10px;
    border: 1px solid #d63638;
    background: #fff2f2;
    border-radius: 4px;
    margin-bottom: 15px;
    font-weight: 600;
}

/* ========================================================================
   Utility Classes (JS-Injected)
   ======================================================================== */
.cdti-text-danger {
    color: #d63638;
}

.cdti-history-error {
    color: #d63638;
    padding: 10px;
    text-align: center;
    font-size: 13px;
}