.ztk-ai-summary {
    --ztk-summary-accent: var(--theme-color, #6888f5);
    --ztk-summary-accent-soft: var(--focus-color-opacity1, rgba(104, 136, 245, .13));
    --ztk-summary-shell: #f5f6f8;
    --ztk-summary-panel: #fff;
    --ztk-summary-text: #343b48;
    --ztk-summary-muted: #6f7784;
    --ztk-summary-border: rgba(56, 66, 87, .08);
    position: relative;
    isolation: isolate;
    overflow: visible;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    margin: 18px 0 28px;
    padding: 22px;
    border: 1px solid var(--ztk-summary-border);
    border-radius: 15px;
    color: var(--ztk-summary-text);
    background:
        radial-gradient(circle at 52% -18%, rgba(130, 158, 255, .14), transparent 26%),
        var(--ztk-summary-shell);
    box-shadow: 0 18px 46px -38px rgba(37, 47, 72, .55);
    transition: color .25s ease, background-color .25s ease, border-color .25s ease, box-shadow .25s ease;
}

body.dark-theme .ztk-ai-summary,
body.dark-mode .ztk-ai-summary,
html.dark-theme .ztk-ai-summary,
[data-theme="dark"] .ztk-ai-summary {
    --ztk-summary-accent: var(--theme-color, #8da2ff);
    --ztk-summary-accent-soft: var(--focus-color-opacity1, rgba(141, 162, 255, .16));
    --ztk-summary-shell: #1a1f29;
    --ztk-summary-panel: #242b37;
    --ztk-summary-text: #eef2fa;
    --ztk-summary-muted: rgba(229, 235, 247, .6);
    --ztk-summary-border: rgba(215, 225, 255, .1);
    box-shadow: 0 22px 54px -38px rgba(0, 0, 0, .9);
}

.ztk-ai-summary-head {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 76px minmax(0, 1fr);
    align-items: center;
    min-height: 34px;
    padding-bottom: 17px;
}

.ztk-ai-summary-head-copy {
    display: flex;
    grid-column: 1;
    flex: 1 1 auto;
    min-width: 0;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px 12px;
    padding-right: 0;
}

.ztk-ai-summary-title {
    color: var(--ztk-summary-text);
    font-size: 1.08em;
    font-weight: 800;
    line-height: 1.35;
    letter-spacing: .01em;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.ztk-ai-summary-subtitle {
    color: var(--ztk-summary-muted);
    font-size: .82em;
    line-height: 1.5;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.ztk-ai-summary-icon {
    position: absolute;
    z-index: 2;
    top: -39px;
    left: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 58px;
    box-sizing: border-box;
    border: 8px solid var(--ztk-summary-shell);
    border-radius: 50%;
    color: #fff;
    background: linear-gradient(145deg, #62b8ff, #7889f5 58%, #b477ed);
    box-shadow: 0 10px 26px -15px rgba(73, 91, 184, .8), inset 0 1px 0 rgba(255, 255, 255, .46);
    transform: translateX(-50%);
}

.ztk-ai-summary-icon svg {
    width: 27px;
    height: 27px;
    fill: currentColor;
}

.ztk-ai-summary-icon--image {
    padding: 7px;
    background: var(--ztk-summary-shell);
}

.ztk-ai-summary-icon-image {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.ztk-ai-summary-badge {
    grid-column: 3;
    justify-self: end;
    margin-left: 0;
    padding-left: 16px;
    color: var(--ztk-summary-muted);
    font-size: .78em;
    line-height: 1.4;
    letter-spacing: .02em;
    white-space: nowrap;
}

.ztk-ai-summary-content {
    box-sizing: border-box;
    min-height: 72px;
    padding: 17px 18px;
    border: 1px solid var(--ztk-summary-border);
    border-radius: 8px;
    color: var(--ztk-summary-text);
    background: var(--ztk-summary-panel);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4);
    font-size: 1em;
    line-height: 1.9;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.ztk-ai-summary-content > :first-child {
    margin-top: 0;
}

.ztk-ai-summary-content > :last-child {
    margin-bottom: 0;
}

.ztk-ai-summary-typed {
    min-height: 1.9em;
}

.ztk-ai-summary-typed p {
    margin: 0;
    white-space: pre-line;
}

.ztk-ai-summary-typed.is-typing p {
    cursor: pointer;
}

.ztk-ai-summary-cursor {
    display: inline-block;
    width: 2px;
    height: 1.05em;
    margin-left: 3px;
    vertical-align: -.12em;
    border-radius: 2px;
    background: var(--ztk-summary-accent);
    animation: ztk-summary-cursor 1s steps(1, end) infinite;
}

@keyframes ztk-summary-cursor {
    0%, 45% { opacity: 1; }
    46%, 100% { opacity: 0; }
}

.ztk-ai-summary-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px 16px;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px dashed var(--ztk-summary-border);
}

.ztk-ai-summary-tags {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.ztk-ai-summary-tags-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--ztk-summary-muted);
    font-size: .88em;
}

.ztk-ai-summary-tags-label svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.ztk-ai-summary-tag {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 3px 11px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--ztk-summary-muted) !important;
    background: var(--ztk-summary-panel);
    font-size: .82em;
    line-height: 1.25;
    text-decoration: none !important;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
    transition: color .2s ease, border-color .2s ease, background-color .2s ease, transform .2s ease;
}

.ztk-ai-summary-tag:hover,
.ztk-ai-summary-tag:focus-visible {
    border-color: var(--ztk-summary-accent);
    color: var(--ztk-summary-accent) !important;
    background: var(--ztk-summary-accent-soft);
    outline: 0;
    transform: translateY(-1px);
}

.ztk-ai-summary-disclaimer {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    color: var(--ztk-summary-muted);
    font-size: .76em;
    line-height: 1.5;
}

.ztk-ai-summary-disclaimer::before {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--ztk-summary-accent);
    content: '';
    opacity: .72;
}

.ztk-screen-reader-text {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

@media (max-width: 760px) {
    .ztk-ai-summary {
        margin-top: 24px;
        margin-bottom: 22px;
        padding: 18px 15px 16px;
        border-radius: 13px;
    }

    .ztk-ai-summary-head {
        display: block;
        padding-top: 18px;
    }

    .ztk-ai-summary-head-copy {
        display: block;
        padding-right: 72px;
    }

    .ztk-ai-summary-subtitle {
        display: block;
        margin-top: 4px;
    }

    .ztk-ai-summary-icon {
        top: -39px;
        width: 50px;
        height: 50px;
        border-width: 7px;
    }

    .ztk-ai-summary-badge {
        position: absolute;
        top: 0;
        right: 0;
        padding-left: 8px;
        font-size: .68em;
    }

    .ztk-ai-summary-content {
        padding: 15px;
        line-height: 1.8;
    }

    .ztk-ai-summary-footer {
        align-items: flex-start;
    }

    .ztk-ai-summary-disclaimer {
        width: 100%;
        margin-left: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ztk-ai-summary,
    .ztk-ai-summary-tag {
        transition: none;
    }

    .ztk-ai-summary-tag:hover,
    .ztk-ai-summary-tag:focus-visible {
        transform: none;
    }

    .ztk-ai-summary-cursor {
        animation: none;
        opacity: 1;
    }
}

/* Admin controls */
.ztk-ai-box .ztk-ai-spinner {
    float: none;
    margin: 4px 6px 0;
    vertical-align: middle;
}

.ztk-ai-box .ztk-ai-status {
    display: inline-block;
    margin-top: 5px;
    vertical-align: top;
}

.ztk-ai-box textarea {
    box-sizing: border-box;
    width: 100%;
}

.ztk-forum-ai-box .notice-error {
    margin-left: 8px;
    color: #b32d2e;
}
