/* Codex post writing enhancements for Handsome. */
#post-content .codex-code-wrap {
    position: relative;
    margin: 1.2em 0;
}

#post-content .codex-code-wrap > pre {
    margin: 0;
    padding-top: 2.8em;
    overflow: auto;
}

#post-content .codex-code-toolbar {
    position: absolute;
    top: 8px;
    right: 8px;
    left: 8px;
    z-index: 2;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

#post-content .codex-code-lang {
    max-width: 50%;
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(255, 255, 255, .82);
    color: #6b7280;
    font-size: 12px;
    line-height: 1.4;
    text-transform: uppercase;
    box-shadow: 0 2px 10px rgba(15, 23, 42, .08);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#post-content .codex-copy-btn {
    pointer-events: auto;
    border: 1px solid rgba(148, 163, 184, .35);
    border-radius: 6px;
    padding: 4px 9px;
    background: rgba(255, 255, 255, .9);
    color: #4b5563;
    font-size: 12px;
    line-height: 1.4;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(15, 23, 42, .08);
    transition: background .16s ease, color .16s ease, border-color .16s ease;
}

#post-content .codex-copy-btn:hover,
#post-content .codex-copy-btn:focus {
    background: #ffffff;
    color: #111827;
    border-color: rgba(59, 130, 246, .55);
    outline: none;
}

#post-content .codex-copy-btn.is-copied {
    color: #047857;
    border-color: rgba(16, 185, 129, .55);
}

#post-content .codex-table-wrap {
    max-width: 100%;
    overflow-x: auto;
    margin: 1em 0;
    -webkit-overflow-scrolling: touch;
}

#post-content .codex-table-wrap > table {
    margin: 0;
    min-width: 520px;
}

#post-content img.codex-clickable-image {
    cursor: zoom-in;
}

#post-content .codex-heading-anchor {
    margin-left: 8px;
    color: #94a3b8;
    font-size: .72em;
    text-decoration: none;
    opacity: 0;
    transition: opacity .16s ease, color .16s ease;
}

#post-content h1:hover .codex-heading-anchor,
#post-content h2:hover .codex-heading-anchor,
#post-content h3:hover .codex-heading-anchor,
#post-content h4:hover .codex-heading-anchor,
#post-content h5:hover .codex-heading-anchor,
#post-content h6:hover .codex-heading-anchor {
    opacity: 1;
}

#post-content .codex-heading-anchor:hover {
    color: #38bdf8;
}

#post-content kbd {
    display: inline-block;
    min-width: 1.6em;
    padding: 2px 6px;
    border: 1px solid #cbd5e1;
    border-bottom-width: 2px;
    border-radius: 5px;
    background: #f8fafc;
    color: #334155;
    font-family: inherit;
    font-size: .86em;
    line-height: 1.25;
    text-align: center;
    box-shadow: inset 0 -1px 0 rgba(15, 23, 42, .06);
}

#post-content mark {
    padding: 1px 5px;
    border-radius: 5px;
    background: linear-gradient(transparent 42%, rgba(250, 204, 21, .52) 42%);
    color: inherit;
}

#post-content .codex-badge {
    display: inline-block;
    margin: 0 2px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #eef2ff;
    color: #4338ca;
    font-size: .86em;
    line-height: 1.45;
    vertical-align: 1px;
    white-space: nowrap;
}

#post-content .codex-badge-success {
    background: #ecfdf5;
    color: #047857;
}

#post-content .codex-badge-warning {
    background: #fffbeb;
    color: #b45309;
}

#post-content .codex-badge-danger {
    background: #fef2f2;
    color: #b91c1c;
}

#post-content .codex-mermaid-wrap {
    margin: 1.2em 0;
    padding: 16px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #ffffff;
    overflow-x: auto;
}

#post-content .codex-mermaid-wrap .mermaid {
    text-align: center;
}

#post-content details.codex-details {
    margin: 1.2em 0;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #ffffff;
    overflow: hidden;
}

#post-content details.codex-details > summary {
    padding: 12px 14px;
    background: #f8fafc;
    color: #334155;
    font-weight: 700;
    cursor: pointer;
}

#post-content details.codex-details > .codex-details-body {
    padding: 14px 16px;
}

#post-content blockquote.codex-callout {
    border-left-width: 4px;
    border-radius: 8px;
    padding: 14px 16px;
    background: #f8fafc;
}

#post-content blockquote.codex-callout-tip {
    border-left-color: #38bdf8;
    background: #f0f9ff;
}

#post-content blockquote.codex-callout-note {
    border-left-color: #a78bfa;
    background: #f5f3ff;
}

#post-content blockquote.codex-callout-warning {
    border-left-color: #f59e0b;
    background: #fffbeb;
}

#post-content blockquote p.codex-callout {
    margin: 10px 0;
    border-left: 4px solid #38bdf8;
    border-radius: 8px;
    padding: 12px 14px;
    background: #f0f9ff;
}

#post-content blockquote p.codex-callout-note {
    border-left-color: #a78bfa;
    background: #f5f3ff;
}

#post-content blockquote p.codex-callout-warning {
    border-left-color: #f59e0b;
    background: #fffbeb;
}

#post-content li.codex-task-item {
    list-style: none;
    margin-left: -1.3em;
}

#post-content li.codex-task-item::before {
    content: "";
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-right: 7px;
    vertical-align: -2px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background: #fff;
}

#post-content li.codex-task-item.is-checked::before {
    content: "✓";
    color: #ffffff;
    background: #38bdf8;
    border-color: #38bdf8;
    font-size: 11px;
    line-height: 13px;
    text-align: center;
}

html.theme-dark #post-content .codex-code-lang,
html.theme-dark #post-content .codex-copy-btn,
body.theme-dark #post-content .codex-code-lang,
body.theme-dark #post-content .codex-copy-btn,
body.dark #post-content .codex-code-lang,
body.dark #post-content .codex-copy-btn {
    background: rgba(31, 41, 55, .92);
    color: #d1d5db;
    border-color: rgba(75, 85, 99, .8);
}

.codex-image-preview {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 28px;
    background: rgba(15, 23, 42, .82);
    cursor: zoom-out;
}

.codex-image-preview.is-open {
    display: flex;
}

.codex-image-preview img {
    max-width: min(94vw, 1280px);
    max-height: 90vh;
    border-radius: 10px;
    box-shadow: 0 24px 90px rgba(0, 0, 0, .45);
    background: #ffffff;
}

.codex-image-preview button {
    position: fixed;
    top: 18px;
    right: 18px;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 18px;
    background: rgba(255, 255, 255, .92);
    color: #111827;
    font-size: 24px;
    line-height: 36px;
    cursor: pointer;
}
