.phone-screen:has(> .community-page:not([hidden])) {
  background: var(--paper);
}

.phone-screen:has(> .community-page:not([hidden])) > .app-header {
  display: none;
}

.community-page:not([hidden]) {
  --community-gutter: 16px;
  --community-card-shadow: 0 4px 24px rgb(0 0 0 / 4%);
  display: grid;
  container: community / size;
  grid-area: 2 / 1 / 4;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  overflow: hidden;
  font: 400 14px/20px var(--academy-sans);
  letter-spacing: .02em;
}

.home-toolbar.community-toolbar {
  display: flex;
  justify-content: space-between;
  padding: 8px var(--community-gutter) 0;
}

.community-toolbar button {
  position: relative;
  padding: 0;
  color: var(--ink);
}

.community-profile {
  display: block;
  border-radius: 50%;
  object-fit: cover;
}

.community-unread,
.community-group-update {
  position: absolute;
  inset: 0 0 auto auto;
  border: 1px solid var(--paper);
  color: var(--fill);
  background: var(--academy-mom-500);
}

.community-unread {
  display: grid;
  width: 16px;
  height: 16px;
  place-items: center;
  border-radius: 50%;
  font: 500 10px/1 var(--academy-sans);
}

.community-scroll {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  padding-block: 16px;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.community-section {
  flex: none;
  min-width: 0;
}

.community-section-heading {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  padding-inline: calc(var(--community-gutter) + 8px) calc(var(--community-gutter) + 2px);
}

.community-page :is(h2, h3, p) {
  margin: 0;
}

.community-page :is(h2, h3) {
  font-size: 16px;
  line-height: 22px;
}

.community-section-next {
  display: grid;
  width: 32px;
  height: 40px;
  min-height: 0;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: none;
  cursor: pointer;
}

.community-page :is(button, .community-rail):focus-visible {
  outline: 2px solid var(--academy-wine);
  outline-offset: -2px;
}

.community-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding-inline: var(--community-gutter);
}

.community-group {
  position: relative;
  display: grid;
  min-width: 0;
  align-content: start;
  justify-items: center;
  gap: 6px;
  padding: 24px 10px 16px;
  border-radius: 24px;
  background: linear-gradient(var(--academy-blush), var(--fill));
  box-shadow: inset 0 4px 12px var(--fill), 0 4px 12px rgb(0 0 0 / 4%);
  text-align: center;
}

.community-group-art {
  display: block;
  border-radius: 17.5px;
  background: var(--fill);
  object-fit: cover;
}

.community-group h3 {
  margin-block-end: -2px;
}

.community-group-stats {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  line-height: 18px;
}

.community-group-update {
  padding-inline: 6px;
  border-radius: 12px 16px 16px 2px;
  font-size: 12px;
  line-height: 18px;
}

.community-join,
.community-post-button {
  min-height: 32px;
  min-width: 80px;
  padding: 4px 12px;
  border: 0;
  border-radius: 999px;
  background: var(--academy-wine);
  color: var(--fill);
  font: 500 14px/20px var(--academy-sans);
  letter-spacing: .02em;
  cursor: pointer;
}

.community-join[aria-pressed="true"] {
  background: var(--academy-pill);
  color: var(--academy-wine);
  box-shadow: inset 0 0 0 1px var(--academy-wine);
}

.community-topics .community-section-heading {
  margin-block-end: 8px;
}

.community-rail {
  padding-inline: var(--community-gutter);
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: none;
}

.community-topic-rows,
.community-topic-rows ul {
  display: flex;
  gap: 8px;
  width: max-content;
}

.community-topic-rows {
  flex-direction: column;
}

.community-topic-rows ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.community-topic-rows li {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border-radius: 100px;
  background: var(--fill);
  white-space: nowrap;
}

.community-topic-rows img {
  flex: none;
}

.community-topic-long {
  max-width: 200px;
}

.community-topic-long span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.community-topic-rows small {
  padding: 2px 4px;
  border-radius: 6px;
  background: var(--academy-mom-500);
  color: var(--fill);
  font: 400 10px/13px var(--academy-sans);
}

.community-featured-rail {
  display: flex;
  gap: 16px;
  margin-block-end: -12px;
  padding-block-end: 12px;
  scroll-padding-inline: var(--community-gutter);
  scroll-snap-type: inline proximity;
}

.community-feature-card {
  display: grid;
  flex: 0 0 min(292px, 78cqw);
  grid-template-rows: auto 1fr auto;
  gap: 8px;
  min-width: 0;
  min-height: 193px;
  padding: 16px;
  border-radius: 24px;
  background: var(--fill);
  box-shadow: var(--community-card-shadow);
  scroll-snap-align: start;
}

.community-author,
.community-feature-metrics,
.community-reactions,
.community-heat {
  display: flex;
  align-items: center;
  gap: 4px;
}

.community-author {
  gap: 8px;
  font-weight: 500;
  line-height: 18px;
}

.community-author-options {
  margin-inline-start: auto;
}

.community-author-avatar,
.community-reactions img {
  display: block;
  border-radius: 50%;
  object-fit: cover;
}

.community-daily-avatar {
  position: relative;
  width: 24px;
  height: 24px;
}

.community-daily-logo {
  position: absolute;
  inset: 7px auto auto 6px;
}

.community-daily-badge {
  position: absolute;
  inset: auto 0 0 auto;
  width: 10px;
  height: 10px;
  overflow: hidden;
  mask-image: url("daily-badge-mask.svg");
}

.community-daily-badge img {
  position: absolute;
  top: -71.5px;
  left: -35.5px;
}

.community-feature-copy p {
  display: -webkit-box;
  margin-block-start: 4px;
  overflow: hidden;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.community-added-post p {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.community-feature-metrics {
  color: #9f969b;
  font-size: 12px;
  line-height: 18px;
}

.community-reactions {
  gap: 0;
}

.community-reactions img {
  border: 1px solid var(--fill);
}

.community-reactions img + img {
  margin-inline-start: -12px;
}

.community-heat {
  margin-inline-start: auto;
  white-space: nowrap;
}

.community-post-toolbar {
  display: flex;
  justify-content: center;
  padding: 10px 16px 12px;
}

.community-post-button {
  min-width: 135px;
  min-height: 44px;
  background: linear-gradient(var(--academy-wine), var(--academy-mom-500));
  box-shadow: inset 0 0 0 1px #fff4, inset 0 4px 7px #fff3, var(--community-card-shadow);
}

.community-tab-selected {
  display: none;
}

.community-page:not([hidden]) ~ .tab-bar {
  margin-inline: 21px;
  border-color: #d0c9cb;
  background: linear-gradient(#f0eeef, var(--paper));
}

.community-page:not([hidden]) ~ .tab-bar [data-tab="community"] {
  background: #240f1b14;
  font-weight: 600;
}

.community-page:not([hidden]) ~ .tab-bar [data-tab="community"] svg {
  display: none;
}

.community-page:not([hidden]) ~ .tab-bar .community-tab-selected {
  display: block;
}

.community-composer > .academy-dialog-viewport .academy-dialog-panel {
  display: grid;
  gap: 12px;
}

.community-composer :is(h2, p) {
  margin: 0;
}

.community-composer textarea {
  width: 100%;
  padding: 12px;
  resize: vertical;
  border: 1px solid var(--stroke);
  border-radius: 14px;
  color: var(--ink);
  background: var(--fill);
  font: inherit;
}

.community-composer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.community-composer-actions button[value="cancel"] {
  padding: 4px 12px;
  border: 0;
  border-radius: 999px;
  color: var(--academy-wine);
  background: var(--academy-pill);
  font: inherit;
  cursor: pointer;
}

@container community (max-height: 755px) {
  .community-scroll {
    gap: 12px;
    padding-block: 8px;
  }

  .community-section-heading {
    min-height: 40px;
  }

  .community-group {
    padding-block: 18px 12px;
  }

  .community-topics .community-section-heading {
    margin-block-end: 4px;
  }

  .community-feature-card {
    min-height: 176px;
  }
}
