:root {
    color-scheme: light;
}

* {
    box-sizing: border-box;
}

.communities-body {
    margin: 0;
    background: #f4f7fb;
    color: #23354a;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.communities-page {
    min-height: 100vh;
}

.communities-shell {
    width: min(72rem, calc(100% - 2rem));
    margin: 0 auto;
    padding: 2rem 0 4rem;
}

.communities-hero,
.communities-form-heading,
.community-profile__header,
.communities-section-heading,
.communities-card__header,
.communities-signin,
.communities-actions,
.communities-pagination,
.communities-form-submit {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.communities-hero,
.communities-form-heading,
.community-profile,
.communities-card,
.communities-empty,
.communities-signin,
.communities-form {
    border: 1px solid #dce4ef;
    border-radius: 1rem;
    background: #fff;
    box-shadow: 0 10px 30px rgba(28, 48, 77, .06);
}

.communities-hero,
.communities-form-heading,
.community-profile,
.communities-form {
    padding: 1.4rem;
}

.communities-hero {
    margin-bottom: 1.2rem;
}

.communities-hero h1,
.communities-form-heading h1,
.community-profile h1,
.communities-section-heading h2,
.communities-card h3 {
    margin: 0;
    color: #142a4f;
}

.communities-hero p,
.communities-form-heading p {
    max-width: 48rem;
    line-height: 1.65;
}

.communities-eyebrow,
.communities-card__slug,
.community-profile__slug {
    margin: 0 0 .35rem;
    color: #62748a;
    font-size: .82rem;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.communities-primary-action,
.communities-card__link,
.communities-signin > a,
.communities-form-heading > a,
.communities-context-nav a {
    color: #174f92;
    font-weight: 750;
    text-decoration: none;
}

.communities-primary-action {
    display: inline-flex;
    flex: 0 0 auto;
    padding: .7rem .9rem;
    border: 1px solid #b8cbe2;
    border-radius: .7rem;
    background: #eef5fd;
}

.communities-primary-action:hover,
.communities-primary-action:focus-visible,
.communities-card__link:hover,
.communities-card__link:focus-visible,
.communities-signin > a:hover,
.communities-signin > a:focus-visible,
.communities-form-heading > a:hover,
.communities-form-heading > a:focus-visible,
.communities-context-nav a:hover,
.communities-context-nav a:focus-visible {
    text-decoration: underline;
}

.communities-status {
    margin: 0 0 1rem;
    padding: .75rem 1rem;
    border: 1px solid #b9dec4;
    border-radius: .75rem;
    background: #eef8f1;
    color: #235b36;
    font-weight: 700;
}

.communities-section-heading {
    margin: 0 0 .8rem;
}

.communities-section-heading > span {
    color: #64758a;
    font-size: .9rem;
    font-weight: 700;
}

.communities-card {
    margin-bottom: .8rem;
    padding: 1rem 1.1rem;
}

.communities-card__description,
.community-profile__description {
    line-height: 1.65;
}

.communities-badge {
    flex: 0 0 auto;
    padding: .35rem .6rem;
    border-radius: 999px;
    background: #eef1f5;
    color: #536477;
    font-size: .78rem;
    font-weight: 800;
}

.communities-details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .6rem 1rem;
    margin: .9rem 0;
}

.communities-details--profile {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.communities-details div {
    padding-top: .65rem;
    border-top: 1px solid #edf1f6;
}

.communities-details dt {
    color: #6b7a8c;
    font-size: .76rem;
    font-weight: 800;
    text-transform: uppercase;
}

.communities-details dd {
    margin: .2rem 0 0;
    font-weight: 700;
}

.communities-empty {
    padding: 1.2rem;
}

.communities-signin {
    margin-top: 1rem;
    padding: 1rem 1.1rem;
}

.communities-signin p {
    margin: .3rem 0 0;
}

.communities-pagination {
    margin-top: 1rem;
}

.communities-pagination a {
    color: #174f92;
    font-weight: 700;
}

.communities-context-nav {
    display: flex;
    flex-wrap: wrap;
    gap: .8rem;
    margin-bottom: 1rem;
}

.community-profile__header {
    align-items: flex-start;
}

.communities-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.communities-actions form {
    margin: 0;
}

.communities-actions button,
.communities-form button {
    padding: .7rem .9rem;
    border: 1px solid #a9bfd9;
    border-radius: .65rem;
    background: #174f92;
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-weight: 750;
}

.communities-secondary-button {
    background: #fff !important;
    color: #6b3640 !important;
    border-color: #d8b8be !important;
}

.communities-actions button:hover,
.communities-actions button:focus-visible,
.communities-form button:hover,
.communities-form button:focus-visible {
    filter: brightness(.96);
    outline: 3px solid #9fc3ed;
    outline-offset: 2px;
}

.communities-form-heading {
    margin-bottom: 1rem;
}

.communities-form {
    display: grid;
    gap: 1rem;
}

.communities-field {
    display: grid;
    gap: .4rem;
}

.communities-field label,
.communities-readonly > span {
    color: #2a3f59;
    font-weight: 800;
}

.communities-field small {
    color: #68778a;
    line-height: 1.45;
}

.communities-field input,
.communities-field textarea,
.communities-field select {
    width: 100%;
    padding: .7rem .75rem;
    border: 1px solid #bdc9d8;
    border-radius: .6rem;
    background: #fff;
    color: #23354a;
    font: inherit;
}

.communities-field input:focus-visible,
.communities-field textarea:focus-visible,
.communities-field select:focus-visible {
    outline: 3px solid #9fc3ed;
    outline-offset: 2px;
}

.communities-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .9rem;
}

.communities-readonly {
    display: grid;
    gap: .25rem;
    padding: .8rem;
    border: 1px solid #e0e7f0;
    border-radius: .65rem;
    background: #f8fafc;
}

.communities-form-submit {
    align-items: flex-start;
}

.communities-form-submit p {
    max-width: 42rem;
    margin: 0;
    color: #68778a;
    font-size: .86rem;
    line-height: 1.5;
}

@media (max-width: 760px) {
    .communities-hero,
    .communities-form-heading,
    .community-profile__header,
    .communities-signin,
    .communities-form-submit {
        align-items: stretch;
        flex-direction: column;
    }

    .communities-details--profile {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 540px) {
    .communities-shell {
        width: min(100% - 1rem, 72rem);
        padding-top: 1rem;
    }

    .communities-details,
    .communities-details--profile,
    .communities-form-grid {
        grid-template-columns: 1fr;
    }

    .communities-card__header,
    .communities-section-heading,
    .communities-pagination {
        align-items: flex-start;
        flex-direction: column;
    }
}


/* Phase 4D — Community membership workflows */
.community-workflow-panel {
    margin-top: 1.25rem;
    padding: 1rem;
    border: 1px solid rgba(22, 48, 78, 0.18);
    border-radius: 0.9rem;
    background: #fff;
}

.community-workflow-panel h2,
.community-workflow-panel h3,
.community-workflow-panel p {
    margin-top: 0;
}

.community-workflow-list {
    display: grid;
    gap: 0.75rem;
    margin-top: 0.9rem;
}

.community-workflow-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.8rem;
    border: 1px solid rgba(22, 48, 78, 0.12);
    border-radius: 0.75rem;
}

.community-workflow-item p {
    margin: 0.2rem 0 0;
}

.community-workflow-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.community-invite-form {
    margin-top: 0.8rem;
}

.community-invite-form label {
    display: block;
    font-weight: 700;
    margin-bottom: 0.35rem;
}

.community-invite-form__row {
    display: flex;
    gap: 0.55rem;
}

.community-invite-form__row input {
    min-width: 0;
    flex: 1 1 16rem;
}

@media (max-width: 680px) {
    .community-workflow-item,
    .community-invite-form__row {
        align-items: stretch;
        flex-direction: column;
    }

    .community-workflow-actions {
        align-items: stretch;
    }
}
