:root {
    --tp-bg: #0b1020;
    --tp-card: #141a2d;
    --tp-accent: #6decb9;
    --tp-text: #e7ebf3;
    --tp-sub: #9aa6c1;
}

html,
body {
    margin: 0;
    padding: 0;
    background: var(--tp-bg);
    color: var(--tp-text);
    font: 16px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial;
}

h1,
h2,
h3 {
    margin: 0 0 .5rem
}

button,
input,
select,
textarea {
    border-radius: 10px;
    border: 1px solid #27304a;
    background: #0e1527;
    color: var(--tp-text);
    padding: .6rem .8rem
}

button {
    cursor: pointer
}

a {
    color: var(--tp-accent);
    text-decoration: none
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 1rem
}

h1.title {
    color: #FFFFFF;
}

.card {
    background: var(--tp-card);
    border: 1px solid #27304a;
    border-radius: 16px;
    padding: 1rem;
    margin: 1rem 0;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .25)
}

.row {
    display: flex;
    gap: .75rem;
    align-items: center;
    flex-wrap: wrap
}

.badge {
    display: inline-block;
    font-size: .75rem;
    padding: .15rem .5rem;
    border-radius: 999px;
    border: 1px solid #355;
    color: var(--tp-accent)
}

.muted {
    color: var(--tp-sub)
}

.btn-primary {
    background: var(--tp-accent);
    color: #071018;
    border: 0
}

.btn-ghost {
    background: transparent;
    border: 1px dashed #355
}

body {
    font-family: Arial, sans-serif;
    margin: 20px;
}

h1 {
    color: #333;
}

form {
    margin-bottom: 20px;
}

input,
textarea {
    display: block;
    margin-bottom: 10px;
    padding: 10px;
    width: 100%;
    max-width: 500px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

button {
    background-color: #007BFF;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

button:hover {
    background-color: #0056b3;
}

.post {
    border: 1px solid #ccc;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 4px;
    background-color: #f9f9f9;
}

.selected {
    background-color: lightblue;
    border: 2px solid blue;
}

.post-list {
    padding: 1rem;
}

.post-list h2 {
    margin-bottom: 0.5rem;
}

.post-list .sort-container {
    margin-bottom: 1rem;
}

.posts-meta {
    opacity: 0.7;
    font-size: 12px;
    margin: 0.25rem 0;
}

.post {
    border: 1px solid #374151;
    margin: 10px;
    padding: 12px;
    background: #111827;
    color: #e5e7eb;
    border-radius: 10px;
}

.post.pinned {
    border: 1px solid #ec4899;
    background: #fff0f6;
    color: #111;
}

.post h2 {
    margin: 0 0 .5rem 0;
    font-size: 20px;
    font-weight: 700;
}

.post p.content {
    margin: 0 0 .5rem 0;
    line-height: 1.5;
}

.post button {
    margin-right: 8px;
}

.post .debug {
    color: gray;
    font-size: 12px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 8px 0 16px;
}

.topbar .identity {
    display: flex;
    align-items: baseline;
    gap: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar .identity .welcome {
    font-weight: 600;
}

h1.title {
    margin-bottom: 8px;
}

/* === LAYOUT GRID === */
.layout {
    display: grid;
    grid-template-columns: 260px 1fr 300px;
    /* left / center / right */
    gap: 16px;
    align-items: start;
}

/* collapse right rail on medium screens */
@media (max-width: 1200px) {
    .layout {
        grid-template-columns: 260px 1fr;
    }

    .right {
        display: none;
    }
}

/* stack into a single column on small screens */
@media (max-width: 800px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .left {
        order: 2;
    }

    /* show communities under the feed on mobile */
    .center {
        order: 1;
    }
}

/* sticky left card so communities stay in view while scrolling */
.sticky {
    position: sticky;
    top: 12px;
}

/* columns just to be explicit */
.col.left {
    min-width: 0;
}

.col.center {
    min-width: 0;
}

.col.right {
    min-width: 0;
}

/* tighten card spacing inside the grid */
.layout .card {
    margin: 0;
}

/* single-line header from previous step (in case you missed it) */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 8px 0 16px;
}

.topbar .identity {
    display: flex;
    align-items: baseline;
    gap: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar .identity .welcome {
    font-weight: 600;
}

/* Left rail list cleanup */
.col.left .card ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.col.left .card li {
    margin: 6px 0;
}

.col.left .card .community-item {
    display: flex;
    gap: .5rem;
    align-items: center;
}

.col.left .card .community-item .desc {
    color: var(--tp-sub);
    font-size: .9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Make the whole left card scroll if long */
.col.left .card.sticky {
    max-height: calc(100vh - 24px);
    overflow: auto;
}

/* Make the middle column read comfortably on big screens */
.layout {
    grid-template-columns: 260px minmax(640px, 1fr) 300px;
    /* left / center / right */
}

/* Card density in feed */
.col.center .card {
    padding: .85rem 1rem;
}

/* Post card hover & spacing */
.post {
    transition: border-color .15s ease, box-shadow .15s ease;
}

.post:hover {
    border-color: #4b5563;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
}

.post button {
    margin-right: 8px;
    margin-top: 6px;
}

.post textarea {
    width: 100%;
    box-sizing: border-box;
}

/* Topbar polish */
.topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--tp-bg);
    padding: 8px 0 12px;
    border-bottom: 1px solid #1f2940;
}

.post.pinned {
    border: 1px solid #ec4899;
    background: #1a0f16;
    /* darker, not bright pink */
    color: var(--tp-text);
}

.post-list .sort-container {
    position: sticky;
    top: 56px;
    /* sits under the .topbar */
    background: var(--tp-card);
    padding: .5rem 0 .75rem;
    z-index: 4;
}

button,
input,
select,
textarea {
    border-radius: 10px;
    border: 1px solid #27304a;
    background: #0e1527;
    color: var(--tp-text);
    padding: .5rem .7rem;
}

button.btn-primary {
    background: var(--tp-accent);
    color: #071018;
    border: 0;
}

button:disabled {
    opacity: .6;
    cursor: not-allowed;
}

@media (max-width: 800px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .left {
        order: 2;
    }

    .center {
        order: 1;
    }

    .card {
        border-radius: 12px;
    }
}

small.muted {
    color: #888;
    display: block;
    margin-top: -6px;
    margin-bottom: 8px;
    font-size: 12px;
}
