/* 题目详情 — 对齐 home / collection 视觉语言 */
:root {
    --pd-bg: #f5f7fb;
    --pd-surface: #ffffff;
    --pd-text: #1f2329;
    --pd-text-2: #646a73;
    --pd-text-3: #8f959e;
    --pd-line: #eef0f3;
    --pd-primary: #1677ff;
    --pd-primary-soft: #e8f3ff;
    --pd-radius: 14px;
    --pd-shadow: 0 1px 2px rgba(31, 35, 41, 0.04), 0 12px 28px rgba(31, 35, 41, 0.06);
}

body:has(.pd-wrap) {
    background: var(--pd-bg);
}

.pd-wrap {
    min-height: calc(100vh - 120px);
    padding-bottom: 56px;
    background:
        radial-gradient(1100px 280px at 14% -50px, rgba(22, 119, 255, 0.10), transparent 58%),
        radial-gradient(900px 240px at 92% 0, rgba(14, 165, 233, 0.07), transparent 55%),
        var(--pd-bg);
}

.pd-page {
    max-width: 1250px;
    margin: 0 auto;
    padding: 28px 16px 0;
    color: var(--pd-text);
}

.pd-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 18px;
    font-size: 13px;
    color: var(--pd-text-3);
}

.pd-breadcrumb a {
    color: var(--pd-text-2) !important;
    text-decoration: none !important;
}

.pd-breadcrumb a:hover {
    color: var(--pd-primary) !important;
}

.pd-breadcrumb .is-current {
    color: var(--pd-text);
    font-weight: 400;
}

.pd-card {
    background: var(--pd-surface);
    border: 1px solid var(--pd-line);
    border-radius: 18px;
    box-shadow: var(--pd-shadow);
    padding: 28px 32px 36px;
}

.pd-head {
    padding-bottom: 20px;
    border-bottom: 1px solid var(--pd-line);
    margin-bottom: 8px;
}

.pd-head-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.pd-head-top .pd-title {
    margin: 0;
    flex: 1 1 auto;
    min-width: 0;
}

.pd-fav-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 14px;
    border-radius: 10px;
    border: 1px solid rgba(22, 119, 255, 0.28);
    background: #fff;
    color: var(--pd-primary);
    font-size: 13px;
    font-weight: 450;
    cursor: pointer;
    white-space: nowrap;
}

.pd-fav-btn:hover {
    background: var(--pd-primary-soft);
    border-color: var(--pd-primary);
}

.pd-fav-btn.is-on {
    background: #fff1f0;
    border-color: #ffa39e;
    color: #cf1322;
}

.pd-fav-btn .pd-fav-count {
    font-style: normal;
    color: var(--pd-text-3);
    font-size: 12px;
}

.pd-fav-btn.is-on .pd-fav-count {
    color: #f5222d;
}

.pd-title {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px;
    margin: 0 0 14px;
    font-size: 28px;
    font-weight: 450;
    letter-spacing: -0.02em;
    line-height: 1.35;
    color: var(--pd-text);
}
.pd-title-no {
    flex-shrink: 0;
    color: var(--pd-muted, #64748b);
}
.pd-title-text {
    flex: 1 1 12rem;
    min-width: 0;
}

.pd-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.pd-pill {
    display: inline-flex;
    align-items: center;
    height: 26px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 450;
    text-decoration: none !important;
    line-height: 1;
}

.pd-pill.is-diff {
    background: #ecfdf5;
    color: #059669;
}

.pd-knowledge {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-top: 4px;
}

.pd-knowledge-label {
    flex: 0 0 auto;
    margin-top: 4px;
    font-size: 13px;
    font-weight: 450;
    color: var(--pd-text-3);
}

.pd-knowledge-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
}

.pd-ktag {
    display: inline-flex;
    align-items: center;
    height: 28px;
    padding: 0 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 450;
    text-decoration: none !important;
    line-height: 1;
    transition: transform 0.15s ease;
}

.pd-ktag:hover {
    transform: translateY(-1px);
}

.pd-ktag-tone-0 { background: #e8f1ff; color: #1677ff; }
.pd-ktag-tone-1 { background: #ecfdf5; color: #059669; }
.pd-ktag-tone-2 { background: #fff7ed; color: #c2410c; }
.pd-ktag-tone-3 { background: #f5f3ff; color: #7c3aed; }
.pd-ktag-tone-4 { background: #fdf2f8; color: #db2777; }
.pd-ktag-tone-5 { background: #ecfeff; color: #0891b2; }
.pd-ktag-tone-6 { background: #fefce8; color: #a16207; }
.pd-ktag-tone-7 { background: #f1f5f9; color: #475569; }

.pd-knowledge-empty {
    font-size: 13px;
    color: var(--pd-text-3);
    line-height: 28px;
}

.pd-section {
    margin-top: 28px;
}

.pd-section h2 {
    margin: 0 0 14px;
    font-size: 17px;
    font-weight: 450;
    color: var(--pd-text);
    padding-left: 12px;
    border-left: 3px solid var(--pd-primary);
}

.pd-body {
    color: var(--pd-text);
    line-height: 1.85;
    font-size: 15px;
    word-break: break-word;
}

.pd-body img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 12px 0;
    border-radius: 10px;
}

.pd-body code,
.pd-answer {
    padding: 2px 8px;
    background: #f3f5f8;
    border-radius: 6px;
    font-size: 13px;
    color: #0f172a;
}

.pd-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pd-option {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px 16px;
    background: #f8fafc;
    border: 1px solid var(--pd-line);
    border-radius: 12px;
}

.pd-option.is-selectable {
    position: relative;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}

.pd-option.is-selectable:hover {
    border-color: #b7d4ff;
    background: #f3f8ff;
}

.pd-option.is-checked {
    border-color: var(--pd-primary);
    background: var(--pd-primary-soft);
    box-shadow: 0 0 0 1px rgba(22, 119, 255, 0.12);
}

.pd-option.is-correct {
    border-color: #22c55e;
    background: #f0fdf4;
}

.pd-option.is-wrong {
    border-color: #ef4444;
    background: #fef2f2;
}

.pd-option.is-missed {
    border-color: #86efac;
    background: #f7fef9;
}

.pd-option-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.pd-option-label {
    flex: 0 0 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid var(--pd-line);
    font-weight: 450;
    color: var(--pd-primary);
}

.pd-option.is-checked .pd-option-label,
.pd-option.is-correct .pd-option-label {
    background: var(--pd-primary);
    border-color: var(--pd-primary);
    color: #fff;
}

.pd-option.is-correct .pd-option-label {
    background: #16a34a;
    border-color: #16a34a;
}

.pd-option.is-wrong .pd-option-label {
    background: #dc2626;
    border-color: #dc2626;
    color: #fff;
}

.pd-option-content {
    flex: 1;
    min-width: 0;
    color: var(--pd-text);
    line-height: 1.7;
}

.pd-option-content p {
    margin: 0 0 6px;
}

.pd-option-content p:last-child {
    margin-bottom: 0;
}

.pd-option-content img {
    max-width: 100%;
    height: auto;
}

.pd-pill.is-type {
    background: #eef2ff;
    color: #4338ca;
}

.pd-quiz-tip {
    margin-left: 8px;
    font-size: 13px;
    font-weight: 400;
    color: var(--pd-text-3);
}

.pd-quiz-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
}

.pd-result {
    margin-top: 16px;
    padding: 16px 18px;
    border-radius: 12px;
    border: 1px solid var(--pd-line);
    background: #fff;
}

.pd-result-verdict {
    font-size: 16px;
    font-weight: 450;
    margin-bottom: 6px;
}

.pd-result-verdict.is-ok { color: #15803d; }
.pd-result-verdict.is-bad { color: #b91c1c; }
.pd-result-verdict.is-neutral { color: var(--pd-text-2); }

.pd-result-answer {
    color: var(--pd-text);
    font-size: 14px;
    margin-bottom: 8px;
}

.pd-result-extra {
    margin: 0 0 10px;
    font-size: 13px;
    color: var(--pd-text-2);
}

.pd-result-extra a {
    color: var(--pd-primary) !important;
    text-decoration: none !important;
}

.pd-result-extra a:hover {
    text-decoration: underline !important;
}

.pd-result-hint {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--pd-line);
}

.pd-result-hint h3 {
    margin: 0 0 8px;
    font-size: 15px;
}

.pd-result-vip {
    margin-top: 12px;
    padding: 14px 16px;
    border-radius: 10px;
    background: linear-gradient(135deg, #fff7ed, #eff6ff);
    border: 1px solid #fed7aa;
}

.pd-result-vip p {
    margin: 0 0 10px;
    color: var(--pd-text-2);
    font-size: 14px;
}

.pd-sample {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 14px;
    align-items: start;
}

.pd-sample-pane {
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: #f7f8fa;
    border: 1px solid var(--pd-line);
    border-radius: 12px;
    overflow: hidden;
}

.pd-sample-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 0 0 auto;
    padding: 10px 14px;
    background: #eef1f5;
    border-bottom: 1px solid var(--pd-line);
    font-size: 12px;
    font-weight: 450;
    color: var(--pd-text-2);
}

.pd-sample-pane .pd-sample-code,
.pd-sample-pane pre.pd-sample-code {
    margin: 0 !important;
    padding: 14px 16px !important;
    background: #f7f8fa !important;
    color: #1f2329 !important;
    border: 0 !important;
    border-radius: 0 !important;
    font-family: Consolas, "SF Mono", "Courier New", monospace !important;
    font-size: 13px !important;
    line-height: 1.65 !important;
    white-space: pre-wrap;
    word-break: break-word;
    overflow: auto;
    min-height: 0;
    max-height: 320px;
}

.pd-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 32px;
    padding-top: 22px;
    border-top: 1px solid var(--pd-line);
    max-width: none;
}

.pd-actions .pd-btn-solve {
    margin-left: auto;
    margin-right: auto;
}

.pd-btn-solve {
    min-width: 132px;
    gap: 8px;
    background: #1677ff;
    box-shadow: 0 8px 18px rgba(22, 119, 255, 0.22);
}

.pd-btn-solve:hover {
    background: #0958d9;
    color: #fff !important;
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(22, 119, 255, 0.28);
}

.pd-btn-solve .fa {
    font-size: 14px;
}

.pd-btn {
    appearance: none;
    -webkit-appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 128px;
    width: auto;
    height: 40px;
    padding: 0 22px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: #1677ff;
    color: #fff !important;
    text-decoration: none !important;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.01em;
    line-height: 1;
    box-sizing: border-box;
    cursor: pointer;
    box-shadow: none;
    outline: none;
    transition:
        background 0.18s ease,
        border-color 0.18s ease,
        color 0.18s ease,
        box-shadow 0.18s ease,
        transform 0.18s ease;
}

.pd-btn:hover {
    background: #0f66e0;
    color: #fff !important;
    box-shadow: 0 6px 16px rgba(22, 119, 255, 0.22);
}

.pd-btn:active {
    transform: translateY(1px);
    box-shadow: 0 2px 8px rgba(22, 119, 255, 0.16);
}

.pd-btn:focus-visible {
    box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.22);
}

.pd-btn.is-ghost {
    background: #fff;
    color: #4e5969 !important;
    border-color: #e5e7eb;
    box-shadow: none;
}

.pd-btn.is-ghost:hover {
    border-color: rgba(22, 119, 255, 0.35);
    color: #1677ff !important;
    background: #f5f9ff;
    box-shadow: none;
}

.pd-btn.is-ghost:active {
    background: #e8f3ff;
}

.pd-btn.is-disabled {
    opacity: 0.42;
    pointer-events: none;
    cursor: default;
    box-shadow: none;
}

.markdown-body .katex-display {
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 0;
}

/* KaTeX 加载前隐藏含公式区域，避免刷新时 $ 闪烁 */
#problem-detail.is-math-pending .pd-title-text,
#problem-detail.is-math-pending .pd-body,
#problem-detail.is-math-pending .pd-option-content {
    visibility: hidden;
}

.pd-related {
    margin-top: 20px;
    background: var(--pd-surface);
    border: 1px solid var(--pd-line);
    border-radius: 18px;
    box-shadow: var(--pd-shadow);
    overflow: hidden;
}

.pd-related-head {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--pd-line);
}

.pd-related-head h2 {
    margin: 0 0 6px;
    font-size: 18px;
    font-weight: 750;
    letter-spacing: -0.02em;
}

.pd-related-head p {
    margin: 0;
    font-size: 13px;
    color: var(--pd-text-3);
}

.pd-related-list {
    display: flex;
    flex-direction: column;
}

.pd-related-item {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr) 28px;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    border-bottom: 1px solid var(--pd-line);
    text-decoration: none !important;
    color: inherit;
    transition: background 0.18s ease;
}

.pd-related-item:last-child {
    border-bottom: none;
}

.pd-related-item:hover {
    background: var(--pd-primary-soft);
}

.pd-related-no {
    font-size: 13px;
    font-weight: 450;
    color: var(--pd-text-3);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pd-related-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pd-related-main strong {
    font-size: 14px;
    font-weight: 450;
    color: var(--pd-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pd-related-main em {
    font-style: normal;
    font-size: 12px;
    font-weight: 400;
    color: var(--pd-text-3);
}

.pd-related-item:hover .pd-related-main strong,
.pd-related-item:hover .pd-related-no {
    color: var(--pd-primary);
}

.pd-related-go {
    color: var(--pd-text-3);
    text-align: center;
    transition: transform 0.18s ease, color 0.18s ease;
}

.pd-related-item:hover .pd-related-go {
    color: var(--pd-primary);
    transform: translateX(2px);
}

@media (max-width: 767px) {
    .pd-page {
        padding-top: 20px;
    }

    .pd-card {
        padding: 20px 16px 28px;
        border-radius: 14px;
    }

    .pd-title {
        font-size: 22px;
    }

    .pd-head-top {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .pd-fav-btn {
        align-self: flex-start;
    }

    .pd-sample {
        grid-template-columns: 1fr;
    }

    .pd-actions {
        gap: 10px;
    }

    .pd-btn {
        min-width: 120px;
        padding: 0 18px;
    }

    .pd-knowledge {
        flex-direction: column;
        gap: 8px;
    }

    .pd-related-item {
        grid-template-columns: minmax(0, 1fr) 28px;
        padding: 14px 16px;
    }

    .pd-related-no {
        display: none;
    }
}
