/* FGG Enhance - 所有选择器均以 fgge- 前缀隔离，避免与主题 UIkit 冲突 */

:root {
    --fgge-accent: #2d6a4f;
    --fgge-surface: #ffffff;
    --fgge-surface-2: #f5f7f6;
    --fgge-text: #1f2429;
    --fgge-muted: #6b7570;
    --fgge-line: rgba(31, 36, 41, .10);
    --fgge-shadow: 0 8px 28px rgba(20, 30, 25, .10);
    --fgge-radius: 12px;
}

body.dark {
    --fgge-surface: #191b2c;
    --fgge-surface-2: #222539;
    --fgge-text: #dedede;
    --fgge-muted: #8c92b3;
    --fgge-line: rgba(255, 255, 255, .10);
    --fgge-shadow: 0 8px 28px rgba(0, 0, 0, .34);
}

/* ---------- 阅读进度条 ---------- */
.fgge-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    z-index: 9998;
    pointer-events: none;
    background: transparent;
}
.fgge-progress > i {
    display: block;
    height: 100%;
    width: 0;
    background: var(--fgge-accent);
    transition: width .12s linear;
}

/* ---------- 回到顶部 ---------- */
.fgge-totop {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 44px;
    height: 44px;
    border: 1px solid var(--fgge-line);
    border-radius: 50%;
    background: var(--fgge-surface);
    color: var(--fgge-text);
    box-shadow: var(--fgge-shadow);
    cursor: pointer;
    z-index: 9990;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: opacity .25s ease, transform .25s ease, color .2s ease, border-color .2s ease;
}
.fgge-totop.is-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.fgge-totop:hover {
    color: var(--fgge-accent);
    border-color: var(--fgge-accent);
}
.fgge-totop svg { width: 18px; height: 18px; display: block; }
.fgge-totop .fgge-ring {
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    pointer-events: none;
}

/* ---------- 文章目录 ---------- */
.fgge-toc {
    position: fixed;
    top: 50%;
    right: 24px;
    transform: translateY(-50%);
    width: 216px;
    max-height: 68vh;
    overflow: auto;
    padding: 16px 14px;
    border: 1px solid var(--fgge-line);
    border-radius: var(--fgge-radius);
    background: var(--fgge-surface);
    box-shadow: var(--fgge-shadow);
    z-index: 9980;
    font-size: 12px;
    line-height: 1.6;
    scrollbar-width: thin;
}
.fgge-toc::-webkit-scrollbar { width: 4px; }
.fgge-toc::-webkit-scrollbar-thumb { background: var(--fgge-line); border-radius: 4px; }
.fgge-toc-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 500;
    color: var(--fgge-text);
    padding: 0 4px 10px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--fgge-line);
    letter-spacing: .02em;
}
.fgge-toc-toggle {
    border: 0;
    background: none;
    color: var(--fgge-muted);
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    padding: 0 2px;
}
.fgge-toc-toggle:hover { color: var(--fgge-accent); }
.fgge-toc ul { list-style: none; margin: 0; padding: 0; }
.fgge-toc li { margin: 0; padding: 0; }
.fgge-toc a {
    display: block;
    padding: 5px 8px;
    color: var(--fgge-muted);
    text-decoration: none;
    border-left: 2px solid transparent;
    border-radius: 0 4px 4px 0;
    transition: color .18s ease, background .18s ease, border-color .18s ease;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.fgge-toc a:hover { color: var(--fgge-text); background: var(--fgge-surface-2); }
.fgge-toc a.is-active {
    color: var(--fgge-accent);
    border-left-color: var(--fgge-accent);
    background: var(--fgge-surface-2);
}
.fgge-toc li[data-level="3"] a { padding-left: 22px; font-size: 11.5px; }
.fgge-toc li[data-level="4"] a { padding-left: 34px; font-size: 11.5px; }
.fgge-toc li[data-level="5"] a { padding-left: 46px; font-size: 11.5px; }
.fgge-toc.is-folded { width: 44px; padding: 12px 8px; }
.fgge-toc.is-folded .fgge-toc-title { border: 0; padding: 0; margin: 0; justify-content: center; }
.fgge-toc.is-folded .fgge-toc-title > span { display: none; }
.fgge-toc.is-folded ul { display: none; }
.fgge-heading { scroll-margin-top: 84px; }

/* ---------- 图片灯箱 ---------- */
.fgge-lightbox {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 36px;
    background: rgba(10, 12, 18, .90);
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s ease;
}
.fgge-lightbox.is-open { opacity: 1; pointer-events: auto; }
.fgge-lightbox img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 6px;
    box-shadow: 0 18px 60px rgba(0, 0, 0, .5);
    transform: scale(.97);
    transition: transform .22s ease;
}
.fgge-lightbox.is-open img { transform: scale(1); }
.fgge-lightbox-close {
    position: absolute;
    top: 20px;
    right: 24px;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(255, 255, 255, .28);
    border-radius: 50%;
    background: rgba(255, 255, 255, .08);
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}
.fgge-lightbox-close:hover { background: rgba(255, 255, 255, .18); }
.fgge-lightbox-cap {
    position: absolute;
    bottom: 22px;
    left: 0;
    right: 0;
    text-align: center;
    color: rgba(255, 255, 255, .72);
    font-size: 12px;
}
.fgge-zoomable { cursor: zoom-in; }

/* ---------- 外链标识 ---------- */
.fgge-ext::after {
    content: "";
    display: inline-block;
    width: 9px;
    height: 9px;
    margin-left: 3px;
    vertical-align: baseline;
    background-repeat: no-repeat;
    background-size: contain;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6'/%3E%3Cpolyline points='15 3 21 3 21 9'/%3E%3Cline x1='10' y1='14' x2='21' y2='3'/%3E%3C/svg%3E");
    opacity: .55;
}

/* ---------- 移动端底栏 ---------- */
.fgge-mbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9970;
    display: none;
    border-top: 1px solid var(--fgge-line);
    background: var(--fgge-surface);
    box-shadow: 0 -4px 20px rgba(20, 30, 25, .06);
    padding-bottom: env(safe-area-inset-bottom, 0);
}
.fgge-mbar ul {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
}
.fgge-mbar li { flex: 1 1 0; margin: 0; }
.fgge-mbar button,
.fgge-mbar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    width: 100%;
    padding: 9px 0 8px;
    border: 0;
    background: none;
    color: var(--fgge-muted);
    font-size: 10px;
    text-decoration: none;
    cursor: pointer;
}
.fgge-mbar button:hover,
.fgge-mbar a:hover { color: var(--fgge-accent); }
.fgge-mbar svg { width: 19px; height: 19px; display: block; }
body.has-fgge-mbar .fgge-totop { bottom: 78px; }

/* ---------- 响应式 ---------- */
@media (max-width: 1400px) {
    .fgge-toc { right: 14px; width: 190px; }
}
@media (max-width: 1100px) {
    .fgge-toc { display: none; }
}
@media (max-width: 768px) {
    .fgge-mbar { display: block; }
    .fgge-totop { right: 16px; width: 40px; height: 40px; }
    body.has-fgge-mbar .single-content,
    body.has-fgge-mbar .entry-content { padding-bottom: 56px; }
    .fgge-lightbox { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    .fgge-progress > i,
    .fgge-totop,
    .fgge-toc a,
    .fgge-lightbox,
    .fgge-lightbox img { transition: none; }
}
