.sg-community-detail-page,
.sg-community-detail-page * {
    box-sizing: border-box;
}

.sg-community-detail-page {
    width: 100%;
    min-width: 0;
    color: #333;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
}

.sg-community-detail-page .right-content {
    width: 100%;
    min-width: 0;
}

.sg-community-detail-page .community-header {
    overflow: visible;
    margin-bottom: 20px;
    border-radius: 8px;
    background-color: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.sg-community-detail-page .community-banner {
    position: relative;
    width: 100%;
    height: 110px;
    margin-bottom: 0;
    border-radius: 8px 8px 0 0;
    background: linear-gradient(135deg, #ff6b35 0%, #ff4500 100%);
}

.sg-community-detail-page .community-banner::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
}

.sg-community-detail-page .community-info {
    display: flex;
    align-items: flex-start;
    padding: 20px;
}

.sg-community-detail-page .community-icon {
    display: flex;
    width: 100px;
    height: 100px;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    margin-right: 20px;
    border: 4px solid #fff;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff6b35 0%, #ff4500 100%);
    box-shadow: 0 6px 16px rgba(255, 69, 0, 0.4);
    color: #fff;
    font-size: 2.5rem;
    font-weight: 700;
    overflow: hidden;
}

.sg-community-detail-page .community-icon--image {
    padding: 0;
}

.sg-community-detail-page .community-icon-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sg-community-detail-page .community-details {
    flex: 1;
    flex: 1;
    min-width: 0;
}

.sg-community-detail-page .community-name {
    margin: 0 0 12px;
    color: #333;
    font-size: 2.8rem;
    font-weight: 900;
    line-height: 1.05;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.sg-community-detail-page .community-desc {
    margin: 0 0 15px;
    color: #666;
    font-size: 0.8rem;
    line-height: 1.4;
}

.sg-community-detail-page .community-stats {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
    color: #666;
    font-size: 0.7rem;
    line-height: 1.3;
}

.sg-community-detail-page .community-stats span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.sg-community-detail-page .community-stats span::before {
    content: "";
    display: inline-block;
    width: 14px;
    height: 14px;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
}

.sg-community-detail-page .community-stats span:nth-child(1)::before {
    background-image: url("data:image/svg+xml,%3Csvg width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='9' cy='7' r='4'/%3E%3Cpath d='M23 21v-2a4 4 0 0 0-3-3.87'/%3E%3Cpath d='M16 3.13a4 4 0 0 1 0 7.75'/%3E%3C/svg%3E");
}

.sg-community-detail-page .community-stats span:nth-child(2)::before {
    background-image: url("data:image/svg+xml,%3Csvg width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpolyline points='14 2 14 8 20 8'/%3E%3Cline x1='16' y1='13' x2='8' y2='13'/%3E%3Cline x1='16' y1='17' x2='8' y2='17'/%3E%3Cpolyline points='10 9 9 9 8 9'/%3E%3C/svg%3E");
}

.sg-community-detail-page .community-stats span:nth-child(3)::before {
    background-image: url("data:image/svg+xml,%3Csvg width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M13 2L3 14h9l-1 8 10-12h-9l1-8z'/%3E%3C/svg%3E");
}

.sg-community-detail-page .community-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.sg-community-detail-page .action-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-width: auto;
    padding: 4px 10px;
    border: 1px solid #d1d5da;
    border-radius: 14px;
    background: none;
    box-shadow: none;
    color: #666;
    cursor: pointer;
    font-size: 0.8rem;
    line-height: 1.2;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.sg-community-detail-page .action-btn:hover {
    border-color: #ff4500;
    background-color: #fff3f0;
    box-shadow: none;
    color: #ff4500;
}

.sg-community-detail-page .action-btn svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
}

.sg-community-detail-page .action-btn.follow {
    border-color: #ff4500;
    background-color: #fff8f5;
    color: #ff4500;
}

.sg-community-detail-page .action-btn.follow:hover {
    background-color: #ff4500;
    color: #fff;
}

.sg-community-detail-page .action-btn.follow.is-following,
.sg-community-detail-page .action-btn.follow.following,
.sg-community-detail-page .follow-profile.is-following,
.sg-community-detail-page .follow-profile.following {
    border-color: #d1d5da;
    background-color: #f0f0f0;
    color: #999;
}

.sg-community-detail-page .action-btn.follow.is-following:hover,
.sg-community-detail-page .action-btn.follow.following:hover,
.sg-community-detail-page .follow-profile.is-following:hover,
.sg-community-detail-page .follow-profile.following:hover {
    border-color: #d1d5da;
    background-color: #e8e8e8;
    color: #777;
}

.sg-community-detail-page .content-area {
    display: flex;
    align-items: flex-start;
    gap: 20px;
}

.sg-community-detail-page .posts-section {
    min-width: 0;
    flex: 1;
    padding: 20px;
    border-radius: 8px;
    background-color: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.sg-community-detail-page .filter-section {
    margin-bottom: 10px;
}

.sg-community-detail-page .filter-section:last-child {
    margin-bottom: 0;
}

.sg-community-detail-page .content-filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 5px 0 10px;
    border-bottom: 1px solid #e1e4e8;
}

.sg-community-detail-page .tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 5px 0 10px;
    border-bottom: 1px solid #e1e4e8;
}

.sg-community-detail-page .filter-tag {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 14px;
    background-color: transparent;
    color: #666;
    cursor: pointer;
    font-size: 0.7rem;
    line-height: 1.2;
    transition: all 0.2s ease;
    white-space: nowrap;
    text-decoration: none;
}

.sg-community-detail-page .filter-tag:hover {
    background-color: #e9ecef;
    color: #333;
}

.sg-community-detail-page .filter-tag.active {
    background-color: #ff4500;
    color: #fff;
    font-weight: 500;
}

.sg-community-detail-page .filter-tag.active:hover {
    background-color: #ff6347;
    color: #fff;
}

.sg-community-detail-page .topic-content {
    margin-bottom: 12px;
    color: #666;
    font-size: 0.85rem;
    line-height: 1.5;
}

.sg-community-detail-page .topic-interactions {
    display: flex;
    align-items: center;
    gap: 1px;
    margin: 0 0 1.26px 48px;
}

.sg-community-detail-page .load-more {
    margin-top: 10px;
    padding: 15px;
    border-radius: 8px;
    color: #666;
    cursor: pointer;
    font-size: 0.9rem;
    text-align: center;
    transition: all 0.2s ease;
    user-select: none;
}

.sg-community-detail-page .load-more:hover {
    background-color: #fff8f5;
    color: #ff4500;
}

.sg-community-detail-page .load-more.is-loading {
    pointer-events: none;
    opacity: 0.7;
}

.sg-community-detail-page .community-empty-state {
    padding: 18px 0 8px;
    color: #666;
    text-align: center;
}

.sg-community-detail-page .community-empty-state__title {
    margin-bottom: 6px;
    color: #333;
    font-size: 1rem;
    font-weight: 600;
}

.sg-community-detail-page .community-empty-state__desc {
    font-size: 0.9rem;
    line-height: 1.6;
}

.sg-community-detail-page .sidebar {
    width: 320px;
    flex-shrink: 0;
    padding: 24px;
    border-radius: 12px;
    background-color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.sg-community-detail-page .sidebar-section {
    margin-bottom: 32px;
}

.sg-community-detail-page .sidebar-section:last-child {
    margin-bottom: 0;
}

.sg-community-detail-page .sidebar-title {
    margin: 0 0 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #ff4500;
    color: #333;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.sg-community-detail-page .sidebar-item {
    padding: 12px 0;
    border-bottom: 1px solid #f5f5f5;
    transition: all 0.2s ease;
}

.sg-community-detail-page .sidebar-item:hover {
    padding-right: 8px;
    padding-left: 8px;
    border-radius: 6px;
    background-color: #fafafa;
}

.sg-community-detail-page .sidebar-item:last-child {
    border-bottom: none;
}

.sg-community-detail-page .sidebar-item a {
    display: block;
    color: #333;
    font-size: 0.95rem;
    text-decoration: none;
}

.sg-community-detail-page .sidebar-item a:hover {
    color: #ff4500;
}

.sg-community-detail-page .rule-category {
    margin-bottom: 10px;
    padding-left: 12px;
    border-left: 3px solid #ff4500;
    color: #333;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.3;
}

.sg-community-detail-page .rule-content {
    padding: 8px 0;
    color: #666;
    font-size: 0.9rem;
    line-height: 1.6;
}

.sg-community-detail-page .rule-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.sg-community-detail-page .rule-list li {
    position: relative;
    padding: 6px 0 6px 20px;
    color: #666;
    font-size: 0.85rem;
    line-height: 1.5;
}

.sg-community-detail-page .rule-list li::before {
    content: "\2022";
    position: absolute;
    top: 6px;
    left: 0;
    color: #ff4500;
    font-size: 0.9rem;
    font-weight: 700;
}

.sg-community-detail-page #rules-section .rules-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.sg-community-detail-page #rules-section .rules-header .sidebar-title {
    margin-bottom: 0;
}

.sg-community-detail-page #rules-section .edit-rules-btn {
    padding: 4px 10px;
    border: 1px solid #d1d5da;
    border-radius: 12px;
    background-color: #fff;
    color: #666;
    font-size: 0.65rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    margin-top: -6px;
}

.sg-community-detail-page #rules-section .edit-rules-btn:hover {
    border-color: #ff4500;
    color: #ff4500;
    background-color: #fff5f0;
}

.sg-community-detail-page #rules-section .rules-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sg-community-detail-page #rules-section .rule-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px;
    background-color: #f8f9fa;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.sg-community-detail-page #rules-section .rule-item:hover {
    background-color: #e9ecef;
}

.sg-community-detail-page #rules-section .rule-item.expanded {
    background-color: #f8f9fa;
    border-left: 3px solid #ff4500;
}

.sg-community-detail-page #rules-section .rule-content {
    flex: 1;
    padding: 0;
}

.sg-community-detail-page #rules-section .rule-title {
    margin-bottom: 2px;
    color: #333;
    font-size: 0.76rem;
    font-weight: 500;
}

.sg-community-detail-page #rules-section .rule-desc {
    color: #666;
    font-size: 0.665rem;
    line-height: 1.3;
}

.sg-community-detail-page #rules-section .rule-toggle {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 12px;
    height: 12px;
    color: #666;
    cursor: pointer;
    font-size: 0.6rem;
    transition: transform 0.2s ease, color 0.2s ease;
}

.sg-community-detail-page #rules-section .rule-toggle::before {
    content: '▼';
    font-size: 0.5rem;
    line-height: 1;
}

.sg-community-detail-page #rules-section .rule-toggle:hover {
    color: #ff4500;
    transform: translateY(1px);
}

.sg-community-detail-page #rules-section .rule-toggle.expanded::before {
    content: '▲';
    transform: translateY(-1px);
}

.sg-community-detail-page #rules-section .rule-details {
    display: none;
    margin-top: 8px;
    padding-left: 10px;
    border-left: 2px solid #e9ecef;
}

.sg-community-detail-page #rules-section .rule-item.expanded .rule-details {
    display: block;
}

.sg-community-detail-page #rules-section .rule-details p {
    margin-bottom: 4px;
    color: #666;
    font-size: 0.65rem;
    line-height: 1.4;
}

.sg-community-detail-page #rules-section .rule-details p:last-child {
    margin-bottom: 0;
}

.sg-community-detail-page .sg-community-rules__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.sg-community-detail-page .sg-community-rules__title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.sg-community-detail-page .sg-community-rules__header .sidebar-title {
    margin: 0;
}

.sg-community-detail-page .sg-community-rules__badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(255, 69, 0, 0.1);
    color: #ff4500;
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}

.sg-community-detail-page .sg-community-rules__edit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    border: 1px solid rgba(255, 69, 0, 0.18);
    border-radius: 999px;
    background: #fff7f3;
    color: #ff4500;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 700;
    transition: all 0.2s ease;
}

.sg-community-detail-page .sg-community-rules__edit-btn:hover {
    border-color: rgba(255, 69, 0, 0.34);
    background: #fff0e8;
}

.sg-community-detail-page .sg-community-rules__intro {
    margin-bottom: 14px;
    color: #666;
    font-size: 0.88rem;
    line-height: 1.6;
}

.sg-community-detail-page .sg-community-rules__cards {
    display: grid;
    gap: 12px;
}

.sg-community-detail-page .sg-community-rule-card {
    padding: 14px 0;
}

.sg-community-rules-modal[hidden] {
    display: none;
}

.sg-community-rules-modal {
    position: fixed;
    inset: 0;
    z-index: 10030;
}

.sg-community-rules-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.52);
}

.sg-community-rules-modal__dialog {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: min(760px, calc(100vw - 32px));
    max-height: calc(100vh - 56px);
    margin: 28px auto;
    border-radius: 20px;
    background: #fff;
    box-shadow: 0 30px 60px rgba(15, 23, 42, 0.22);
    overflow: hidden;
}

.sg-community-rules-modal__header,
.sg-community-rules-modal__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 20px 24px;
}

.sg-community-rules-modal__copy {
    display: grid;
    gap: 8px;
}

.sg-community-rules-modal__title {
    margin: 0;
    color: #0f172a;
    font-size: 1.15rem;
    font-weight: 700;
}

.sg-community-rules-modal__intro {
    margin: 0;
    color: #64748b;
    font-size: 0.86rem;
    line-height: 1.6;
}

.sg-community-rules-modal__close {
    border: 0;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    font-size: 28px;
    line-height: 1;
}

.sg-community-rules-modal__body {
    display: grid;
    gap: 14px;
    padding: 0 24px 24px;
    overflow-y: auto;
}

.sg-community-rules-modal__cards {
    display: grid;
    gap: 14px;
}

.sg-community-rules-modal__empty {
    padding: 18px 20px;
    border: 1px dashed rgba(148, 163, 184, 0.5);
    border-radius: 16px;
    background: #f8fafc;
    color: #64748b;
    font-size: 0.85rem;
    line-height: 1.6;
}

.sg-community-rules-modal__card {
    display: grid;
    gap: 12px;
    padding: 18px;
    border: 1px solid rgba(226, 232, 240, 1);
    border-radius: 18px;
    background: #fffaf7;
}

.sg-community-rules-modal__card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.sg-community-rules-modal__card-index {
    color: #0f172a;
    font-size: 0.9rem;
    font-weight: 700;
}

.sg-community-rules-modal__remove {
    border: 0;
    background: transparent;
    color: #dc2626;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 700;
}

.sg-community-rules-modal__field {
    display: grid;
    gap: 8px;
}

.sg-community-rules-modal__field label {
    color: #334155;
    font-size: 0.82rem;
    font-weight: 700;
}

.sg-community-rules-modal__field input,
.sg-community-rules-modal__field textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid rgba(203, 213, 225, 1);
    border-radius: 14px;
    background: #fff;
    color: #0f172a;
    font-size: 0.9rem;
    line-height: 1.5;
}

.sg-community-rules-modal__field textarea {
    min-height: 112px;
    resize: vertical;
}

.sg-community-rules-modal__field input:focus,
.sg-community-rules-modal__field textarea:focus {
    outline: none;
    border-color: rgba(255, 69, 0, 0.5);
    box-shadow: 0 0 0 4px rgba(255, 69, 0, 0.1);
}

.sg-community-rules-modal__add,
.sg-community-rules-modal__secondary,
.sg-community-rules-modal__primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 11px 18px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 700;
    transition: all 0.2s ease;
}

.sg-community-rules-modal__add {
    width: fit-content;
    border: 1px dashed rgba(255, 69, 0, 0.35);
    background: #fff;
    color: #ff4500;
}

.sg-community-rules-modal__footer {
    justify-content: flex-end;
}

.sg-community-rules-modal__secondary {
    border: 1px solid rgba(203, 213, 225, 1);
    background: #fff;
    color: #334155;
}

.sg-community-rules-modal__primary {
    border: 1px solid transparent;
    background: linear-gradient(135deg, #ff6a00 0%, #ff4500 100%);
    color: #fff;
    box-shadow: 0 12px 24px rgba(255, 69, 0, 0.18);
}

.sg-community-rules-modal__primary[disabled] {
    cursor: not-allowed;
    opacity: 0.62;
    box-shadow: none;
}

.sg-community-detail-page .contributor-rank {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
}

.sg-community-detail-page .rank-number {
    display: inline-flex;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff6b35 0%, #ff4500 100%);
    box-shadow: 0 1px 2px rgba(255, 69, 0, 0.2);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
}

.sg-community-detail-page .contributor-name {
    flex: 1;
    color: #333;
    font-size: 0.8rem;
    font-weight: 500;
}

.sg-community-detail-page .reputation-value {
    color: #ff4500;
    font-size: 0.8rem;
    font-weight: 600;
}

.sg-community-detail-page .community-recommendation {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    text-decoration: none;
    transition: all 0.2s ease;
}

.sg-community-detail-page .community-recommendation:hover {
    padding-right: 4px;
    padding-left: 4px;
    border-radius: 3px;
    background-color: #fafafa;
}

.sg-community-detail-page .community-icon-small {
    display: inline-flex;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff6b35 0%, #ff4500 100%);
    box-shadow: 0 1px 2px rgba(255, 69, 0, 0.2);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
}

.sg-community-detail-page .community-info-small {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.sg-community-detail-page .community-name-small {
    color: #333;
    font-size: 0.75rem;
    font-weight: 500;
}

.sg-community-detail-page .community-meta-small {
    color: #999;
    font-size: 0.65rem;
}

@media (max-width: 1199px) {
    .sg-community-detail-page .content-area {
        flex-direction: column;
    }

    .sg-community-detail-page .sidebar {
        width: 100%;
    }

    .sg-community-rules-modal__dialog {
        width: min(760px, calc(100vw - 24px));
        margin: 12px auto;
    }
}

@media (max-width: 767px) {
    .sg-community-detail-page .community-info {
        flex-direction: column;
    }

    .sg-community-detail-page .community-icon {
        width: 72px;
        height: 72px;
        margin: 0 0 14px;
        font-size: 2rem;
    }

    .sg-community-detail-page .community-name {
        font-size: 2rem;
    }

    .sg-community-detail-page .community-stats {
        flex-direction: column;
        gap: 8px;
    }

    .sg-community-detail-page .community-actions {
        justify-content: flex-start;
    }

    .sg-community-detail-page .posts-section,
    .sg-community-detail-page .sidebar {
        padding: 18px;
        border-radius: 8px;
    }

    .sg-community-detail-page .post:not(.post-last)::after {
        left: 0;
    }

    .sg-community-detail-page .post-actual-title,
    .sg-community-detail-page .post-tags,
    .sg-community-detail-page .post-content,
    .sg-community-detail-page .post-interactions {
        margin-left: 0;
    }

    .sg-community-detail-page .sg-community-rules__header,
    .sg-community-rules-modal__header,
    .sg-community-rules-modal__footer {
        flex-direction: column;
        align-items: stretch;
    }

    .sg-community-detail-page .sg-community-rules__title-wrap {
        flex-wrap: wrap;
    }

    .sg-community-detail-page .sg-community-rules__edit-btn,
    .sg-community-rules-modal__add,
    .sg-community-rules-modal__secondary,
    .sg-community-rules-modal__primary {
        width: 100%;
    }

}
