/* ===== Post details page ===== */
.pd-area,
.pd-similar,
.pd-progress {
    --pd-bg: #f6f5fa;
    --pd-surface: #ffffff;
    --pd-surface-2: #f3f2f8;
    --pd-border: rgba(16, 12, 40, 0.08);
    --pd-text: #1f1d2b;
    --pd-body: #34323f;
    --pd-muted: #6b6880;
    --pd-accent: var(--color-primary, #49108b);
    --pd-accent-soft: rgba(73, 16, 139, 0.09);
}

body.active-dark-mode .pd-area,
body.active-dark-mode .pd-similar,
body.active-dark-mode .pd-progress {
    --pd-bg: #111116;
    --pd-surface: #1d1d24;
    --pd-surface-2: #26262f;
    --pd-border: rgba(255, 255, 255, 0.08);
    --pd-text: #f3f3f6;
    --pd-body: #dcdbe4;
    --pd-muted: #a3a1b3;
    --pd-accent: #a98bf5;
    --pd-accent-soft: rgba(169, 139, 245, 0.14);
}

.pd-area {
    padding: 28px 0 56px;
    background: var(--pd-surface);
    color: var(--pd-text);
}

.pd-area a:focus-visible,
.pd-area button:focus-visible,
.pd-area summary:focus-visible,
.pd-area textarea:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--pd-accent) 45%, transparent);
    outline-offset: 2px;
}

/* Persian digits in meta text */
.pd-facts,
.pd-facts *:not(i),
.pd-area .pd-comments-head h2,
.pd-reaction-count,
.pd-comment-head time,
.pd-similar-card time,
.pd-rail-btn span {
    font-family: Dana, Dana-fallback, Tahoma, sans-serif;
}

/* ----- Reading progress ----- */
.pd-progress {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 1100;
    height: 3px;
    pointer-events: none;
}

.pd-progress span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #db2777, var(--pd-accent));
    transform: scaleX(0);
    transform-origin: right;
}

/* ----- Header ----- */
.pd-head {
    max-width: 760px;
    margin: 0 auto 28px;
}

.pd-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
    color: var(--pd-muted);
    font-size: 13px;
}

.pd-area .pd-breadcrumb a {
    color: var(--pd-muted);
}

.pd-area .pd-breadcrumb a:hover {
    color: var(--pd-accent);
}

.pd-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.pd-chips a,
.pd-type {
    padding: 3px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.pd-area .pd-chips a {
    background: var(--pd-accent-soft);
    color: var(--pd-accent);
}

.pd-type {
    background: var(--pd-surface-2);
    color: var(--pd-text);
}

.pd-type--news { background: rgba(190, 18, 60, 0.1); color: #be123c; }
.pd-type--tutorial { background: rgba(15, 118, 110, 0.1); color: #0f766e; }
.pd-type--package { background: rgba(180, 83, 9, 0.1); color: #b45309; }
.pd-type--video { background: rgba(124, 58, 237, 0.1); color: #7c3aed; }

body.active-dark-mode .pd-type--news { color: #fb7185; }
body.active-dark-mode .pd-type--tutorial { color: #2dd4bf; }
body.active-dark-mode .pd-type--package { color: #fbbf24; }
body.active-dark-mode .pd-type--video { color: #c4b5fd; }

.pd-area .pd-title {
    margin: 0 0 14px;
    color: var(--pd-text);
    font-size: 36px;
    font-weight: 800;
    line-height: 1.55;
}

.pd-lead {
    margin: 0 0 20px;
    color: var(--pd-muted);
    font-size: 18px;
    line-height: 2;
}

.pd-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px 24px;
    padding: 14px 0;
    border-top: 1px solid var(--pd-border);
    border-bottom: 1px solid var(--pd-border);
}

.pd-byline {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.pd-byline img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
}

.pd-byline span {
    display: flex;
    flex-direction: column;
    line-height: 1.5;
}

.pd-area .pd-byline strong {
    color: var(--pd-text);
    font-size: 15px;
}

.pd-byline small {
    color: var(--pd-muted);
    font-size: 12px;
}

.pd-area .pd-byline:hover strong {
    color: var(--pd-accent);
}

/* Facts + the "save" button, on the left side of the meta row */
.pd-meta-side {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 18px;
}

.pd-area .pd-rail-btn:disabled {
    opacity: 0.6;
    cursor: progress;
}

.pd-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    margin: 0;
    padding: 0;
    color: var(--pd-muted);
    font-size: 13px;
    list-style: none;
}

.pd-facts li {
    margin: 0;
}

.pd-facts i {
    margin-left: 4px;
}

.pd-area .pd-facts a {
    color: var(--pd-muted);
}

.pd-area .pd-facts a:hover {
    color: var(--pd-accent);
}

/* ----- Cover ----- */
.pd-hero {
    max-width: 960px;
    margin: 0 auto 36px;
    overflow: hidden;
    border-radius: 20px;
    background: var(--pd-surface-2);
    box-shadow: 0 20px 50px rgba(16, 12, 40, 0.12);
}

.pd-hero img,
.pd-hero video {
    display: block;
    width: 100%;
    height: auto;
}

/* ----- Layout: share rail + 760px column ----- */
.pd-layout {
    display: flex;
    justify-content: center;
    gap: 32px;
}

.pd-main {
    width: 100%;
    max-width: 760px;
    min-width: 0;
}

.pd-rail {
    display: none;
}

@media (min-width: 1200px) {
    .pd-rail {
        display: block;
        flex: none;
        order: 2; /* the left side in RTL */
        width: 56px;
    }

    .pd-rail-inner {
        position: sticky;
        top: 110px;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }

    /* Balance the rail on the other side so the column stays centred */
    .pd-layout::before {
        content: '';
        flex: none;
        width: 56px;
    }
}

.pd-area .pd-rail-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    width: 48px;
    min-height: 48px;
    padding: 6px 0;
    border: 1px solid var(--pd-border);
    border-radius: 14px;
    background: var(--pd-surface);
    color: var(--pd-muted);
    font-size: 16px;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.pd-rail-btn span {
    font-size: 11px;
}

.pd-area .pd-rail-btn:hover {
    border-color: var(--pd-accent);
    color: var(--pd-accent);
}

.pd-area .pd-like.is-active {
    border-color: #e11d48;
    background: rgba(225, 29, 72, 0.1);
    color: #e11d48;
}

/* The rail's "save" button (bm-btn--rail) when saved */
.pd-area .pd-rail-btn.bm-btn.is-active {
    border-color: var(--pd-accent);
    background: var(--pd-accent-soft);
    color: var(--pd-accent);
}

.pd-rail-sep {
    width: 24px;
    height: 1px;
    margin: 4px 0;
    background: var(--pd-border);
}

/* ----- Table of contents ----- */
.pd-toc {
    margin: 0 0 28px;
    border: 1px solid var(--pd-border);
    border-radius: 16px;
    background: var(--pd-surface-2);
}

.pd-toc summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 18px;
    color: var(--pd-text);
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
    list-style: none;
}

.pd-toc summary::-webkit-details-marker {
    display: none;
}

.pd-toc summary::after {
    content: '\f107';
    margin-right: auto;
    font-family: 'Font Awesome 5 Pro';
    font-weight: 300;
    transition: transform 0.2s ease;
}

.pd-toc details[open] summary::after {
    transform: rotate(180deg);
}

.pd-toc ol {
    margin: 0;
    padding: 0 18px 16px 18px;
    list-style: none;
    counter-reset: toc;
}

.pd-toc li {
    margin: 0;
    padding: 4px 0;
    counter-increment: toc;
}

.pd-toc li:not(.is-sub)::before {
    content: counter(toc, persian) '.';
    margin-left: 8px;
    color: var(--pd-accent);
    font-family: Dana, Dana-fallback, Tahoma, sans-serif;
    font-weight: 800;
}

.pd-toc li.is-sub {
    padding-right: 22px;
    counter-increment: none;
    font-size: 14px;
}

.pd-area .pd-toc a {
    color: var(--pd-body);
}

.pd-area .pd-toc a:hover {
    color: var(--pd-accent);
}

/* ----- Article body ----- */
.pd-content {
    color: var(--pd-body);
    font-size: 17px;
    line-height: 2.15;
    overflow-wrap: anywhere;
}

.pd-content > :first-child {
    margin-top: 0;
}

.pd-content p,
.pd-content ul,
.pd-content ol,
.pd-content blockquote,
.pd-content figure {
    margin: 0 0 22px;
}

.pd-content h2,
.pd-content h3,
.pd-content h4 {
    margin: 40px 0 14px;
    color: var(--pd-text);
    line-height: 1.6;
    scroll-margin-top: 100px;
}

.pd-content h2 {
    font-size: 26px;
}

.pd-content h3 {
    font-size: 21px;
}

.pd-content h4 {
    font-size: 18px;
}

.pd-content ul,
.pd-content ol {
    padding-right: 26px;
}

.pd-content li {
    margin-bottom: 8px;
}

.pd-area .pd-content a {
    color: var(--pd-accent);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 4px;
}

.pd-content img {
    max-width: 100%;
    height: auto;
    border-radius: 14px;
}

.pd-content figure img {
    display: block;
    margin: 0 auto;
}

.pd-content figcaption {
    margin-top: 8px;
    color: var(--pd-muted);
    font-size: 14px;
    text-align: center;
}

.pd-content blockquote {
    padding: 14px 20px;
    border-right: 4px solid var(--pd-accent);
    border-radius: 10px;
    background: var(--pd-accent-soft);
    color: var(--pd-text);
}

.pd-content blockquote p:last-child {
    margin-bottom: 0;
}

.pd-content :not(pre) > code {
    padding: 2px 6px;
    border-radius: 6px;
    background: var(--pd-surface-2);
    color: var(--pd-accent);
    font-size: 0.88em;
    direction: ltr;
    unicode-bidi: isolate;
}

.pd-content pre {
    margin: 0 0 22px;
    overflow-x: auto;
    border-radius: 14px;
    direction: ltr;
    text-align: left;
}

.pd-content hr {
    margin: 36px 0;
    border: 0;
    border-top: 1px solid var(--pd-border);
}

/* Tables (wrapped in .table-responsive by the page script).
   The theme's app.css sets `td { border: 1px solid #7e7e7e !important }`,
   so the cell borders here need !important to win. */
.pd-content .table-responsive {
    --pd-table-shadow: rgba(16, 12, 40, 0.16);
    margin: 28px 0;
    overflow-x: auto;
    border: 1px solid var(--pd-border);
    border-radius: 14px;
    /* Scroll hints: covers move with the content, shadows stay on the edges,
       so a shadow shows only on a side that has more to scroll to. */
    background:
        linear-gradient(to right, var(--pd-surface) 30%, transparent) left center / 40px 100% no-repeat local,
        linear-gradient(to left, var(--pd-surface) 30%, transparent) right center / 40px 100% no-repeat local,
        radial-gradient(farthest-side at 0 50%, var(--pd-table-shadow), transparent) left center / 14px 100% no-repeat scroll,
        radial-gradient(farthest-side at 100% 50%, var(--pd-table-shadow), transparent) right center / 14px 100% no-repeat scroll,
        var(--pd-surface);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--pd-border) transparent;
}

body.active-dark-mode .pd-content .table-responsive {
    --pd-table-shadow: rgba(0, 0, 0, 0.55);
}

.pd-content .table-responsive:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--pd-accent) 45%, transparent);
    outline-offset: 2px;
}

.pd-content table:not(.hljs-ln) {
    width: 100%;
    margin: 0;
    border-collapse: collapse;
    background: transparent;
    font-family: Dana, Dana-fallback, Tahoma, sans-serif;
    font-size: 15px;
    line-height: 1.85;
}

.pd-content table:not(.hljs-ln) td,
.pd-content table:not(.hljs-ln) th {
    min-width: 96px;
    padding: 13px 18px;
    border: 0 !important;
    border-bottom: 1px solid var(--pd-border) !important;
    background: transparent;
    color: var(--pd-body);
    font-weight: 400;
    text-align: right;
    vertical-align: middle;
    overflow-wrap: break-word;
    transition: background-color 0.15s ease;
}

.pd-content table:not(.hljs-ln) tr {
    background: transparent;
}

.pd-content table:not(.hljs-ln) > :last-child > tr:last-child > td,
.pd-content table:not(.hljs-ln) > :last-child > tr:last-child > th {
    border-bottom: 0 !important;
}

/* Header row: a real <thead>, or the first row when the editor leaves it out */
.pd-content table:not(.hljs-ln) thead th,
.pd-content table:not(.hljs-ln) thead td,
.pd-content table:not(.hljs-ln):not(:has(thead)) tr:first-child > * {
    padding-top: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid color-mix(in srgb, var(--pd-accent) 28%, transparent) !important;
    background: var(--pd-accent-soft);
    color: var(--pd-accent);
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
}

/* First column reads as the row label */
.pd-content table:not(.hljs-ln) tbody tr > :first-child,
.pd-content table:not(.hljs-ln) tbody th {
    color: var(--pd-text);
    font-weight: 600;
}

.pd-content table:not(.hljs-ln):not(:has(thead)) tr:first-child > :first-child {
    font-weight: 700;
}

/* Zebra rows (skipping the header row when it lives in tbody) */
.pd-content table:not(.hljs-ln) thead ~ tbody tr:nth-child(even) > *,
.pd-content table:not(.hljs-ln):not(:has(thead)) tr:not(:first-child):nth-child(odd) > * {
    background: color-mix(in srgb, var(--pd-text) 3%, transparent);
}

@media (hover: hover) {
    .pd-content table:not(.hljs-ln) thead ~ tbody tr:hover > *,
    .pd-content table:not(.hljs-ln):not(:has(thead)) tr:not(:first-child):hover > * {
        background: color-mix(in srgb, var(--pd-accent) 7%, transparent);
    }
}

.pd-content table:not(.hljs-ln) caption {
    caption-side: bottom;
    padding: 10px 16px;
    border-top: 1px solid var(--pd-border);
    color: var(--pd-muted);
    font-size: 13px;
    text-align: center;
}

.pd-content table:not(.hljs-ln) :not(pre) > code {
    font-size: 0.85em;
    white-space: nowrap;
}

.pd-content table:not(.hljs-ln) p {
    margin: 0;
}

/* ----- Tags ----- */
.pd-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 32px 0;
}

.pd-tags a {
    padding: 4px 12px;
    border: 1px solid var(--pd-border);
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    transition: border-color 0.15s ease, color 0.15s ease;
}

.pd-area .pd-tags a {
    color: var(--pd-muted);
}

.pd-area .pd-tags a:hover {
    border-color: var(--pd-accent);
    color: var(--pd-accent);
}

/* ----- Cards ----- */
.pd-card {
    margin-bottom: 24px;
    padding: 22px 24px;
    border: 1px solid var(--pd-border);
    border-radius: 18px;
    background: var(--pd-surface-2);
}

/* ----- Feedback: reactions + share ----- */
.pd-feedback h2 {
    margin: 0 0 14px;
    color: var(--pd-text);
    font-size: 17px;
    font-weight: 800;
    text-align: center;
}

.pd-reactions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.pd-area .pd-reaction {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: auto;
    height: 46px;
    padding: 0 16px;
    border: 1px solid var(--pd-border);
    border-radius: 999px;
    background: var(--pd-surface);
    color: var(--pd-text);
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
}

.pd-area .pd-reaction:hover {
    border-color: var(--pd-accent);
    transform: translateY(-2px);
}

.pd-area .pd-reaction.is-active {
    border-color: var(--pd-accent);
    background: var(--pd-accent-soft);
    color: var(--pd-accent);
}

.pd-reaction-emoji {
    font-size: 22px;
    line-height: 1;
}

.pd-reaction.is-active .pd-reaction-emoji {
    animation: pd-pop 0.3s ease;
}

@keyframes pd-pop {
    50% { transform: scale(1.3); }
}

.pd-reaction-count {
    font-size: 14px;
    font-weight: 700;
}

.pd-feedback-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px dashed var(--pd-border);
}

.pd-share {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    color: var(--pd-muted);
    font-size: 13px;
}

.pd-area .pd-share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: auto;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--pd-border);
    border-radius: 10px;
    background: var(--pd-surface);
    color: var(--pd-muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.pd-area .pd-share-btn:hover {
    border-color: var(--pd-accent);
    color: var(--pd-accent);
}

.pd-donate {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 12px;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    font-size: 13px;
    font-weight: 800;
}

.pd-area .pd-donate {
    color: #fff;
}

.pd-donate:hover {
    filter: brightness(1.08);
}

/* ----- Author ----- */
.pd-author {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.pd-author-avatar img {
    width: 72px;
    height: 72px;
    border: 3px solid var(--pd-surface);
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 0 0 2px var(--pd-accent-soft);
}

.pd-author-body {
    flex: 1;
    min-width: 0;
}

.pd-author-body small {
    color: var(--pd-muted);
    font-size: 12px;
}

.pd-area .pd-author-name {
    display: block;
    color: var(--pd-text);
    font-size: 18px;
    font-weight: 800;
}

.pd-author-bio {
    margin-top: 6px;
    color: var(--pd-body);
    font-size: 14px;
    line-height: 1.9;
    font-family: var(--secondary-font), 'serif';
}

.pd-author-bio p {
    margin: 0;
}

.pd-author-socials {
    display: flex;
    gap: 6px;
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
}

.pd-author-socials li {
    margin: 0;
}

.pd-area .pd-author-socials a {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--pd-border);
    border-radius: 10px;
    color: var(--pd-muted);
}

.pd-area .pd-author-socials a:hover {
    border-color: var(--pd-accent);
    color: var(--pd-accent);
}

.pd-area .pd-author-more {
    flex: none;
    align-self: center;
    color: var(--pd-accent);
    font-size: 13px;
    font-weight: 700;
}

/* ----- Ad ----- */
.pd-ad {
    position: relative;
    display: block;
    margin-bottom: 24px;
}

.pd-ad img {
    width: 100%;
    height: auto;
    border-radius: 14px;
}

.pd-ad span {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 2px 8px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 11px;
}

/* ----- Comments ----- */
.pd-comments {
    margin-top: 40px;
    scroll-margin-top: 90px;
}

.pd-comments-head h2 {
    margin: 0 0 16px;
    color: var(--pd-text);
    font-size: 22px;
    font-weight: 800;
}

.pd-comment-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pd-comment-form-head {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pd-comment-form-head img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.pd-comment-form-head label {
    margin: 0;
    color: var(--pd-text);
    font-size: 15px;
    font-weight: 700;
}

.pd-area .pd-comments textarea {
    width: 100%;
    min-height: 110px;
    padding: 12px 14px;
    border: 1px solid var(--pd-border);
    border-radius: 12px;
    background: var(--pd-surface);
    color: var(--pd-text);
    font-family: Dana, Dana-fallback, Tahoma, sans-serif;
    font-size: 15px;
    line-height: 1.9;
    resize: vertical;
}

body.active-dark-mode .pd-area .pd-comments textarea {
    border-color: var(--pd-border);
    background: var(--pd-surface);
    color: var(--pd-text);
}

.pd-area .pd-comments textarea:focus {
    border-color: var(--pd-accent);
    box-shadow: 0 0 0 4px var(--pd-accent-soft);
    outline: none;
}

.pd-comment-form-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.pd-comment-form-foot small {
    color: var(--pd-muted);
    font-size: 12px;
}

.pd-area button.pd-btn,
.pd-area a.pd-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    height: 42px;
    padding: 0 20px;
    border: 0;
    border-radius: 12px;
    background: var(--color-primary, #49108b);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

body.active-dark-mode .pd-area .pd-btn {
    background: #6d3fd1;
}

.pd-area .pd-btn:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.pd-area .pd-btn--sm {
    height: 36px;
    padding: 0 14px;
    font-size: 13px;
}

.pd-form-error {
    margin: 0;
    color: #dc2626;
    font-size: 13px;
    font-weight: 600;
}

.pd-login {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px 18px;
}

.pd-login > div {
    display: flex;
    flex: 1 1 200px;
    flex-direction: column;
}

.pd-login strong {
    color: var(--pd-text);
}

.pd-login span {
    color: var(--pd-muted);
    font-size: 14px;
}

.pd-login-icon {
    display: grid;
    flex: none;
    place-items: center;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--pd-accent-soft);
    color: var(--pd-accent);
    font-size: 22px;
}

.pd-comments-empty {
    color: var(--pd-muted);
    text-align: center;
}

.pd-comment-list,
.pd-replies {
    margin: 0;
    padding: 0;
    list-style: none;
}

.pd-comment {
    display: flex;
    gap: 12px;
    margin: 0;
    padding: 18px 0;
}

.pd-comment-list > .pd-comment + .pd-comment {
    border-top: 1px solid var(--pd-border);
}

.pd-comment-avatar {
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.pd-comment--reply .pd-comment-avatar {
    width: 32px;
    height: 32px;
}

.pd-comment-main {
    flex: 1;
    min-width: 0;
}

.pd-comment-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
    margin-bottom: 4px;
    color: var(--pd-muted);
    font-size: 12px;
}

.pd-area .pd-comment-head a {
    color: var(--pd-text);
    font-size: 14px;
    font-weight: 700;
}

.pd-area .pd-comment-head a:hover {
    color: var(--pd-accent);
}

.pd-badge {
    padding: 1px 8px;
    border-radius: 6px;
    background: var(--pd-accent-soft);
    color: var(--pd-accent);
    font-size: 11px;
    font-weight: 700;
}

.pd-comment-text {
    margin: 0;
    color: var(--pd-body);
    font-size: 15px;
    line-height: 1.95;
    white-space: pre-line;
}

.pd-replies {
    margin-top: 6px;
    padding-right: 14px;
    border-right: 2px solid var(--pd-border);
}

.pd-comment--reply {
    padding: 12px 0 4px;
}

.pd-reply-box {
    margin-top: 8px;
}

.pd-reply-box summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--pd-muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
}

.pd-reply-box summary::-webkit-details-marker {
    display: none;
}

.pd-reply-box summary:hover,
.pd-reply-box[open] summary {
    color: var(--pd-accent);
}

.pd-reply-box form {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin-top: 8px;
}

.pd-area .pd-reply-box textarea {
    min-height: 80px;
}

/* ----- Similar posts ----- */
.pd-similar {
    padding: 48px 0 64px;
    background: var(--pd-bg);
}

.pd-similar-title {
    margin: 0 0 20px;
    color: var(--pd-text);
    font-size: 24px;
    font-weight: 800;
}

.pd-similar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
    gap: 20px;
}

.pd-similar-card {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--pd-border);
    border-radius: 16px;
    background: var(--pd-surface);
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.pd-similar-card:hover,
.pd-similar-card:focus-within {
    border-color: color-mix(in srgb, var(--pd-accent) 35%, transparent);
    transform: translateY(-3px);
}

.pd-similar-thumb {
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: var(--pd-surface-2);
}

.pd-similar-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pd-similar-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px 16px 16px;
}

.pd-similar-cat {
    color: var(--pd-accent);
    font-size: 12px;
    font-weight: 700;
}

.pd-similar-body h3 {
    display: -webkit-box;
    margin: 0;
    overflow: hidden;
    font-size: 15px;
    font-weight: 800;
    line-height: 1.75;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.pd-similar .pd-similar-body h3 a {
    color: var(--pd-text);
}

.pd-similar-body h3 a::after {
    content: '';
    position: absolute;
    inset: 0;
}

.pd-similar .pd-similar-card:hover h3 a {
    color: var(--pd-accent);
}

.pd-similar-card time {
    color: var(--pd-muted);
    font-size: 12px;
}

/* ----- Related questions (under the similar posts) ----- */
.pd-similar + .pd-questions {
    padding-top: 0;
}

.pd-questions-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}

.pd-questions-head .pd-similar-title {
    margin: 0;
}

.pd-similar .pd-questions-ask {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--pd-accent-soft);
    color: var(--pd-accent);
    font-size: 14px;
    font-weight: 700;
}

.pd-similar .pd-questions-ask:hover {
    background: var(--pd-accent);
    color: #fff;
}

.pd-questions-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.pd-questions-list li {
    margin: 0;
}

.pd-similar .pd-questions-list a {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    height: 100%;
    padding: 14px 16px;
    border: 1px solid var(--pd-border);
    border-radius: 16px;
    background: var(--pd-surface);
    color: var(--pd-text);
    transition: border-color 0.2s ease, transform 0.2s ease;
}

.pd-similar .pd-questions-list a:hover,
.pd-similar .pd-questions-list a:focus-visible {
    border-color: color-mix(in srgb, var(--pd-accent) 35%, transparent);
    transform: translateY(-2px);
}

.pd-questions-count {
    display: flex;
    flex: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 52px;
    padding: 6px 8px;
    border: 1px solid var(--pd-border);
    border-radius: 12px;
    color: var(--pd-muted);
    font-family: Dana, Dana-fallback, Tahoma, sans-serif;
    font-size: 16px;
    font-weight: 800;
    line-height: 1.3;
}

.pd-questions-count small {
    font-size: 11px;
    font-weight: 600;
}

.pd-questions-count.is-answered {
    border-color: transparent;
    background: rgba(22, 163, 74, 0.12);
    color: #15803d;
}

body.active-dark-mode .pd-questions-count.is-answered {
    background: rgba(74, 222, 128, 0.14);
    color: #4ade80;
}

.pd-questions-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.pd-questions-title {
    display: -webkit-box;
    overflow: hidden;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.8;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.pd-similar .pd-questions-list a:hover .pd-questions-title {
    color: var(--pd-accent);
}

.pd-questions-body time {
    color: var(--pd-muted);
    font-family: Dana, Dana-fallback, Tahoma, sans-serif;
    font-size: 12px;
}

@media (prefers-reduced-motion: reduce) {
    .pd-similar .pd-questions-list a,
    .pd-similar .pd-questions-list a:hover {
        transition: none;
        transform: none;
    }
}

/* ----- Phones ----- */
@media (max-width: 575px) {
    .pd-area {
        padding-top: 18px;
    }

    .pd-area .pd-title {
        font-size: 25px;
    }

    .pd-lead {
        font-size: 16px;
    }

    .pd-hero {
        margin-right: -16px;
        margin-left: -16px;
        border-radius: 0;
    }

    .pd-content {
        font-size: 16px;
        line-height: 2.05;
    }

    .pd-content h2 {
        font-size: 22px;
    }

    .pd-content .table-responsive {
        margin: 22px 0;
        border-radius: 12px;
    }

    .pd-content table:not(.hljs-ln) {
        font-size: 14px;
    }

    .pd-content table:not(.hljs-ln) td,
    .pd-content table:not(.hljs-ln) th {
        min-width: 88px;
        padding: 11px 14px;
    }

    .pd-card {
        padding: 18px 16px;
    }

    .pd-author {
        flex-wrap: wrap;
    }

    .pd-feedback-foot {
        justify-content: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    .pd-reaction,
    .pd-similar-card,
    .pd-toc summary::after {
        transition: none;
    }

    .pd-reaction.is-active .pd-reaction-emoji {
        animation: none;
    }

    .pd-area .pd-reaction:hover,
    .pd-similar-card:hover {
        transform: none;
    }
}
