/* ===== /questions page (on top of posts.css: header, sort chips, sidebar) ===== */
.qlist-area {
    --ql-green: #15803d;
    --ql-green-soft: rgba(21, 128, 61, 0.1);
}

body.active-dark-mode .qlist-area {
    --ql-green: #4ade80;
    --ql-green-soft: rgba(74, 222, 128, 0.12);
}

/* Persian digits (the theme's heading font has Latin ones) */
.qlist-stat dd,
.qlist-meta,
.qlist-meta *:not(i),
.qlist-user-score,
.qlist-area .plist-subtitle {
    font-family: Dana, Dana-fallback, Tahoma, sans-serif;
}

/* ----- Header with the "ask" button ----- */
.qlist-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px 24px;
    margin-bottom: 24px;
}

.qlist-cta {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 44px;
    padding: 0 20px;
    border-radius: 12px;
    background: var(--color-primary, #49108b);
    font-size: 14px;
    font-weight: 700;
    transition: filter 0.15s ease;
}

.qlist-area .qlist-cta {
    color: #fff;
}

body.active-dark-mode .qlist-area .qlist-cta {
    background: #6d3fd1;
}

.qlist-cta:hover {
    filter: brightness(1.1);
}

.qlist-area .plist-empty .qlist-cta {
    margin-top: 6px;
}

/* ----- Question cards ----- */
.qlist-card {
    position: relative;
    display: flex;
    gap: 20px;
    padding: 20px 22px;
    border: 1px solid var(--pl-border);
    border-radius: 18px;
    background: var(--pl-surface);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.qlist-card:hover,
.qlist-card:focus-within {
    border-color: color-mix(in srgb, var(--pl-accent) 30%, transparent);
    box-shadow: 0 16px 32px rgba(16, 12, 40, 0.08);
    transform: translateY(-2px);
}

.qlist-stats {
    display: flex;
    flex: none;
    flex-direction: column;
    gap: 6px;
    width: 76px;
    margin: 0;
}

.qlist-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 4px;
    border: 1px solid transparent;
    border-radius: 12px;
    color: var(--pl-muted);
    line-height: 1.3;
}

.qlist-stat dd {
    order: -1;
    margin: 0;
    color: var(--pl-text);
    font-size: 17px;
    font-weight: 800;
}

.qlist-stat dt {
    font-size: 12px;
    font-weight: 500;
}

.qlist-stat--answered {
    border-color: color-mix(in srgb, var(--ql-green) 35%, transparent);
    background: var(--ql-green-soft);
    color: var(--ql-green);
}

.qlist-stat--answered dd {
    color: var(--ql-green);
}

.qlist-stat--views dd {
    font-size: 14px;
    font-weight: 600;
}

.qlist-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.qlist-name {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.7;
}

.qlist-area .qlist-name a {
    color: var(--pl-text);
}

/* The whole card opens the question */
.qlist-name a::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
    border-radius: inherit;
}

.qlist-area .qlist-card:hover .qlist-name a {
    color: var(--pl-accent);
}

.qlist-name a:focus-visible {
    outline: none;
}

.qlist-card:has(.qlist-name a:focus-visible) {
    outline: 3px solid color-mix(in srgb, var(--pl-accent) 45%, transparent);
    outline-offset: 2px;
}

.qlist-excerpt {
    display: -webkit-box;
    margin: 0;
    overflow: hidden;
    color: var(--pl-muted);
    font-size: 14px;
    line-height: 1.9;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.qlist-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 16px;
    margin-top: 4px;
}

.qlist-cats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.qlist-cats a {
    position: relative;
    z-index: 2; /* above the card-wide link */
    padding: 3px 10px;
    border-radius: 8px;
    background: var(--pl-accent-soft);
    font-size: 12px;
    font-weight: 600;
}

.qlist-area .qlist-cats a {
    color: var(--pl-accent);
}

.qlist-area .qlist-cats a:hover {
    background: color-mix(in srgb, var(--pl-accent) 18%, transparent);
}

.qlist-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    margin-inline-start: auto;
    color: var(--pl-muted);
    font-size: 13px;
}

.qlist-author {
    position: relative;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
}

.qlist-area .qlist-author {
    color: var(--pl-text);
}

.qlist-area .qlist-author:hover {
    color: var(--pl-accent);
}

.qlist-author img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
}

/* ----- Sidebar: best users ----- */
.qlist-users {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.qlist-users li {
    margin: 0;
}

.qlist-users a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 12px;
    transition: background-color 0.15s ease;
}

.qlist-users a:hover {
    background: var(--pl-surface-2);
}

.qlist-users li:nth-child(n + 4) .plist-rank {
    color: var(--pl-muted);
}

.qlist-users img {
    flex: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.qlist-user-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
    line-height: 1.5;
}

.qlist-user-name {
    overflow: hidden;
    color: var(--pl-text);
    font-size: 14px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.qlist-user-handle {
    overflow: hidden;
    color: var(--pl-muted);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
    direction: ltr;
    text-align: right;
}

.qlist-user-score {
    flex: none;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--pl-accent-soft);
    color: var(--pl-accent);
    font-size: 12px;
    font-weight: 700;
}

/* ----- Phones: stats become one row above the title ----- */
@media (max-width: 575px) {
    .qlist-head .qlist-cta {
        width: 100%;
    }

    .qlist-card {
        flex-direction: column;
        gap: 12px;
        padding: 16px;
    }

    .qlist-stats {
        flex-direction: row;
        width: auto;
    }

    .qlist-stat {
        flex-direction: row;
        gap: 4px;
        padding: 3px 10px;
        border-color: var(--pl-border);
    }

    .qlist-stat dd,
    .qlist-stat--views dd {
        font-size: 14px;
    }

    .qlist-name {
        font-size: 16px;
    }

    .qlist-meta {
        margin-inline-start: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .qlist-card,
    .qlist-users a {
        transition: none;
    }

    .qlist-card:hover,
    .qlist-card:focus-within {
        transform: none;
    }
}

/* ===== /questions/create ===== */
.qform-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

@media (min-width: 992px) {
    .qform-layout {
        grid-template-columns: minmax(0, 1fr) 320px;
    }

    .qform-tips {
        position: sticky;
        top: 96px;
    }
}

.qform-card {
    padding: 28px;
    border: 1px solid var(--pl-border);
    border-radius: 20px;
    background: var(--pl-surface);
}

.qform {
    display: flex;
    flex-direction: column;
    gap: 26px;
}

/* ----- Alerts ----- */
.qform-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(217, 119, 6, 0.12);
    color: #b45309;
    font-size: 14px;
    line-height: 1.8;
}

body.active-dark-mode .qform-alert {
    color: #fbbf24;
}

.qform-alert i {
    margin-top: 5px;
}

.qform-area .qform-alert a {
    color: inherit;
    font-weight: 700;
    text-decoration: underline;
}

.qform-alert--error {
    background: rgba(220, 38, 38, 0.1);
    color: #b91c1c;
}

body.active-dark-mode .qform-alert--error {
    color: #f87171;
}

/* ----- Fields ----- */
.qform-field {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.qform-label-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.qform-field label:not(.qform-chip),
.qform-field legend {
    float: none;
    width: auto;
    margin: 0;
    padding: 0;
    color: var(--pl-text);
    font-size: 16px;
    font-weight: 700;
}

.qform-field legend small {
    color: var(--pl-muted);
    font-size: 13px;
    font-weight: 500;
}

.qform-req {
    color: #dc2626;
}

.qform-hint {
    margin: 4px 0 10px;
    color: var(--pl-muted);
    font-size: 13px;
    line-height: 1.8;
}

.qform-counter {
    flex: none;
    color: var(--pl-muted);
    font-family: Dana, Dana-fallback, Tahoma, sans-serif;
    font-size: 12px;
}

.qform-counter.is-full {
    color: var(--pl-accent);
    font-weight: 700;
}

.qform-area .qform input[type='text'],
.qform-area .qform-filter input {
    width: 100%;
    height: 50px;
    padding: 0 16px;
    border: 1px solid var(--pl-border);
    border-radius: 12px;
    background: var(--pl-surface-2);
    color: var(--pl-text);
    font-family: Dana, Dana-fallback, Tahoma, sans-serif;
    font-size: 15px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

/* The theme styles inputs in dark mode with a stronger selector */
body.active-dark-mode .qform-area .qform input[type='text'],
body.active-dark-mode .qform-area .qform-filter input {
    border-color: var(--pl-border);
    background: var(--pl-surface-2);
    color: var(--pl-text);
}

.qform-area .qform input[type='text']::placeholder,
.qform-area .qform-filter input::placeholder {
    color: var(--pl-muted);
    opacity: 0.8;
}

.qform-area .qform input[type='text']:focus,
.qform-area .qform-filter input:focus {
    border-color: var(--pl-accent);
    background: var(--pl-surface);
    box-shadow: 0 0 0 4px var(--pl-accent-soft);
    outline: none;
}

.qform-area .qform input.is-invalid,
.qform-editor.is-invalid {
    border-color: #dc2626;
}

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

body.active-dark-mode .qform-error {
    color: #f87171;
}

/* ----- Editor ----- */
.qform-editor {
    overflow: hidden;
    min-height: 360px;
    border: 1px solid var(--pl-border);
    border-radius: 12px;
}

.qform-editor .tox-tinymce {
    border: 0;
    border-radius: 0;
}

.qform-editor textarea {
    width: 100%;
    min-height: 360px;
    padding: 12px;
    border: 0;
}

/* ----- Chips (categories, tags) ----- */
.qform-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.qform-chips--scroll {
    max-height: 196px;
    overflow-y: auto;
    padding: 2px;
}

.qform-field.is-invalid .qform-chip span {
    border-color: color-mix(in srgb, #dc2626 45%, transparent);
}

.qform-chip {
    position: relative;
    margin: 0;
    cursor: pointer;
}

.qform-chip[hidden] {
    display: none;
}

.qform-chip input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.qform-chip span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1px solid var(--pl-border);
    border-radius: 999px;
    background: var(--pl-surface-2);
    color: var(--pl-text);
    font-size: 13px;
    font-weight: 600;
    transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.qform-chip span i {
    display: none;
    font-size: 11px;
}

.qform-chip:hover span {
    border-color: color-mix(in srgb, var(--pl-accent) 40%, transparent);
}

.qform-chip input:checked + span {
    border-color: var(--pl-accent);
    background: var(--pl-accent-soft);
    color: var(--pl-accent);
}

.qform-chip input:checked + span i {
    display: inline;
}

.qform-chip input:focus-visible + span {
    outline: 3px solid color-mix(in srgb, var(--pl-accent) 45%, transparent);
    outline-offset: 2px;
}

.qform-chip input:disabled + span {
    cursor: not-allowed;
    opacity: 0.45;
}

.qform-filter {
    position: relative;
    margin-bottom: 10px;
}

.qform-filter i {
    position: absolute;
    top: 50%;
    right: 16px;
    color: var(--pl-muted);
    transform: translateY(-50%);
}

.qform-area .qform-filter input {
    height: 42px;
    padding-right: 40px;
    font-size: 14px;
}

.qform-none {
    margin: 0;
    color: var(--pl-muted);
    font-size: 13px;
}

/* ----- Actions ----- */
.qform-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding-top: 22px;
    border-top: 1px solid var(--pl-border);
}

.qform-actions--center {
    justify-content: center;
    padding-top: 0;
    border: 0;
}

.qform-area button.qform-submit,
.qd-area button.qform-submit {
    width: auto;
    min-width: 160px;
    border: 0;
    cursor: pointer;
}

.qform-area button.qform-submit:disabled,
.qd-area button.qform-submit:disabled {
    cursor: progress;
    opacity: 0.7;
}

.qform-secondary {
    display: inline-flex;
    align-items: center;
    height: 44px;
    padding: 0 18px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
}

.qform-area .qform-secondary {
    color: var(--pl-muted);
}

.qform-area .qform-secondary:hover {
    background: var(--pl-surface-2);
    color: var(--pl-text);
}

/* ----- Tips ----- */
.qform-tips h2 {
    margin: 0 0 14px;
    color: var(--pl-text);
    font-size: 17px;
    font-weight: 800;
}

.qform-tips ol {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 0 0 20px;
    padding: 0;
    list-style: none;
    counter-reset: tip;
}

.qform-tips li {
    position: relative;
    margin: 0;
    padding-right: 34px;
    color: var(--pl-muted);
    font-size: 14px;
    line-height: 1.8;
    counter-increment: tip;
}

.qform-tips li::before {
    content: counter(tip, persian);
    position: absolute;
    top: 1px;
    right: 0;
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 8px;
    background: var(--pl-accent-soft);
    color: var(--pl-accent);
    font-family: Dana, Dana-fallback, Tahoma, sans-serif;
    font-size: 13px;
    font-weight: 800;
}

.qform-tips strong {
    color: var(--pl-text);
}

/* ----- Guest ----- */
.qform-guest {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    max-width: 560px;
    margin: 0 auto;
    padding: 40px 24px;
    text-align: center;
}

.qform-guest-icon {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    border-radius: 20px;
    background: var(--pl-accent-soft);
    color: var(--pl-accent);
    font-size: 26px;
}

.qform-guest h2 {
    margin: 6px 0 0;
    color: var(--pl-text);
    font-size: 20px;
    font-weight: 800;
}

.qform-guest p {
    margin: 0 0 8px;
    color: var(--pl-muted);
}

@media (max-width: 575px) {
    .qform-card {
        padding: 18px 16px;
        border-radius: 16px;
    }

    .qform-area button.qform-submit {
        flex: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .qform-chip span,
    .qform-area .qform input {
        transition: none;
    }
}

/* ===== /questions/{id} details ===== */
.qd-head {
    margin-bottom: 24px;
}

.qd-head-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px 24px;
    margin: 8px 0 10px;
}

.qd-title {
    flex: 1 1 420px;
    margin: 0;
    color: var(--pl-text);
    font-size: 30px;
    font-weight: 800;
    line-height: 1.6;
}

.qd-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    color: var(--pl-muted);
    font-size: 14px;
}

.qd-facts,
.qd-facts *:not(i),
.qd-vote-score,
.qd-answer-time,
.qd-reply-head time,
.qd-related-count,
.qd-chip small {
    font-family: Dana, Dana-fallback, Tahoma, sans-serif;
}

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

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

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

.qd-area > .container > .qform-alert {
    margin-bottom: 20px;
}

/* ----- Cards ----- */
.qd-card {
    border: 1px solid var(--pl-border);
    border-radius: 20px;
    background: var(--pl-surface);
}

.qd-question,
.qd-answer {
    display: flex;
    gap: 20px;
    padding: 24px;
}

.qd-question-main,
.qd-answer-main {
    flex: 1;
    min-width: 0;
}

/* ----- Votes ----- */
.qd-vote {
    display: flex;
    flex: none;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    width: 48px;
}

.qd-area button.qd-vote-btn {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid var(--pl-border);
    border-radius: 50%;
    background: transparent;
    color: var(--pl-muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.qd-area button.qd-vote-btn:hover:not(:disabled) {
    border-color: var(--pl-accent);
    color: var(--pl-accent);
}

.qd-area button.qd-vote-btn.is-active {
    border-color: var(--pl-accent);
    background: var(--pl-accent);
    color: #fff;
}

.qd-area button.qd-vote-btn[data-qd-vote-btn='negative'].is-active {
    border-color: #dc2626;
    background: #dc2626;
}

.qd-area button.qd-vote-btn:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.qd-area button.qd-vote-btn:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--pl-accent) 45%, transparent);
    outline-offset: 2px;
}

.qd-vote-score {
    padding: 4px 0;
    direction: ltr; /* keep the minus sign in front of negative scores */
    unicode-bidi: isolate;
    color: var(--pl-text);
    font-size: 19px;
    font-weight: 800;
}

/* ----- Rich content (question and answers) ----- */
.qd-content {
    color: var(--pl-text);
    font-family: Dana, Dana-fallback, Tahoma, sans-serif; /* loose text would get the theme's heading font */
    font-size: 16px;
    line-height: 2;
    overflow-wrap: anywhere;
}

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

.qd-content > :last-child {
    margin-bottom: 0;
}

.qd-content p,
.qd-content ul,
.qd-content ol,
.qd-content blockquote,
.qd-content table {
    margin: 0 0 16px;
}

.qd-content h2,
.qd-content h3,
.qd-content h4 {
    margin: 24px 0 12px;
    color: var(--pl-text);
    font-size: 20px;
}

.qd-content ul,
.qd-content ol {
    padding-right: 24px;
}

.qd-content li {
    margin-bottom: 6px;
}

.qd-area .qd-content a {
    color: var(--pl-accent);
    text-decoration: underline;
    text-underline-offset: 3px;
}

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

.qd-content blockquote {
    padding: 10px 16px;
    border-right: 4px solid var(--pl-accent);
    border-radius: 8px;
    background: var(--pl-surface-2);
    color: var(--pl-muted);
}

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

.qd-content pre {
    margin: 0 0 16px;
    overflow-x: auto;
    border-radius: 12px;
    direction: ltr;
    text-align: left;
}

.qd-content table {
    display: block;
    width: 100%;
    overflow-x: auto;
    border-collapse: collapse;
}

.qd-content th,
.qd-content td {
    padding: 8px 12px;
    border: 1px solid var(--pl-border);
}

/* ----- Chips ----- */
.qd-taxonomy {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 20px;
}

.plist-widget .qd-taxonomy {
    margin-top: 0;
}

.qd-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border: 1px solid var(--pl-border);
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    transition: border-color 0.15s ease, color 0.15s ease;
}

.qd-area .qd-chip {
    color: var(--pl-text);
}

.qd-area .qd-chip:hover {
    border-color: var(--pl-accent);
    color: var(--pl-accent);
}

.qd-area .qd-chip--cat {
    border-color: transparent;
    background: var(--pl-accent-soft);
    color: var(--pl-accent);
}

.qd-chip small {
    color: var(--pl-muted);
    font-size: 11px;
}

/* ----- Question footer: share + asker ----- */
.qd-question-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--pl-border);
}

.qd-share {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.qd-area .qd-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(--pl-border);
    border-radius: 10px;
    background: transparent;
    color: var(--pl-muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease;
}

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

.qd-asker {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 6px 6px 6px 14px;
    border-radius: 14px;
    background: var(--pl-accent-soft);
}

.qd-asker img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.qd-asker span {
    display: flex;
    flex-direction: column;
    line-height: 1.5;
}

.qd-asker small {
    color: var(--pl-muted);
    font-size: 11px;
}

.qd-area .qd-asker strong {
    color: var(--pl-text);
    font-size: 14px;
}

/* ----- Ad ----- */
.qd-ad {
    display: block;
    margin-top: 20px;
}

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

/* ----- Answers ----- */
.qd-answers {
    margin-top: 36px;
}

.qd-section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px 16px;
    margin-bottom: 14px;
}

.qd-section-head h2,
.qd-respond h2 {
    margin: 0;
    color: var(--pl-text);
    font-size: 22px;
    font-weight: 800;
}

.qd-section-note {
    color: var(--pl-muted);
    font-size: 13px;
}

.qd-answer + .qd-answer {
    border-top: 1px solid var(--pl-border);
}

.qd-answer:target {
    background: color-mix(in srgb, var(--pl-accent) 6%, transparent);
}

.qd-answer-list .qd-answer:first-child {
    border-radius: 20px 20px 0 0;
}

.qd-answer-list .qd-answer:last-child {
    border-radius: 0 0 20px 20px;
}

.qd-answer-list .qd-answer:only-child {
    border-radius: 20px;
}

.qd-answer-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    margin-bottom: 12px;
}

/* Answer's save button sits at the far end of its header */
.qd-answer-head .qd-answer-save {
    margin-inline-start: auto;
}

.qd-person {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
}

.qd-area .qd-person {
    color: var(--pl-text);
}

.qd-area .qd-person:hover {
    color: var(--pl-accent);
}

.qd-person img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.qd-person--sm {
    font-size: 13px;
}

.qd-person--sm img {
    width: 22px;
    height: 22px;
}

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

.qd-area .qd-answer-time {
    margin-inline-start: auto;
    color: var(--pl-muted);
    font-size: 12px;
}

.qd-area .qd-answer-time:hover {
    color: var(--pl-accent);
}

/* ----- Replies ----- */
.qd-replies {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 18px 0 0;
    padding: 0;
    list-style: none;
}

.qd-reply {
    margin: 0;
    padding: 10px 14px;
    border-right: 3px solid var(--pl-border);
    border-radius: 10px;
    background: var(--pl-surface-2);
}

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

.qd-reply p {
    margin: 0;
    color: var(--pl-text);
    font-size: 14px;
    line-height: 1.9;
    white-space: pre-line;
}

.qd-reply-box {
    margin-top: 14px;
}

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

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

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

.qd-reply-form {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-top: 10px;
}

.qd-area .qd-reply-form textarea {
    width: 100%;
    min-height: 90px;
    padding: 10px 14px;
    border: 1px solid var(--pl-border);
    border-radius: 12px;
    background: var(--pl-surface-2);
    color: var(--pl-text);
    font-family: Dana, Dana-fallback, Tahoma, sans-serif;
    font-size: 14px;
    line-height: 1.8;
    resize: vertical;
}

body.active-dark-mode .qd-area .qd-reply-form textarea {
    border-color: var(--pl-border);
    background: var(--pl-surface-2);
    color: var(--pl-text);
}

.qd-area .qd-reply-form textarea:focus {
    border-color: var(--pl-accent);
    box-shadow: 0 0 0 4px var(--pl-accent-soft);
    outline: none;
}

.qd-area button.qd-btn {
    width: auto;
    height: 38px;
    padding: 0 16px;
    border: 0;
    border-radius: 10px;
    background: var(--color-primary, #49108b);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

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

.qd-area button.qd-btn:disabled {
    opacity: 0.6;
}

/* ----- Answer form ----- */
.qd-respond {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 28px;
    padding: 24px;
}

.qd-respond form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 6px;
}

.qd-respond .qform-editor,
.qd-respond .qform-editor textarea {
    min-height: 300px;
}

.qd-login {
    padding: 8px 0 4px;
    color: var(--pl-muted);
    text-align: center;
}

.qd-login p {
    margin: 0 0 12px;
}

/* ----- Sidebar: related ----- */
.qd-related {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.qd-related li {
    margin: 0;
}

.qd-related a {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px;
    border-radius: 12px;
    transition: background-color 0.15s ease;
}

.qd-related a:hover {
    background: var(--pl-surface-2);
}

.qd-related-count {
    display: grid;
    flex: none;
    place-items: center;
    min-width: 30px;
    height: 26px;
    padding: 0 6px;
    border: 1px solid var(--pl-border);
    border-radius: 8px;
    color: var(--pl-muted);
    font-size: 13px;
    font-weight: 700;
}

.qd-related-count.is-answered {
    border-color: transparent;
    background: var(--ql-green-soft);
    color: var(--ql-green);
}

.qd-related-title {
    color: var(--pl-text);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.8;
}

.qd-related a:hover .qd-related-title {
    color: var(--pl-accent);
}

/* Related posts (sidebar) */
.qd-related-posts {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.qd-related-posts li {
    margin: 0;
}

.qd-related-posts a {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px;
    border-radius: 12px;
    transition: background-color 0.15s ease;
}

.qd-related-posts a:hover {
    background: var(--pl-surface-2);
}

.qd-related-posts img {
    flex: none;
    width: 96px;
    height: 54px;
    border-radius: 8px;
    background: var(--pl-surface-2);
    object-fit: cover;
}

.qd-related-posts-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.qd-related-posts-section {
    color: var(--pl-accent);
    font-size: 12px;
    font-weight: 700;
}

.qd-related-posts .qd-related-title {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.qd-related-posts a:hover .qd-related-title {
    color: var(--pl-accent);
}

/* ----- Phones ----- */
@media (max-width: 575px) {
    .qd-title {
        flex-basis: 100%;
        font-size: 22px;
    }

    .qd-head-row .qlist-cta {
        display: none; /* the header already has the questions link; keep the title first */
    }

    .qd-question,
    .qd-answer {
        flex-direction: column;
        gap: 14px;
        padding: 18px 16px;
    }

    .qd-vote {
        flex-direction: row;
        width: auto;
        gap: 8px;
    }

    .qd-area button.qd-vote-btn {
        width: 38px;
        height: 38px;
    }

    .qd-vote-score {
        min-width: 28px;
        text-align: center;
    }

    .qd-respond {
        padding: 18px 16px;
    }

    .qd-asker {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .qd-area button.qd-vote-btn,
    .qd-chip,
    .qd-related a {
        transition: none;
    }
}
