.community-page {
    max-width: 760px;
    margin: 32px auto 70px;
    padding: 0 18px;
}

.community-hero {
    background:
        radial-gradient(circle at top left, rgba(59, 130, 246, .22), transparent 35%),
        linear-gradient(135deg, #0f172a, #020617);
    border: 1px solid var(--border);
    border-radius: 30px;
    padding: 40px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.community-hero p {
    color: var(--primary-soft);
    font-weight: 900;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 1.4px;
    font-size: 12px;
}

.community-hero h1 {
    margin: 8px 0;
    font-size: clamp(38px, 5vw, 58px);
    letter-spacing: -2px;
}

.community-hero span {
    color: var(--muted);
    display: block;
    line-height: 1.7;
}

/* ===== COMPOSER ===== */

.composer-card {
    background: rgba(255, 255, 255, .07);
    border: 1px solid var(--border);
    border-radius: 26px;
    padding: 22px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.composer-top {
    display: flex;
    gap: 14px;
}

.post-avatar {
    width: 46px;
    height: 46px;
    flex-shrink: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-soft));
    color: white;
    font-weight: 900;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.post-author-name {
    text-decoration: none;
    color: inherit;
}

.post-author-name:hover {
    text-decoration: underline;
}

.post-avatar-sm {
    width: 34px;
    height: 34px;
    font-size: 14px;
}

.composer-fields {
    flex: 1;
    display: grid;
    gap: 10px;
}

.composer-textarea,
.composer-image-input,
.post-edit-textarea,
.comment-input {
    width: 100%;
    padding: 14px 16px;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, .06);
    color: white;
    font-size: 15px;
    font-family: inherit;
    box-sizing: border-box;
    outline: none;
    resize: vertical;
}

.composer-textarea {
    min-height: 76px;
}

.composer-textarea:focus,
.composer-image-input:focus,
.post-edit-textarea:focus,
.comment-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, .15);
}

.composer-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
    margin-top: 14px;
}

.composer-count {
    color: var(--muted);
    font-weight: 700;
    font-size: 13px;
    margin-right: auto;
}

.composer-count-over {
    color: var(--danger);
}

.composer-submit-button {
    border: none;
    background: linear-gradient(135deg, var(--primary), var(--primary-soft));
    color: white;
    padding: 11px 22px;
    border-radius: 999px;
    font-weight: 900;
    cursor: pointer;
}

.composer-submit-button:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.composer-message {
    margin: 10px 0 0;
    font-weight: 700;
    font-size: 14px;
    color: var(--success);
    min-height: 18px;
}

.composer-message:empty {
    display: none;
}

.composer-message-error {
    color: #fca5a5;
}

.composer-signed-out {
    text-align: center;
    padding: 26px;
    border: 2px dashed var(--border);
    border-radius: 22px;
    color: var(--muted);
    margin-bottom: 24px;
}

.composer-signed-out a {
    display: inline-block;
    margin-top: 12px;
    padding: 10px 20px;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 900;
    color: white;
    background: linear-gradient(135deg, var(--primary), var(--primary-soft));
}

/* ===== TABS (Session 22: Feed / Discover / Trending) ===== */

.community-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    padding: 6px;
    background: rgba(255, 255, 255, .05);
    border: 1px solid var(--border);
    border-radius: 999px;
}

.community-tab {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--muted);
    padding: 11px 16px;
    border-radius: 999px;
    font-weight: 800;
    font-size: 14px;
    cursor: pointer;
    transition: .2s;
}

.community-tab:hover {
    color: var(--text);
}

.community-tab.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-soft));
    color: white;
}

/* ===== DISCOVER ===== */

.discover-content {
    display: grid;
    gap: 28px;
}

.discover-section h2 {
    margin: 0 0 14px;
    font-size: 20px;
}

.discover-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}

.discover-card {
    display: grid;
    gap: 10px;
    background: rgba(255, 255, 255, .06);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 14px;
}

.discover-card-main {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
    min-width: 0;
}

.discover-card-logo {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 14px;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    overflow: hidden;
    color: #020617;
}

.discover-card-logo img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.discover-card-logo-round {
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-soft));
    color: white;
    font-weight: 900;
}

.discover-card-text {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.discover-card-text strong {
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.discover-card-text small {
    color: var(--muted);
    font-size: 12px;
}

.discover-follow-button {
    width: 100%;
    border: none;
    background: linear-gradient(135deg, var(--primary), var(--primary-soft));
    color: white;
    padding: 9px 14px;
    border-radius: 999px;
    font-weight: 800;
    font-size: 13px;
    cursor: pointer;
    transition: .2s;
}

.discover-follow-button.is-following {
    background: rgba(255, 255, 255, .08);
    color: var(--text);
    border: 1px solid var(--border);
}

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

.discover-empty {
    margin: 0;
}

.post-personalized-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 11px;
    border-radius: 999px;
    background: rgba(250, 204, 21, .14);
    color: #facc15;
    font-weight: 800;
    font-size: 12px;
    white-space: nowrap;
    flex-shrink: 0;
}

.post-personalized-badge .icon {
    width: 13px;
    height: 13px;
}

/* ===== READ-ONLY POST CARDS (Discover posts / Trending) ===== */

.post-card-readonly .post-actions-static {
    display: flex;
    gap: 16px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.post-action-static {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-weight: 800;
    font-size: 13px;
}

.post-action-static .icon {
    width: 16px;
    height: 16px;
}

/* ===== FEED ===== */

.community-feed-message {
    color: #fca5a5;
    font-weight: 700;
    text-align: center;
    margin-bottom: 16px;
}

.community-feed {
    display: grid;
    gap: 18px;
}

.community-feed-empty {
    text-align: center;
    padding: 40px;
    border: 2px dashed var(--border);
    border-radius: 22px;
    color: var(--muted);
    display: grid;
    gap: 14px;
    justify-items: center;
}

.community-feed-empty p {
    margin: 0;
}

.post-card {
    background: rgba(255, 255, 255, .07);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 20px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.post-card-top {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.post-meta {
    display: grid;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.post-author-name {
    font-size: 15px;
}

.post-timestamp {
    color: var(--muted);
    font-size: 13px;
}

.post-owner-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.post-owner-button {
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, .06);
    color: var(--muted);
    padding: 7px 14px;
    border-radius: 999px;
    font-weight: 800;
    font-size: 13px;
    cursor: pointer;
}

.post-owner-button:hover {
    background: rgba(59, 130, 246, .14);
    color: var(--text);
}

.post-owner-button-danger:hover {
    background: rgba(239, 68, 68, .14);
    color: #fecaca;
    border-color: rgba(239, 68, 68, .35);
}

.post-body p {
    margin: 0;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.post-image {
    display: block;
    max-width: 100%;
    margin-top: 12px;
    border-radius: 18px;
    border: 1px solid var(--border);
}

.post-edit-textarea {
    min-height: 90px;
}

.post-edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 10px;
}

.post-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.post-action-button {
    display: flex;
    align-items: center;
    gap: 7px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, .05);
    color: var(--muted);
    padding: 8px 16px;
    border-radius: 999px;
    font-weight: 800;
    font-size: 13px;
    cursor: pointer;
}

.post-action-button:hover {
    background: rgba(59, 130, 246, .12);
    color: var(--text);
}

.post-action-button .icon {
    width: 17px;
    height: 17px;
}

.post-action-button.is-active {
    color: #fca5a5;
    border-color: rgba(239, 68, 68, .35);
    background: rgba(239, 68, 68, .12);
}

.post-card-message {
    color: #fca5a5;
    font-weight: 700;
    font-size: 13px;
    margin: 10px 0 0;
}

/* ===== COMMENTS ===== */

.post-comments {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    display: grid;
    gap: 14px;
}

.comment-list {
    display: grid;
    gap: 12px;
}

.comment-list-empty {
    color: var(--muted);
    font-size: 14px;
    margin: 0;
}

.comment-item {
    display: flex;
    gap: 10px;
}

.comment-body {
    background: rgba(255, 255, 255, .05);
    border-radius: 16px;
    padding: 10px 14px;
    flex: 1;
    min-width: 0;
}

.comment-body strong {
    font-size: 13px;
    margin-right: 8px;
}

.comment-timestamp {
    color: var(--muted);
    font-size: 12px;
}

.comment-body p {
    margin: 4px 0 0;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.comment-composer {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.comment-input {
    flex: 1;
    width: auto;
    min-width: 0;
    min-height: 42px;
    padding: 10px 14px;
}

.comment-submit-button {
    border: none;
    background: linear-gradient(135deg, var(--primary), var(--primary-soft));
    color: white;
    padding: 10px 18px;
    border-radius: 999px;
    font-weight: 900;
    cursor: pointer;
    flex-shrink: 0;
}

.comment-submit-button:disabled {
    opacity: .5;
    cursor: not-allowed;
}

@media (max-width: 600px) {
    .community-page {
        margin: 20px auto 60px;
        padding: 0 14px;
    }

    .community-hero {
        padding: 26px;
        border-radius: 22px;
    }

    .composer-card,
    .post-card {
        padding: 16px;
        border-radius: 20px;
    }

    .composer-top {
        gap: 10px;
    }

    .post-card-top {
        flex-wrap: wrap;
    }

    .post-owner-actions {
        gap: 6px;
    }

    .post-owner-button {
        padding: 6px 12px;
        font-size: 12px;
    }

    .post-actions {
        gap: 8px;
    }

    .post-action-button {
        flex: 1;
        justify-content: center;
        padding: 8px 10px;
    }

    .comment-item {
        gap: 8px;
    }

    .comment-composer {
        flex-wrap: wrap;
    }

    .comment-submit-button {
        flex: 1;
    }

    .community-tabs {
        gap: 4px;
        padding: 5px;
    }

    .community-tab {
        padding: 10px 8px;
        font-size: 13px;
    }

    .discover-content {
        gap: 22px;
    }

    .discover-grid {
        grid-template-columns: 1fr;
    }

    .discover-card {
        padding: 12px;
    }

    .post-personalized-badge {
        font-size: 11px;
        padding: 4px 9px;
    }
}
