/* 文章终端块：由 pre.zib-term 渐进增强为 figure.zib-term。 */
.wp-posts-content pre.zib-term,
.zib-term.zib-terminal-window {
    --zt-topbar: #1c2128;
    --zt-topline: #2d333b;
    --zt-body: #0d1117;
    --zt-border: #30363d;
    --zt-title: #8b949e;
    --zt-text: #e6edf3;
    --zt-muted: #8b949e;
    --zt-green: #8dde64;
    --zt-red: #ff6174;
    --zt-yellow: #e3b341;
    --zt-blue: #79c0ff;
    --zt-cyan: #56d4dd;
    --zt-purple: #d2a8ff;
    --zt-gray: #8b949e;
    --zt-shadow: 0 14px 34px rgba(1, 4, 9, .32);
    --zt-mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

/* 无 JS 时仍保持可读的终端外观。 */
.wp-posts-content pre.zib-term:not(.zt-source) {
    display: block;
    max-width: 100%;
    margin: 1.5rem 0;
    padding: 18px;
    overflow: auto;
    color: var(--zt-text);
    background: var(--zt-body);
    border: 1px solid var(--zt-border);
    border-radius: 10px;
    box-shadow: var(--zt-shadow);
    white-space: pre-wrap;
    word-break: break-word;
    font: 13px/1.72 var(--zt-mono);
}

.zib-term.zib-terminal-window {
    position: relative;
    display: block;
    box-sizing: border-box;
    max-width: 100%;
    margin: 1.5rem 0;
    overflow: hidden;
    color: var(--zt-text);
    background: var(--zt-body);
    border: 1px solid var(--zt-border);
    border-radius: 10px;
    box-shadow: var(--zt-shadow);
    direction: ltr;
    text-align: left;
    font: 13px/1.72 var(--zt-mono);
}

.zib-term .zt-topbar {
    display: flex;
    min-height: 43px;
    align-items: center;
    gap: 10px;
    padding: 8px 11px 8px 12px;
    background: var(--zt-topbar);
    border-bottom: 1px solid var(--zt-topline);
    user-select: none;
}

.zib-term .zt-dots {
    display: inline-flex;
    flex: 0 0 auto;
    gap: 7px;
    padding-right: 2px;
}

.zib-term .zt-dots i {
    display: block;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    box-shadow: inset 0 0 0 .5px rgba(0, 0, 0, .28);
}

.zib-term .zt-dots i:nth-child(1) { background: #ff5f57; }
.zib-term .zt-dots i:nth-child(2) { background: #febc2e; }
.zib-term .zt-dots i:nth-child(3) { background: #28c840; }

.zib-term .zt-title {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    color: var(--zt-title);
    font-size: 12px;
    letter-spacing: .2px;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.zib-term .zt-tools {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 5px;
}

.zib-term .zt-copy,
.zib-term .zt-fold {
    display: inline-flex;
    min-height: 27px;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 5px 9px;
    color: #9da7b3;
    cursor: pointer;
    background: rgba(255, 255, 255, .04);
    border: 1px solid var(--zt-topline);
    border-radius: 6px;
    font: 11.5px/1 var(--zt-mono);
    transition: color .18s ease, border-color .18s ease, background-color .18s ease, transform .18s ease;
}

.zib-term .zt-copy:hover,
.zib-term .zt-copy:focus-visible,
.zib-term .zt-fold:hover,
.zib-term .zt-fold:focus-visible {
    color: #fff;
    background: rgba(255, 255, 255, .09);
    border-color: #48545f;
    outline: 0;
}

.zib-term .zt-copy:active,
.zib-term .zt-fold:active { transform: scale(.96); }
.zib-term .zt-copy svg,
.zib-term .zt-fold svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.8; }

.zib-term .zt-body {
    position: relative;
    max-height: 560px;
    padding: 13px 16px 16px;
    overflow: auto;
    color: var(--zt-text);
    overscroll-behavior: auto;
    scrollbar-color: var(--zt-border) transparent;
    scrollbar-width: thin;
}

.zib-term .zt-body::-webkit-scrollbar { width: 8px; height: 8px; }
.zib-term .zt-body::-webkit-scrollbar-thumb { background: var(--zt-border); border-radius: 8px; }
.zib-term .zt-row { display: block; min-height: 1.25em; white-space: pre-wrap; word-break: break-word; }
.zib-term .zt-prompt { color: var(--zt-green); font-weight: 600; }
.zib-term .zt-cmd { color: var(--zt-text); }
.zib-term .zt-command-name,
.zib-term .zt-option { color: var(--zt-blue); }
.zib-term .zt-path { color: var(--zt-blue); }
.zib-term .zt-string,
.zib-term .zt-warn { color: var(--zt-yellow); }
.zib-term .zt-variable { color: var(--zt-purple); }
.zib-term .zt-url,
.zib-term .zt-address,
.zib-term .zt-cyan { color: var(--zt-cyan); }
.zib-term .zt-key,
.zib-term .zt-hash,
.zib-term .zt-magenta { color: var(--zt-purple); }
.zib-term .zt-json-key { color: var(--zt-blue); font-weight: 700; }
.zib-term .zt-json-string { color: var(--zt-green); }
.zib-term .zt-json-number,
.zib-term .zt-json-boolean { color: var(--zt-text); }
.zib-term .zt-json-struct { color: var(--zt-text); font-weight: 700; }
.zib-term .zt-debug,
.zib-term .zt-null,
.zib-term .zt-muted-token { color: var(--zt-gray); }
.zib-term .zt-operator { color: var(--focus-color, var(--theme-color, #f04494)); }
.zib-term .zt-out { color: var(--zt-muted); }
.zib-term .zt-label { color: var(--zt-text); font-weight: 600; }
.zib-term .zt-number,
.zib-term .zt-true,
.zib-term .zt-ok { color: var(--zt-green); }
.zib-term .zt-false,
.zib-term .zt-err { color: var(--zt-red); }
.zib-term .zt-info { color: var(--zt-blue); }
.zib-term .zt-notice { color: var(--zt-text); font-weight: 700; }
.zib-term .zt-progress { color: var(--zt-cyan); }
.zib-term .zt-git-added,
.zib-term .zt-diff-added { color: var(--zt-green); }
.zib-term .zt-git-changed { color: var(--zt-yellow); }
.zib-term .zt-git-deleted,
.zib-term .zt-git-unmerged,
.zib-term .zt-diff-deleted { color: var(--zt-red); }
.zib-term .zt-git-untracked { color: var(--zt-red); }
.zib-term .zt-git-ignored { color: var(--zt-gray); }
.zib-term .zt-diff-meta { color: var(--zt-cyan); }

/*
 * TinyMCE 4 的弹窗表单项由布局器写入绝对坐标。这里不能给表单行追加
 * margin/padding，否则布局器不会重算后一行坐标，两个标签和输入框会叠在一起。
 * 分隔线使用脱离布局的伪元素，不改变任何表单项的盒尺寸。
 */
.mce-formitem.zib-terminal-prompt-separator {
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
}

.mce-formitem.zib-terminal-prompt-separator::before {
    position: absolute;
    right: 0;
    bottom: calc(100% + 9px);
    left: 0;
    height: 1px;
    background: rgba(127, 127, 127, .2);
    content: "";
    pointer-events: none;
}

.mce-formitem.zib-terminal-prompt-separator > .mce-label,
.mce-formitem.zib-terminal-tail-row > .mce-label {
    display: block !important;
    height: 30px !important;
    line-height: 30px !important;
    overflow: visible !important;
    white-space: nowrap !important;
}

.zib-term .zt-caret {
    display: inline-block;
    width: 7px;
    height: 1.15em;
    margin-left: 3px;
    vertical-align: -.18em;
    background: var(--zt-text);
    border-radius: 1px;
    animation: zibll-child-terminal-blink 1.05s steps(1, end) infinite;
}

@keyframes zibll-child-terminal-blink {
    0%, 54% { opacity: 1; }
    55%, 100% { opacity: 0; }
}

.zib-term .zt-source { display: none !important; }
.zib-term.zib-terminal-window.zt-collapsed .zt-body { display: none; }
.zib-term.zib-terminal-window.zt-collapsed .zt-topbar { border-bottom: 0; }

.zibll-child-terminal-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, .28);
    opacity: 0;
    transform: translate(-50%, 12px);
    transition: opacity .2s ease, transform .2s ease;
    font-size: 13px;
}

.zibll-child-terminal-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* 终端主体保持专业深色；外围阴影随子比夜间模式收敛。 */
body.dark-theme .zib-term.zib-terminal-window {
    --zt-shadow: 0 16px 38px rgba(0, 0, 0, .48);
    border-color: rgba(255, 255, 255, .12);
}

@media (max-width: 640px) {
    .zib-term.zib-terminal-window { font-size: 12px; border-radius: 9px; }
    .zib-term .zt-topbar { min-height: 40px; padding-inline: 9px; }
    .zib-term .zt-body { padding: 12px 13px 14px; }
    .zib-term .zt-copy,
    .zib-term .zt-fold { width: 28px; padding: 5px; font-size: 0; }
    .zib-term .zt-copy svg,
    .zib-term .zt-fold svg { width: 14px; height: 14px; }
}

@media (prefers-reduced-motion: reduce) {
    .zib-term .zt-copy,
    .zib-term .zt-fold,
    .zibll-child-terminal-toast { transition: none; }
}

/* TinyMCE 工具栏中的终端图标。 */
.mce-i-zib-terminal::before {
    color: #0e9f6e;
    content: ">_";
    font: 800 14px/1 ui-monospace, "SFMono-Regular", Consolas, monospace;
    letter-spacing: -2px;
}
