:root {
    --bg: #030303;
    --surface: #1a1a1b;
    --card: #272729;
    --ink: #d7dadc;
    --ink-bright: #ffffff;
    --muted: #818384;
    --line: #343536;
    --orange: #ff4500;
    --upvote: #ff4500;
    --downvote: #7193ff;
    --link: #4fbcff;
    --max: 1240px;
    --sans: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
    --radius: 4px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body.rd-body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--sans);
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; height: auto; }

.rd-preview {
    background: var(--orange);
    color: #fff;
    text-align: center;
    padding: .45rem;
    font-weight: 700;
    font-size: .85rem;
    position: relative;
    z-index: 60;
}
.rd-preview a { text-decoration: underline; }

/* —— Header —— */
.rd-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}
.rd-header-inner {
    width: min(var(--max), calc(100% - 1.5rem));
    margin: 0 auto;
    min-height: 48px;
    display: flex;
    align-items: center;
    gap: 1rem;
}
.rd-brand {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    flex-shrink: 0;
}
.rd-logo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background:
        radial-gradient(circle at 50% 55%, #fff 0 18%, transparent 19%),
        linear-gradient(145deg, #ff4500, #ff8717);
    box-shadow: inset 0 0 0 2px #fff;
    position: relative;
}
.rd-logo::before,
.rd-logo::after {
    content: "";
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
    top: 8px;
}
.rd-logo::before { left: 7px; }
.rd-logo::after { right: 7px; }
.rd-brand-name {
    font-weight: 700;
    color: var(--ink-bright);
    letter-spacing: -.02em;
}
.rd-search {
    flex: 1;
    max-width: 560px;
    display: flex;
    align-items: center;
    gap: .55rem;
    margin: 0 auto;
    background: #272729;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: .45rem .9rem;
    color: var(--muted);
}
.rd-search:focus-within {
    border-color: var(--ink-bright);
    background: #1a1a1b;
}
.rd-search input {
    flex: 1;
    border: 0;
    outline: none;
    background: transparent;
    color: var(--ink-bright);
    font: inherit;
    font-size: .9rem;
}
.rd-tools {
    display: flex;
    align-items: center;
    gap: .45rem;
    margin-left: auto;
}
.rd-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .4rem .9rem;
    border-radius: 999px;
    font: inherit;
    font-size: .85rem;
    font-weight: 700;
    border: 1px solid transparent;
}
.rd-btn-primary {
    background: var(--orange);
    color: #fff;
}
.rd-btn-primary:hover { filter: brightness(1.08); }
.rd-btn-ghost {
    border-color: var(--orange);
    color: var(--orange);
}
.rd-btn-ghost:hover { background: rgba(255, 69, 0, 0.12); }
.rd-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: grid;
    place-content: center;
    background: #343536;
    color: var(--ink-bright);
    font-weight: 700;
    font-size: .85rem;
}

.rd-main {
    width: min(var(--max), 100%);
    margin: 0 auto;
    padding: 1rem .75rem 2.5rem;
}
.rd-shell {
    display: grid;
    grid-template-columns: 240px minmax(0, 640px) 300px;
    gap: 1rem;
    justify-content: center;
    align-items: start;
}
.rd-shell-solo {
    display: block;
    max-width: 640px;
    margin: 2rem auto;
}

.rd-col-left,
.rd-col-right {
    position: sticky;
    top: 64px;
    max-height: calc(100vh - 80px);
    overflow: auto;
    scrollbar-width: thin;
}

.rd-side-card,
.rd-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: .75rem;
    margin-bottom: .75rem;
}
.rd-side-card h2 {
    margin: 0 0 .65rem;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
}
.rd-side-link {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .55rem .5rem;
    border-radius: 4px;
    font-weight: 600;
    font-size: .9rem;
    color: var(--ink);
}
.rd-side-link:hover,
.rd-side-link.is-active { background: rgba(255,255,255,.04); }
.rd-ico {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    background: var(--card);
}
.rd-ico-home { background: var(--orange); }
.rd-ico-fire { background: #ff8717; }
.rd-ico-new { background: #46d160; }

.rd-comm-list,
.rd-discover {
    list-style: none;
    margin: 0;
    padding: 0;
}
.rd-comm-list li { margin: .1rem 0; }
.rd-comm-list a {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .45rem .4rem;
    border-radius: 4px;
    font-size: .88rem;
}
.rd-comm-list a:hover,
.rd-comm-list a.is-active { background: rgba(255,255,255,.04); }
.rd-comm-dot,
.rd-comm-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: grid;
    place-content: center;
    background: var(--c, var(--orange));
    color: #fff;
    font-size: .65rem;
    font-weight: 800;
    flex-shrink: 0;
}
.rd-muted { color: var(--muted); font-size: .85rem; }

.rd-pin {
    display: block;
    padding: .55rem;
    border-radius: 4px;
    background: var(--card);
}
.rd-pin strong {
    display: block;
    margin-bottom: .3rem;
    color: var(--ink-bright);
    font-size: .92rem;
}
.rd-pin span { font-size: .82rem; color: var(--muted); line-height: 1.4; }

.rd-trend-list,
.rd-rules {
    margin: 0;
    padding: 0;
    list-style: none;
}
.rd-trend-list li {
    display: flex;
    gap: .65rem;
    padding: .5rem 0;
    border-top: 1px solid var(--line);
}
.rd-trend-list li:first-child { border-top: 0; }
.rd-trend-list span {
    width: 18px;
    color: var(--muted);
    font-weight: 700;
    font-size: .85rem;
}
.rd-trend-list a {
    display: block;
    color: var(--ink-bright);
    font-weight: 600;
    font-size: .9rem;
    line-height: 1.3;
}
.rd-trend-list a:hover { color: var(--link); }
.rd-trend-list small {
    display: block;
    margin-top: .15rem;
    color: var(--muted);
    font-size: .75rem;
}
.rd-rules {
    list-style: decimal;
    padding-left: 1.2rem;
    color: var(--ink);
    font-size: .88rem;
    line-height: 1.55;
}
.rd-rules li { margin: .35rem 0; }
.rd-discover li {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .45rem 0;
    border-top: 1px solid var(--line);
}
.rd-discover li:first-child { border-top: 0; }
.rd-discover li > div { flex: 1; min-width: 0; }
.rd-discover strong { display: block; font-size: .88rem; color: var(--ink-bright); }
.rd-discover small { color: var(--muted); font-size: .75rem; }
.rd-join {
    padding: .3rem .65rem;
    border-radius: 999px;
    border: 1px solid var(--ink-bright);
    font-size: .75rem;
    font-weight: 700;
    color: var(--ink-bright);
}
.rd-join:hover { background: rgba(255,255,255,.08); }

/* —— Sort / composer —— */
.rd-sortbar {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    align-items: center;
}
.rd-sortbar a {
    padding: .45rem .75rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: .85rem;
    color: var(--muted);
}
.rd-sortbar a:hover { background: rgba(255,255,255,.04); color: var(--ink); }
.rd-sortbar a.is-active {
    background: rgba(255, 69, 0, 0.15);
    color: var(--orange);
}
.rd-sortbar h1 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--ink-bright);
    width: 100%;
}
.rd-composer {
    display: flex;
    align-items: center;
    gap: .65rem;
}
.rd-composer-input {
    flex: 1;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: .65rem .85rem;
    color: var(--muted);
    font-size: .9rem;
}
.rd-composer-input:hover { border-color: var(--ink); }
.rd-composer-tools {
    display: flex;
    gap: .45rem;
    color: var(--muted);
}

/* —— Posts —— */
.rd-feed { display: flex; flex-direction: column; gap: .65rem; }
.rd-post {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}
.rd-post:hover { border-color: #4a4a4b; }
.rd-post.is-pinned { border-color: rgba(255, 69, 0, 0.45); }
.rd-votes {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .2rem;
    padding: .55rem .2rem;
    background: #161617;
    font-size: .75rem;
    font-weight: 700;
    color: var(--ink-bright);
}
.rd-vote-btn {
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: .7rem;
    line-height: 1;
    padding: .25rem;
    border-radius: 2px;
}
.rd-vote-btn:hover { background: rgba(255,255,255,.06); }
.rd-vote-btn.is-on[data-rd-up],
[data-rd-up].is-on { color: var(--upvote); }
.rd-vote-btn.is-on[data-rd-down],
[data-rd-down].is-on { color: var(--downvote); }

.rd-post-body { padding: .55rem .75rem .65rem; min-width: 0; }
.rd-post-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .25rem .4rem;
    font-size: .75rem;
    color: var(--muted);
    margin-bottom: .35rem;
}
.rd-sub {
    color: var(--ink-bright);
    font-weight: 700;
}
.rd-sub:hover { text-decoration: underline; }
.rd-badge {
    display: inline-flex;
    padding: .1rem .4rem;
    border-radius: 2px;
    background: rgba(255, 69, 0, 0.2);
    color: var(--orange);
    font-size: .68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.rd-sub-name { display: none; }
.rd-post-title {
    margin: 0 0 .4rem;
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--ink-bright);
}
.rd-post-title a:hover { color: var(--link); }
.rd-post-excerpt {
    margin: 0 0 .65rem;
    font-size: .9rem;
    line-height: 1.45;
    color: var(--ink);
}
.rd-post-media {
    display: block;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: #000;
    margin-bottom: .55rem;
}
.rd-post-media img,
.rd-post-media-static img {
    width: 100%;
    max-height: 420px;
    object-fit: cover;
}
.rd-post-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
}
.rd-post-actions a,
.rd-post-actions button {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    border: 0;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: .78rem;
    font-weight: 700;
    padding: .35rem .55rem;
    border-radius: 2px;
    cursor: pointer;
}
.rd-post-actions a:hover,
.rd-post-actions button:hover {
    background: rgba(255,255,255,.05);
    color: var(--ink);
}
.rd-post-actions .is-copied { color: var(--link); }

.rd-community-hero { padding: 0; overflow: hidden; }
.rd-comm-banner {
    height: 72px;
    background: linear-gradient(90deg, var(--c, var(--orange)), #ff8717);
}
.rd-community-head {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .85rem;
}
.rd-community-head h1 {
    margin: 0;
    font-size: 1.35rem;
    color: var(--ink-bright);
}
.rd-community-head .rd-btn { margin-left: auto; }
.rd-comm-avatar { width: 56px; height: 56px; font-size: .9rem; margin-top: -28px; border: 4px solid var(--surface); }

.rd-lead {
    margin: 0 0 1rem;
    color: var(--muted);
    font-size: 1.02rem;
}
.rd-prose {
    color: var(--ink);
    line-height: 1.65;
    font-size: .98rem;
    margin-bottom: 1rem;
}
.rd-prose p { margin: 0 0 1rem; }
.rd-prose img {
    width: 100%;
    height: auto;
    border-radius: 4px;
    margin: .75rem 0;
}
.rd-related-title {
    margin: 0;
    font-size: 1rem;
    color: var(--ink-bright);
}
.rd-empty { text-align: center; color: var(--muted); padding: 1.5rem; }
.rd-empty-page h1 { margin: 0 0 .5rem; color: var(--ink-bright); }

.rd-footer {
    border-top: 1px solid var(--line);
    padding: 1.25rem .75rem 2rem;
    color: var(--muted);
    font-size: .78rem;
    text-align: center;
}
.rd-footer-inner { width: min(var(--max), 100%); margin: 0 auto; }
.rd-footer p { margin: 0 0 .25rem; }

@media (max-width: 1100px) {
    .rd-shell { grid-template-columns: 200px minmax(0, 1fr); }
    .rd-col-right { display: none; }
}
@media (max-width: 820px) {
    .rd-shell { grid-template-columns: 1fr; }
    .rd-col-left { display: none; }
    .rd-btn-ghost { display: none; }
    .rd-search { max-width: none; }
}
@media (max-width: 520px) {
    .rd-tools .rd-btn-primary { display: none; }
    .rd-post-title { font-size: 1rem; }
}
