.community-page {
  --community-ink: #082a4a;
  --community-copy: #526c7e;
  --community-teal: #079f98;
  --community-teal-dark: #087d79;
  --community-blue: #168bc4;
  --community-line: #d7e8ef;
  --community-soft: #edf8f8;
  width: min(100%, 760px);
  margin-inline: auto;
  color: var(--community-ink);
  letter-spacing: 0;
}

.community-page button,
.community-page input,
.community-page textarea { letter-spacing: 0; }

.community-page-head,
.community-subhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.community-page-head h1,
.community-subhead h1 {
  margin: 2px 0 3px;
  font-size: clamp(1.45rem, 2vw, 1.8rem);
  line-height: 1.12;
}

.community-page-head p,
.community-subhead p { margin: 0; color: var(--community-copy); }
.community-page-head .eyebrow { color: var(--community-teal-dark); }
.community-subhead { justify-content: flex-start; }
.community-subhead > div { min-width: 0; }

.community-composer-trigger {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 64px;
  border: 1px solid var(--community-line);
  border-radius: 8px;
  background: #fff;
  color: var(--community-copy);
  padding: 10px 14px;
  text-align: left;
  box-shadow: 0 8px 24px rgba(8, 42, 74, .06);
}

.community-composer-trigger:hover { border-color: #8ed8d1; background: #fbffff; }
.community-composer-trigger .ui-icon { color: var(--community-teal); }

.community-scope {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  width: min(100%, 340px);
  margin: 14px 0;
  border: 1px solid var(--community-line);
  border-radius: 8px;
  background: #edf3f5;
  padding: 3px;
}

.community-scope button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--community-copy);
  font-weight: 800;
}

.community-scope button.active { background: var(--community-teal); color: #fff; box-shadow: 0 4px 12px rgba(7, 159, 152, .2); }

.community-active-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  border-block: 1px solid var(--community-line);
  padding: 12px 2px;
}

.community-active-strip > div:first-child { display: grid; gap: 2px; }
.community-active-strip small { color: var(--community-copy); font-size: .75rem; }
.community-active-avatars { display: flex; align-items: center; padding-right: 6px; }
.community-active-avatars button {
  position: relative;
  width: 38px;
  height: 38px;
  margin-right: -6px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: transparent;
  padding: 0;
}
.community-active-avatars .profile-avatar { width: 100%; height: 100%; }

.presence-dot {
  position: absolute;
  right: -1px;
  bottom: 0;
  width: 10px;
  height: 10px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #10a76c;
}

.community-feed-list { display: grid; gap: 14px; }
.community-post {
  overflow: hidden;
  border: 1px solid var(--community-line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(8, 42, 74, .07);
}

.community-post-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
}

.community-identity {
  display: grid;
  min-width: 0;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
}
.community-identity > span:last-child { display: grid; min-width: 0; gap: 2px; }
.community-identity strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.community-identity small { color: var(--community-teal-dark); font-size: .75rem; }
.community-avatar-wrap { position: relative; display: inline-flex; }
.community-post-meta { display: flex; align-items: center; gap: 4px; color: var(--community-copy); font-size: .75rem; }
.community-post-meta .icon-action { width: 34px; height: 34px; color: #c53847; }

.community-post-copy {
  margin: 0;
  padding: 0 14px 14px;
  color: #16364e;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.community-location { display: flex; align-items: center; gap: 5px; margin: -6px 14px 10px; color: var(--community-copy); font-size: .78rem; }
.community-location .ui-icon { color: var(--community-teal); }
.community-photo-button { display: block; width: 100%; border: 0; background: #eaf3f5; padding: 0; }
.community-post-photo { display: block; width: 100%; max-height: 680px; aspect-ratio: 4 / 3; object-fit: cover; }

.community-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--community-line);
  padding: 4px 8px;
}
.community-actions button {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--community-copy);
  font-weight: 800;
}
.community-actions button:hover { background: #f2f9fa; }
.community-actions button.is-liked { color: #e43854; }
.community-actions button.is-liked .ui-icon { fill: currentColor; }

.community-loading,
.community-empty {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 180px;
  border: 1px dashed #a9d6df;
  border-radius: 8px;
  background: rgba(255, 255, 255, .65);
  color: var(--community-copy);
  padding: 24px;
  text-align: center;
}
.community-loading .ui-icon { animation: community-spin 1s linear infinite; color: var(--community-teal); }
.community-empty > span { display: grid; width: 54px; height: 54px; place-items: center; border-radius: 50%; background: #dff5f3; color: var(--community-teal); }
.community-empty h2, .community-empty p { margin: 0; }
.community-load-more { display: block; margin: 16px auto 0; }

.community-compose-form { display: grid; gap: 16px; }
.community-compose-form > .community-identity { border-bottom: 1px solid var(--community-line); padding-bottom: 14px; }
.community-textarea { position: relative; display: block; }
.community-textarea textarea {
  width: 100%;
  min-height: 140px;
  resize: vertical;
  border: 1px solid var(--community-line);
  border-radius: 8px;
  background: #fff;
  color: var(--community-ink);
  padding: 14px 14px 32px;
  font: inherit;
  line-height: 1.5;
}
.community-textarea small { position: absolute; right: 12px; bottom: 10px; color: var(--community-copy); }
.community-photo-preview { position: relative; overflow: hidden; border-radius: 8px; background: #e8f3f5; }
.community-photo-preview img { display: block; width: 100%; max-height: 560px; aspect-ratio: 4 / 3; object-fit: cover; }
.community-photo-preview .icon-action { position: absolute; top: 10px; right: 10px; background: rgba(8, 42, 74, .84); color: #fff; }
.community-compose-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.community-option,
.community-location-field {
  display: flex;
  min-height: 52px;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--community-line);
  border-radius: 8px;
  background: #fff;
  color: var(--community-ink);
  padding: 10px 12px;
  font-weight: 750;
}
.community-option { cursor: pointer; }
.community-option .ui-icon,
.community-location-field .ui-icon { flex: 0 0 auto; color: var(--community-teal); }
.community-location-field input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: inherit; font: inherit; }
.community-privacy-note { display: flex; align-items: center; gap: 7px; margin: 0; color: var(--community-copy); font-size: .82rem; }
.community-publish { min-height: 50px; }

.community-comments { margin-top: 16px; }
.community-comments .section-title { display: flex; align-items: center; justify-content: space-between; }
.community-comments .section-title span { display: grid; min-width: 30px; height: 30px; place-items: center; border-radius: 50%; background: var(--community-soft); color: var(--community-teal-dark); font-weight: 800; }
.community-comment-list { display: grid; gap: 10px; margin: 12px 0; }
.community-comment {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  border: 1px solid var(--community-line);
  border-radius: 8px;
  background: #f8fbfc;
  padding: 12px;
}
.community-comment p { margin: 0 0 0 50px; color: #24475d; line-height: 1.45; overflow-wrap: anywhere; white-space: pre-wrap; }
.community-comment footer { display: flex; justify-content: space-between; margin-left: 50px; color: var(--community-copy); font-size: .72rem; }
.community-comment footer button { border: 0; background: transparent; color: #c53847; font-weight: 800; }
.community-comment-form { position: sticky; z-index: 3; bottom: 82px; display: grid; grid-template-columns: minmax(0, 1fr) 44px; gap: 8px; border: 1px solid var(--community-line); border-radius: 8px; background: rgba(255,255,255,.96); padding: 8px; box-shadow: 0 10px 24px rgba(8,42,74,.12); backdrop-filter: blur(12px); }
.community-comment-form input { width: 100%; min-width: 0; border: 0; outline: 0; padding: 0 8px; font: inherit; }
.community-comment-form button { display: grid; width: 44px; height: 44px; place-items: center; border: 0; border-radius: 50%; background: var(--community-teal); color: #fff; }

.community-profile-hero { position: relative; overflow: hidden; display: grid; justify-items: center; gap: 8px; border: 1px solid var(--community-line); border-radius: 8px; background: #fff; padding: 86px 18px 20px; text-align: center; box-shadow: 0 10px 30px rgba(8,42,74,.07); }
.community-profile-wave { position: absolute; inset: 0 0 auto; display: grid; height: 112px; place-items: center; overflow: hidden; background: linear-gradient(135deg, #d8f5f1, #dceffd 62%, #f4fbff); color: #54bdd0; }
.community-profile-wave .ui-icon { width: 170px; height: 76px; opacity: .72; }
.community-profile-avatar { position: relative; z-index: 1; }
.community-profile-avatar .avatar-xl { width: 104px; height: 104px; border: 4px solid #fff; box-shadow: 0 8px 20px rgba(8,42,74,.15); }
.community-profile-avatar .presence-dot { width: 18px; height: 18px; border-width: 3px; }
.community-profile-hero h2 { margin: 3px 0 0; font-size: 1.35rem; }
.community-role-badge { border-radius: 999px; background: #e4f7f4; color: var(--community-teal-dark); padding: 4px 10px; font-size: .75rem; font-weight: 850; }
.community-status { margin: 3px 0; color: var(--community-teal-dark); font-weight: 800; }
.community-bio { max-width: 520px; margin: 0; color: var(--community-copy); line-height: 1.5; white-space: pre-wrap; }
.community-profile-edit { width: min(100%, 520px); min-width: 0; max-width: 100%; margin-top: 8px; border-top: 1px solid var(--community-line); padding-top: 10px; text-align: left; }
.community-profile-edit summary { cursor: pointer; color: var(--community-teal-dark); font-weight: 850; text-align: center; }
.community-profile-edit:not([open]) > :not(summary) { display: none; }
.community-profile-edit form { width: 100%; min-width: 0; max-width: 100%; display: grid; gap: 10px; margin-top: 12px; }
.community-profile-edit label { display: grid; gap: 5px; color: var(--community-copy); font-size: .78rem; }
.community-profile-edit input, .community-profile-edit textarea { width: 100%; border: 1px solid var(--community-line); border-radius: 8px; padding: 10px; color: var(--community-ink); font: inherit; }
.community-profile-edit .primary-action { width: 100%; min-width: 0; max-width: 100%; }
.community-profile-posts { margin-top: 18px; }
.community-profile-posts .section-title { display: flex; align-items: center; justify-content: space-between; }
.community-profile-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.community-profile-grid > button { overflow: hidden; display: grid; min-width: 0; aspect-ratio: 1; place-items: center; border: 1px solid var(--community-line); border-radius: 8px; background: #f4fafb; color: var(--community-copy); padding: 0; }
.community-profile-grid img { width: 100%; height: 100%; object-fit: cover; }
.community-profile-grid span { display: -webkit-box; overflow: hidden; padding: 12px; line-height: 1.35; -webkit-box-orient: vertical; -webkit-line-clamp: 5; }
.community-profile-grid .empty-state { grid-column: 1 / -1; aspect-ratio: auto; }

@keyframes community-spin { to { transform: rotate(360deg); } }

@media (max-width: 720px) {
  .community-page { padding-bottom: 8px; }
  .community-page-head { align-items: flex-start; }
  .community-page-head p { font-size: .88rem; }
  .community-scope { width: 100%; }
  .community-active-strip { align-items: flex-start; flex-direction: column; gap: 9px; }
  .community-active-avatars { width: 100%; overflow: hidden; padding-left: 2px; }
  .community-post-head { padding: 12px; }
  .community-post-copy { padding: 0 12px 12px; }
  .community-post-photo { aspect-ratio: 1 / 1; }
  .community-compose-options { grid-template-columns: 1fr; }
  .community-comment-form { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .community-profile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 370px) {
  .community-composer-trigger { grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; padding-inline: 9px; font-size: .78rem; }
  .community-identity strong { font-size: .86rem; }
  .community-active-avatars button { width: 34px; height: 34px; }
  .community-post-photo { max-height: 420px; }
  .community-page .mobile-bottom-nav button span:last-child { font-size: .54rem; }
}

@media (prefers-reduced-motion: reduce) {
  .community-loading .ui-icon { animation: none; }
}
