/* 仅覆盖面板 UI；语法 token 的颜色、字重和背景均使用父主题当前皮肤。 */
.wp-posts-content pre.zib-code-window,
.comment-content pre.zib-code-window {
    --zc-topbar: #f5f5f7;
    --zc-body: #ffffff;
    --zc-gutter: #f7f7f8;
    --zc-border: #dfe5f1;
    --zc-title: #34363a;
    --zc-text: #383a3e;
    --zc-muted: #9a9da3;
    --zc-hover: rgba(51, 65, 85, .06);
    --zc-scroll-track: #f5f7fc;
    --zc-scroll-thumb: #dbe3f2;
    --zc-gutter-width: 48px;
    position: relative;
    display: block;
    box-sizing: border-box;
    max-width: 100%;
    max-height: none !important;
    margin: 1.5rem 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    background: linear-gradient(90deg, var(--zc-gutter) 0 var(--zc-gutter-width), var(--zc-border) var(--zc-gutter-width) calc(var(--zc-gutter-width) + 1px), var(--zc-body) calc(var(--zc-gutter-width) + 1px)) !important;
    border: 1px solid var(--zc-border) !important;
    border-radius: 8px !important;
    box-shadow: none !important;
    white-space: normal;
    font: 14px/1.78 ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

.zib-code-window .zc-code-topbar {
    position: relative;
    display: flex;
    min-height: 43px;
    align-items: center;
    gap: 7px;
    padding: 5px 10px 5px 8px;
    color: var(--zc-title);
    background: var(--zc-topbar);
    border-bottom: 1px solid var(--zc-border);
    user-select: none;
}

.zib-code-window .zc-code-title {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    color: var(--zc-title);
    font: 600 18px/1.3 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    letter-spacing: 0;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.zib-code-window .zc-code-tools {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: flex-end;
    gap: 2px;
}

.zib-code-window .zc-code-copy,
.zib-code-window .zc-code-window-open,
.zib-code-window .zc-code-fold {
    display: inline-flex;
    width: 31px;
    height: 31px;
    min-width: 31px;
    min-height: 31px;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    color: var(--zc-title);
    cursor: pointer;
    background: transparent;
    border: 0;
    border-radius: 6px;
    box-shadow: none;
    font: inherit;
    transition: color .18s ease, background-color .18s ease, opacity .18s ease, transform .18s ease, width .18s ease, min-width .18s ease;
}

.zib-code-window .zc-code-window-open {
    width: 0;
    min-width: 0;
    overflow: hidden;
    pointer-events: none;
    opacity: 0;
    transform: translateX(5px);
}

.zib-code-window:hover .zc-code-window-open,
.zib-code-window .zc-code-topbar:focus-within .zc-code-window-open {
    width: 31px;
    min-width: 31px;
    pointer-events: auto;
    opacity: 1;
    transform: translateX(0);
}

.zib-code-window .zc-code-copy:hover,
.zib-code-window .zc-code-copy:focus-visible,
.zib-code-window .zc-code-window-open:hover,
.zib-code-window .zc-code-window-open:focus-visible,
.zib-code-window .zc-code-fold:hover,
.zib-code-window .zc-code-fold:focus-visible {
    color: var(--theme-color, #f04494);
    background: var(--zc-hover);
    outline: 0;
}

.zib-code-window .zc-code-copy:active,
.zib-code-window .zc-code-window-open:active,
.zib-code-window .zc-code-fold:active { transform: scale(.92); }

.zib-code-window .zc-code-copy svg,
.zib-code-window .zc-code-window-open svg,
.zib-code-window .zc-code-fold svg {
    display: block;
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
    transition: transform .2s ease;
}

.zib-code-window .zc-code-copy svg {
    width: 19px;
    height: 19px;
    fill: currentColor;
    stroke: none;
}

.zib-code-window .zc-code-fold svg {
    width: 17px;
    height: 17px;
    stroke-width: 2.35;
}

.zib-code-window .zc-code-copy span,
.zib-code-window .zc-code-window-open span,
.zib-code-window .zc-code-fold span {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

.wp-posts-content .zib-code-window > .enlighter-default,
.comment-content .zib-code-window > .enlighter-default {
    display: block;
    box-sizing: border-box;
    width: 100%;
    max-height: var(--zc-code-max-height, 300px) !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: auto !important;
    background: linear-gradient(90deg, var(--zc-gutter) 0 var(--zc-gutter-width), var(--zc-border) var(--zc-gutter-width) calc(var(--zc-gutter-width) + 1px), var(--zc-body) calc(var(--zc-gutter-width) + 1px)) !important;
    border: 0 !important;
    border-radius: 0 !important;
    overscroll-behavior: auto;
    scrollbar-color: var(--zc-scroll-thumb) var(--zc-scroll-track);
    scrollbar-width: thin;
    font-family: ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace !important;
}

.zib-code-window > .enlighter-default::-webkit-scrollbar,
.zib-code-window .enlighter-raw::-webkit-scrollbar { width: 8px; height: 8px; }
.zib-code-window > .enlighter-default::-webkit-scrollbar-track,
.zib-code-window .enlighter-raw::-webkit-scrollbar-track { background: var(--zc-scroll-track); }
.zib-code-window > .enlighter-default::-webkit-scrollbar-thumb,
.zib-code-window .enlighter-raw::-webkit-scrollbar-thumb {
    background: var(--zc-scroll-thumb);
    border: 2px solid var(--zc-scroll-track);
    border-radius: 999px;
}

.wp-posts-content .zib-code-window div.enlighter,
.comment-content .zib-code-window div.enlighter {
    margin: 0 !important;
    padding: 10px 0 12px !important;
}

.zib-code-window div.enlighter > div > div { padding-right: 18px; }
.zib-code-window .enlighter-linenumbers div.enlighter > div::before {
    color: var(--zc-muted);
    background: var(--zc-gutter);
    border-right: 1px solid var(--zc-border);
}

/* Without parent line numbers, avoid drawing an empty gutter. */
.wp-posts-content pre.zib-code-window:not(.zc-code-has-lines),
.comment-content pre.zib-code-window:not(.zc-code-has-lines) { --zc-gutter-width: 0px; }

/* Respect the parent's raw/highlight toggle instead of forcing both views visible. */
.zib-code-window .enlighter-show-rawcode div.enlighter { display: none !important; }

.zib-code-window .enlighter span { font-family: inherit !important; font-size: 14px !important; line-height: inherit !important; }
.zib-code-window .enlighter-toolbar { display: none !important; }
.zib-code-window > code.enlighter-origin { display: none !important; }

.zib-code-window .enlighter-raw {
    box-sizing: border-box;
    width: 100%;
    max-height: var(--zc-code-max-height, 300px);
    margin: 0 !important;
    padding: 14px 18px 16px 62px !important;
    overflow: auto;
    color: var(--zc-text) !important;
    background: linear-gradient(90deg, var(--zc-gutter) 0 var(--zc-gutter-width), var(--zc-border) var(--zc-gutter-width) calc(var(--zc-gutter-width) + 1px), var(--zc-body) calc(var(--zc-gutter-width) + 1px)) !important;
    border: 0 !important;
    white-space: pre !important;
    font: 14px/1.78 ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, Consolas, monospace !important;
}

.zib-code-window.zc-code-collapsed > .enlighter-default { display: none !important; }
.zib-code-window.zc-code-collapsed .zc-code-topbar { border-bottom: 0; }
.zib-code-window.zc-code-collapsed .zc-code-fold svg { transform: rotate(-90deg); }

.zibll-child-code-toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    z-index: 99999;
    padding: 8px 15px;
    color: #fff;
    pointer-events: none;
    background: rgba(20, 25, 33, .94);
    border-radius: 999px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .22);
    opacity: 0;
    transform: translate(-50%, 12px);
    transition: opacity .2s ease, transform .2s ease;
    font-size: 13px;
}
.zibll-child-code-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

body.dark-theme .zib-code-window {
    --zc-topbar: #292b31;
    --zc-body: #1f2126;
    --zc-gutter: #24262c;
    --zc-border: rgba(255, 255, 255, .11);
    --zc-title: #e4e6eb;
    --zc-text: #d4d4d4;
    --zc-muted: #7f858f;
    --zc-hover: rgba(255, 255, 255, .055);
    --zc-scroll-track: #22242a;
    --zc-scroll-thumb: #444954;
}

@media (max-width: 640px) {
    .wp-posts-content pre.zib-code-window,
    .comment-content pre.zib-code-window { --zc-gutter-width: 42px; border-radius: 7px !important; }
    .zib-code-window .zc-code-topbar { min-height: 41px; padding-inline: 6px 8px; }
    .zib-code-window .zc-code-title { font-size: 16px; }
    .zib-code-window .zc-code-copy,
    .zib-code-window .zc-code-window-open,
    .zib-code-window .zc-code-fold,
    .zib-code-window:hover .zc-code-window-open,
    .zib-code-window .zc-code-topbar:focus-within .zc-code-window-open { width: 29px; min-width: 29px; height: 29px; min-height: 29px; }
    .wp-posts-content .zib-code-window div.enlighter > div > div,
    .comment-content .zib-code-window div.enlighter > div > div { padding-right: 12px !important; padding-left: 11px !important; }
    .wp-posts-content .zib-code-window .enlighter-default.enlighter-linenumbers div.enlighter > div::before,
    .comment-content .zib-code-window .enlighter-default.enlighter-linenumbers div.enlighter > div::before { padding-inline: 5px 9px !important; }
}

@media (hover: none) {
    .zib-code-window .zc-code-window-open {
        width: 31px;
        min-width: 31px;
        pointer-events: auto;
        opacity: 1;
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .zib-code-window .zc-code-copy,
    .zib-code-window .zc-code-window-open,
    .zib-code-window .zc-code-fold,
    .zib-code-window .zc-code-copy svg,
    .zib-code-window .zc-code-window-open svg,
    .zib-code-window .zc-code-fold svg,
    .zibll-child-code-toast { transition: none; }
}
