.fox-code-block {
    margin: 1.5rem 0;
    border: 1px solid #d7e2ec;
    border-radius: 16px;
    overflow: hidden;
    background: linear-gradient(180deg, #fbfdff 0%, #f4f8fc 100%);
    box-shadow: 0 18px 42px rgba(15, 23, 42, 0.08);
}

body.a4-note-theme .fox-code-block {
    border-color: #e2bb59;
    background: linear-gradient(180deg, #fff8de 0%, #fff1c2 100%);
    box-shadow: 0 18px 42px rgba(145, 93, 0, 0.09);
}

.a4-page .fox-code-block {
    margin: 18pt 0;
    break-inside: avoid;
}

.fox-code-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid #dce6ef;
    background: #edf4fa;
}

body.a4-note-theme .fox-code-toolbar {
    border-bottom-color: #e5c86f;
    background: #ffeeb9;
}

.fox-code-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex-wrap: wrap;
}

.fox-code-lang {
    display: inline-flex;
    align-items: center;
    padding: 4px 9px;
    border-radius: 999px;
    background: #ddeffc;
    border: 1px solid #c2def5;
    color: #155e75;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

body.a4-note-theme .fox-code-lang {
    background: #ffe8a6;
    border-color: #f2c256;
    color: #7a4700;
}

.fox-code-lines {
    color: #64748b;
    font-size: 0.78rem;
    white-space: nowrap;
}

body.a4-note-theme .fox-code-lines {
    color: #9b6d06;
}

.fox-code-copy {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid #cad9e6;
    background: #ffffff4b;
    color: #0f172a;
    border-radius: 10px;
    padding: 7px 11px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

body.a4-note-theme .fox-code-copy {
    border-color: #e4c46d;
    background: #fffdf26e;
    color: #7b4900;
}

.fox-code-copy:hover {
    background: #f8fbff;
    border-color: #9fc5e6;
    color: #0f5e82;
    transform: translateY(-1px);
}

body.a4-note-theme .fox-code-copy:hover {
    background: #fff7d8;
    border-color: #cf9b2f;
    color: #8b5300;
}

.fox-code-copy.is-copied {
    background: #ecfdf5;
    border-color: #86efac;
    color: #166534;
}

.fox-code-surface {
    overflow: auto;
    background: linear-gradient(180deg, #f7fbff 0%, #f3f8fd 100%);
}

body.a4-note-theme .fox-code-surface {
    background: linear-gradient(180deg, #fffdf7 0%, #fff6dc 100%);
}

.fox-code-surface .ace_static_highlight {
    margin: 0;
    padding: 16px 18px 18px;
    background: transparent !important;
    font-size: 13.5px !important;
    line-height: 1.68;
    white-space: pre-wrap;
    word-break: break-word;
    color: #0f172a;
}

body.a4-note-theme .fox-code-surface .ace_static_highlight {
    color: #4f3211;
}

.fox-code-surface .ace_static_highlight .ace_gutter {
    color: #94a3b8;
    background: #edf4fa94;
}

body.a4-note-theme .fox-code-surface .ace_static_highlight .ace_gutter {
    color: #b68b38;
    background: #ffeeb957;
}

.fox-code-surface .ace_static_highlight .ace_line {
    padding-right: 18px;
}

.fox-code-fallback {
    margin: 0;
    padding: 16px 18px 18px;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: "Cascadia Code", Consolas, "SFMono-Regular", Menlo, monospace;
    font-size: 13.5px;
    line-height: 1.68;
    color: #0f172a;
    background: transparent;
}

body.a4-note-theme .fox-code-fallback {
    color: #4f3211;
}

.page-content-html :not(pre) > code,
.a4-page :not(pre) > code {
    display: inline-block;
    padding: 0.16em 0.45em;
    border-radius: 6px;
    border: 1px solid #cfe0ee;
    background: #eff6ff;
    color: #0f5e82;
    font-family: "Cascadia Code", Consolas, "SFMono-Regular", Menlo, monospace;
    white-space: break-spaces;
}

body.a4-note-theme .page-content-html :not(pre) > code,
body.a4-note-theme .a4-page :not(pre) > code {
    border-color: #e4c46d;
    background: #fff1c7;
    color: #855000;
}

@media (max-width: 768px) {
    .fox-code-toolbar {
        padding: 9px 10px;
    }

    .fox-code-copy {
        padding: 7px 9px;
    }

    .fox-code-copy span {
        display: none;
    }

    .fox-code-surface .ace_static_highlight,
    .fox-code-fallback {
        padding: 14px;
        font-size: 12.5px !important;
    }
}

@media print {
    .fox-code-block {
        border-color: #cbd5e1;
        box-shadow: none;
        background: #ffffff;
    }

    .fox-code-toolbar {
        display: none !important;
    }

    .fox-code-surface {
        background: #ffffff;
    }

    .fox-code-surface .ace_static_highlight,
    .fox-code-fallback {
        padding: 12pt 14pt;
        font-size: 10.5pt !important;
        color: #111827 !important;
    }
}
