/* ==========================================================================
   Link Detail Page — polished
   ========================================================================== */

.ld-page {
    padding: 20px 10px 48px;
    width: 100%;
}

/* Breadcrumb */
.ld-crumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin-bottom: 18px;
    font-size: 13px;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.7);
}

.ld-crumb a {
    color: #fff;
    transition: color 0.2s;
}

.ld-crumb a:hover { color: #ff9701; }

.ld-crumb a:focus-visible,
.ld-btn:focus-visible,
.ld-tag:focus-visible,
.ld-related-item__main:focus-visible,
.ld-related-item__go:focus-visible,
.ld-panel__more:focus-visible,
.ld-nav__link:focus-visible {
    outline: 2px solid #ff9701;
    outline-offset: 2px;
}

.ld-crumb__sep {
    color: rgba(255, 255, 255, 0.35);
    user-select: none;
}

.ld-crumb__current {
    color: rgba(255, 255, 255, 0.5);
    max-width: min(280px, 50vw);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Grid */
.ld-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
    align-items: start;
}

@media (min-width: 900px) {
    .ld-grid {
        grid-template-columns: minmax(0, 1fr) 292px;
        gap: 22px;
    }

    .ld-side {
        position: sticky;
        top: 12px;
    }
}

/* Main card */
.ld-card {
    background: #fdfdfd;
    border-radius: 10px;
    border: 3px solid rgba(var(--cat-rgb, 118, 118, 118), 0.4);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.ld-card__stripe {
    height: 4px;
    background: rgb(var(--cat-rgb, 118, 118, 118));
}

.ld-card__body {
    padding: 26px 26px 28px;
}

/* Header */
.ld-head {
    display: grid;
    gap: 20px;
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid #ececec;
}

@media (min-width: 640px) {
    .ld-head {
        grid-template-columns: auto 1fr;
        align-items: center;
    }
}

@media (max-width: 639px) {
    .ld-head {
        justify-items: center;
        text-align: center;
    }

    .ld-badges,
    .ld-tags {
        justify-content: center;
    }

    .ld-domain {
        justify-content: center;
    }
}

.ld-icon {
    width: 84px;
    height: 84px;
    border-radius: 10px;
    border: 3px solid #e0e0e0;
    background: #fff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.ld-icon img {
    width: 52px;
    height: 52px;
    object-fit: contain;
}

.ld-icon__letter {
    font-size: 34px;
    font-weight: 700;
    color: rgb(var(--cat-rgb, 118, 118, 118));
    line-height: 1;
    text-transform: uppercase;
}

.ld-head__main { min-width: 0; width: 100%; }

.ld-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.ld-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.35;
}

.ld-badge--new {
    background: #f10e0e;
    color: #fff;
}

.ld-badge--rank {
    background: rgba(var(--cat-rgb, 118, 118, 118), 0.1);
    color: rgb(var(--cat-rgb, 118, 118, 118));
    border: 1px solid rgba(var(--cat-rgb, 118, 118, 118), 0.22);
}

.ld-title {
    margin: 0 0 8px;
    font-size: clamp(1.375rem, 3.5vw, 1.875rem);
    font-weight: 700;
    line-height: 1.2;
    color: #1a1a1a;
    letter-spacing: -0.02em;
    word-break: break-word;
}

.ld-domain {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    font-size: 14px;
    color: #96979f;
}

.ld-domain a {
    color: #767676;
    word-break: break-all;
    transition: color 0.2s;
}

.ld-domain a:hover { color: #ff9701; }

.ld-domain svg {
    flex-shrink: 0;
    opacity: 0.55;
}

.ld-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.ld-tag {
    padding: 4px 12px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.35;
    color: rgb(var(--tag-rgb, 118, 118, 118));
    background: rgba(var(--tag-rgb, 118, 118, 118), 0.08);
    border: 1px solid rgba(var(--tag-rgb, 118, 118, 118), 0.22);
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.ld-tag:hover {
    background: rgb(var(--tag-rgb, 118, 118, 118));
    color: #fff;
    border-color: transparent;
}

/* Actions */
.ld-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 28px;
}

@media (min-width: 520px) {
    .ld-actions {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
    }
}

.ld-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.25;
    border: 3px solid transparent;
    transition: background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s, transform 0.12s;
    cursor: pointer;
    text-align: center;
    white-space: nowrap;
}

.ld-btn:active { transform: scale(0.98); }

.ld-btn--primary {
    flex: 1;
    min-width: min(100%, 220px);
    color: #fff;
    background: #ff9701;
    border-color: #e08600;
    box-shadow: 0 3px 12px rgba(255, 151, 1, 0.28);
}

.ld-btn--primary:hover {
    background: #e08600;
    border-color: #c97700;
    box-shadow: 0 4px 16px rgba(255, 151, 1, 0.35);
}

.ld-btn--ghost {
    color: #4e4e4e;
    background: #fff;
    border-color: #d0d0d0;
}

.ld-btn--ghost:hover {
    border-color: rgb(var(--cat-rgb, 118, 118, 118));
    color: rgb(var(--cat-rgb, 118, 118, 118));
    background: rgba(var(--cat-rgb, 118, 118, 118), 0.04);
}

.ld-btn--invert {
    min-width: auto;
    flex: none;
    background: #fff;
    color: rgb(var(--cat-rgb, 118, 118, 118));
    border-color: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}

.ld-btn--invert:hover {
    background: #f8f8f8;
    border-color: #f8f8f8;
    color: rgb(var(--cat-rgb, 118, 118, 118));
}

/* Lead */
.ld-lead {
    position: relative;
    margin-bottom: 28px;
    padding: 20px 22px 20px 40px;
    background: #f7f8fa;
    border-radius: 10px;
    border: 1px solid #ececec;
    border-left: 4px solid rgb(var(--cat-rgb, 118, 118, 118));
}

.ld-lead::before {
    content: '\201C';
    position: absolute;
    top: 10px;
    left: 14px;
    font-size: 36px;
    line-height: 1;
    color: rgba(var(--cat-rgb, 118, 118, 118), 0.18);
    font-family: Georgia, 'Times New Roman', serif;
    pointer-events: none;
}

.ld-lead__label {
    display: block;
    margin-bottom: 8px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgb(var(--cat-rgb, 118, 118, 118));
}

.ld-lead p {
    margin: 0;
    font-size: 16px;
    line-height: 1.7;
    color: #3a3a3a;
}

/* Empty state */
.ld-empty {
    margin-bottom: 28px;
    padding: 28px 24px;
    text-align: center;
    background: #f7f8fa;
    border-radius: 10px;
    border: 2px dashed #d8d8d8;
}

.ld-empty__title {
    margin: 0 0 8px;
    font-size: 15px;
    font-weight: 600;
    color: #767676;
}

.ld-empty__hint {
    margin: 0;
    font-size: 13px;
    line-height: 1.55;
    color: #96979f;
}

/* Cover */
.ld-cover {
    margin-bottom: 28px;
    border-radius: 10px;
    overflow: hidden;
    border: 3px solid #e8e8e8;
    background: #f2f3f6;
}

.ld-cover img {
    width: 100%;
    display: block;
    vertical-align: middle;
}

/* Prose */
.ld-prose {
    margin-bottom: 8px;
}

.ld-prose__label {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 16px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #96979f;
}

.ld-prose__label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e8e8e8;
}

.ld-prose .entry-content {
    font-size: 16px;
    line-height: 1.8;
    color: #333;
}

.ld-prose .entry-content > *:first-child { margin-top: 0; }
.ld-prose .entry-content > *:last-child { margin-bottom: 0; }

.ld-prose .entry-content p { margin-bottom: 1em; }

.ld-prose .entry-content h2,
.ld-prose .entry-content h3,
.ld-prose .entry-content h4 {
    margin: 1.6em 0 0.5em;
    color: #2a2a2a;
    font-weight: 600;
    line-height: 1.35;
}

.ld-prose .entry-content ul,
.ld-prose .entry-content ol {
    margin: 0 0 1em 1.25em;
    padding: 0;
    list-style: disc;
}

.ld-prose .entry-content li { margin-bottom: 0.35em; }

.ld-prose .entry-content a {
    color: #ff9701;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.ld-prose .entry-content a:hover { color: #e08600; }

.ld-prose .entry-content img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    border: 2px solid #ececec;
    margin: 0.5em 0;
}

.ld-prose .entry-content blockquote {
    margin: 1.2em 0;
    padding: 12px 16px;
    border-left: 4px solid rgb(var(--cat-rgb, 118, 118, 118));
    background: #f7f8fa;
    color: #555;
    border-radius: 0 10px 10px 0;
}

/* CTA */
.ld-cta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 28px;
    padding: 18px 20px;
    border-radius: 10px;
    background: rgb(var(--cat-rgb, 118, 118, 118));
    color: #fff;
}

.ld-cta__text strong {
    display: block;
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
    line-height: 1.3;
}

.ld-cta__text span {
    display: block;
    font-size: 12px;
    line-height: 1.45;
    opacity: 0.88;
    max-width: 420px;
}

/* Sidebar panels */
.ld-side {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.ld-panel {
    background: #fdfdfd;
    border-radius: 10px;
    border: 3px solid rgba(var(--cat-rgb, 118, 118, 118), 0.28);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.07);
    overflow: hidden;
}

.ld-panel__head {
    margin: 0;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #fff;
    background: rgb(var(--cat-rgb, 118, 118, 118));
    line-height: 1.35;
}

.ld-info-list,
.ld-related-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ld-info-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 11px 16px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
    line-height: 1.45;
}

.ld-info-row:last-child { border-bottom: none; }

.ld-info-row__label {
    flex-shrink: 0;
    color: #96979f;
    font-weight: 500;
}

.ld-info-row__value {
    text-align: right;
    color: #4e4e4e;
    word-break: break-word;
}

.ld-info-row__value a {
    color: #ff9701;
    transition: color 0.2s;
}

.ld-info-row__value a:hover { color: #e08600; }

.ld-info-row__value--url a {
    font-size: 12px;
}

/* Related */
.ld-related-item {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid #f0f0f0;
}

.ld-related-item:last-child { border-bottom: none; }

.ld-related-item__main {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 8px 10px 12px;
    color: inherit;
    transition: background 0.15s;
}

.ld-related-item__main:hover {
    background: #f8f9fb;
}

.ld-related-item__main:hover .ld-related-item__name {
    color: #ff9701;
}

.ld-related-item__rank {
    flex-shrink: 0;
    width: 20px;
    padding-top: 6px;
    font-size: 11px;
    font-weight: 700;
    color: #c8c8c8;
    text-align: center;
    line-height: 1;
}

.ld-related-item__icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid #e5e5e5;
    background: #f4f4f4;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.ld-related-item__icon img {
    width: 22px;
    height: 22px;
    object-fit: contain;
}

.ld-related-item__letter {
    font-size: 14px;
    font-weight: 700;
    color: #96979f;
    text-transform: uppercase;
}

.ld-related-item__text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-top: 2px;
}

.ld-related-item__name {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    line-height: 1.35;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color 0.15s;
}

.ld-related-item__desc {
    font-size: 11px;
    line-height: 1.4;
    color: #96979f;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ld-related-item__go {
    flex-shrink: 0;
    width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: center;
    margin-right: 8px;
    height: 32px;
    border-radius: 8px;
    color: #bababa;
    font-size: 15px;
    font-weight: 600;
    border: 2px solid #e5e5e5;
    background: #fff;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.ld-related-item__go:hover {
    border-color: #ff9701;
    color: #ff9701;
    background: #fffaf3;
}

.ld-panel__more {
    display: block;
    padding: 12px 16px;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    color: rgb(var(--cat-rgb, 118, 118, 118));
    border-top: 1px solid #f0f0f0;
    background: #fafafa;
    transition: background 0.15s, color 0.15s;
}

.ld-panel__more:hover {
    background: #f3f4f6;
    color: #ff9701;
}

/* Footer nav */
.ld-nav {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px 28px;
    margin-top: 24px;
    padding-top: 4px;
}

.ld-nav__link {
    font-size: 14px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.88);
    transition: color 0.2s;
}

.ld-nav__link:hover { color: #ff9701; }

/* Dark mode */
body.dark .ld-card,
body.dark .ld-panel {
    background: #2a2b31;
    border-color: #43444b;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}

body.dark .ld-head { border-color: #3a3b42; }
body.dark .ld-title { color: #eee; }
body.dark .ld-domain a { color: #999; }
body.dark .ld-icon {
    background: #1a1b1f;
    border-color: #43444b;
}
body.dark .ld-lead,
body.dark .ld-empty {
    background: #23242a;
    border-color: #3a3b42;
}
body.dark .ld-lead p,
body.dark .ld-empty__title { color: #ccc; }
body.dark .ld-empty__hint { color: #888; }
body.dark .ld-prose .entry-content { color: #ccc; }
body.dark .ld-prose .entry-content h2,
body.dark .ld-prose .entry-content h3 { color: #ddd; }
body.dark .ld-prose .entry-content blockquote {
    background: #23242a;
    color: #aaa;
}
body.dark .ld-btn--ghost {
    background: #2a2b31;
    color: #ccc;
    border-color: #43444b;
}
body.dark .ld-info-row { border-color: #333; }
body.dark .ld-info-row__value { color: #bbb; }
body.dark .ld-related-item { border-color: #333; }
body.dark .ld-related-item__main:hover { background: #23242a; }
body.dark .ld-related-item__name { color: #ddd; }
body.dark .ld-related-item__icon {
    background: #1a1b1f;
    border-color: #43444b;
}
body.dark .ld-related-item__go {
    background: #2a2b31;
    border-color: #43444b;
}
body.dark .ld-panel__more {
    background: #23242a;
    border-color: #333;
}
body.dark .ld-cover {
    border-color: #43444b;
    background: #1a1b1f;
}
body.dark .ld-prose__label::after { background: #43444b; }

/* Mobile */
@media (max-width: 599px) {
    .ld-page { padding: 14px 10px 36px; }
    .ld-card__body { padding: 18px 16px 22px; }
    .ld-icon { width: 72px; height: 72px; }
    .ld-icon img { width: 44px; height: 44px; }
    .ld-head { margin-bottom: 20px; padding-bottom: 20px; }
    .ld-actions { margin-bottom: 22px; }
    .ld-btn { width: 100%; white-space: normal; }
    .ld-lead { padding: 16px 16px 16px 36px; margin-bottom: 22px; }
    .ld-lead p { font-size: 15px; }
    .ld-cta {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    .ld-cta__text span { max-width: none; }
    .ld-cta .ld-btn--invert { width: 100%; }
    .ld-crumb__current { max-width: 160px; }
}

@media (max-width: 899px) {
    .ld-side { order: 2; }
}
