.community-page {
  display: grid;
  gap: 22px;
}

.community-hero {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
  padding: 30px;
  border: 1px solid #e8daca;
  border-radius: 24px;
  background:
    radial-gradient(circle at 88% 18%, rgba(249, 194, 120, .34), transparent 26%),
    radial-gradient(circle at 72% 88%, rgba(238, 169, 195, .24), transparent 30%),
    linear-gradient(135deg, #fffdf7, #f7eee2);
  box-shadow: var(--shadow);
}

.community-hero h1 {
  margin: 0;
}

.community-hero > div > p:last-child {
  max-width: 720px;
  margin: 12px 0 0;
  color: var(--muted);
}

.community-back {
  display: inline-block;
  margin-bottom: 12px;
  color: var(--brand);
  font-weight: 800;
  text-decoration: none;
}

.community-notifications {
  position: relative;
  z-index: 10;
  flex: 0 0 auto;
}

.community-notification-toggle {
  position: relative;
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 15px;
  border: 1px solid #e1d2bf;
  border-radius: 999px;
  color: var(--text);
  background: rgba(255,255,255,.92);
  font-weight: 800;
  cursor: pointer;
}

.community-notification-panel {
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  display: none;
  width: min(380px, calc(100vw - 40px));
  max-height: 480px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: #fff;
  box-shadow: 0 18px 55px rgba(38, 29, 19, .2);
}

.community-notifications.open .community-notification-panel {
  display: block;
}

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

.community-notification-heading button {
  min-height: 30px;
  padding: 4px 7px;
  border: 0;
  color: var(--brand);
  background: transparent;
  font-size: .8rem;
  font-weight: 800;
  cursor: pointer;
}

.community-notification-list {
  max-height: 410px;
  overflow-y: auto;
}

.community-notification-list a {
  display: grid;
  gap: 4px;
  padding: 13px 16px;
  border-bottom: 1px solid #f0ebe4;
  text-decoration: none;
}

.community-notification-list a.unread {
  background: #fff8e9;
}

.community-notification-list a:hover {
  background: var(--surface-soft);
}

.community-notification-list small {
  color: var(--muted);
}

.community-notification-list p {
  margin: 0;
  padding: 22px;
  color: var(--muted);
  text-align: center;
}

.community-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow);
}

.community-tabs button {
  position: relative;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  border-radius: 13px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
  cursor: pointer;
}

.community-tabs button:hover {
  background: #faf6ee;
}

.community-tabs button.active {
  color: #fff;
  background: linear-gradient(135deg, #7b6345, #9e7a4b);
  box-shadow: 0 7px 18px rgba(101, 76, 44, .22);
}

.community-tabs button > span:first-child {
  font-size: 1.2rem;
}

.community-unread,
[data-community-nav-badge] {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  color: #fff;
  background: #d94c45;
  font-size: .7rem;
  font-weight: 900;
}

[data-community-nav-badge] {
  min-width: 20px;
  height: 20px;
  margin-left: auto;
}

[data-community-nav-badge][hidden] {
  display: none;
}

.community-tabs .active .community-unread {
  color: #b33c36;
  background: #fff;
}

.community-channel {
  display: grid;
  gap: 16px;
}

.community-loading {
  color: var(--muted);
  text-align: center;
}

.community-channel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 2px;
}

.community-channel-heading > div {
  display: flex;
  align-items: center;
  gap: 14px;
}

.community-channel-heading h2,
.community-channel-heading p {
  margin: 0;
}

.community-channel-heading p {
  margin-top: 4px;
  color: var(--muted);
}

.community-channel-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  border-radius: 15px;
  background: #f6ead9;
  font-size: 1.45rem;
}

.community-compose {
  padding: 20px;
  border: 1px solid #e7d7c5;
  border-radius: 20px;
  background: #fff;
  box-shadow: var(--shadow);
}

.community-compose.locked {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}

.community-compose.locked > span {
  font-size: 1.5rem;
}

.community-compose.locked p {
  margin: 0;
}

.community-compose-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.community-compose-title > div {
  display: grid;
  gap: 3px;
}

.community-compose-title small {
  color: var(--muted);
}

.community-compose textarea {
  width: 100%;
  min-height: 112px;
  padding: 13px 15px;
  border: 1px solid #d8cbbb;
  border-radius: 14px;
  resize: vertical;
}

.community-compose textarea:focus,
.community-reply-form textarea:focus {
  border-color: var(--brand);
  outline: 3px solid rgba(118,98,70,.16);
}

.community-compose-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 13px;
}

.community-compose-footer > span {
  color: var(--muted);
  font-size: .83rem;
}

.community-image-picker {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.community-image-picker > span {
  color: var(--muted);
  font-size: .84rem;
}

.community-image-preview {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.community-image-preview figure {
  min-width: 0;
  margin: 0;
}

.community-image-preview img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 10px;
  object-fit: cover;
}

.community-image-preview figcaption {
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: .7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.community-post {
  position: relative;
  padding: 21px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(58, 44, 28, .06);
}

.community-post.pinned {
  border-color: #dcbf8d;
  background: linear-gradient(180deg, #fffdf7, #fff);
}

.community-pinned-label {
  margin: -5px 0 12px;
  color: #876329;
  font-size: .78rem;
  font-weight: 800;
}

.community-post-header {
  display: flex;
  align-items: center;
  gap: 11px;
}

.community-avatar {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, #8e7454, #c59b67);
  font-size: .82rem;
  font-weight: 900;
}

.community-avatar.small {
  width: 34px;
  height: 34px;
  font-size: .68rem;
}

.community-post-header > div,
.community-reply header {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.community-post-header time,
.community-reply time {
  width: 100%;
  color: var(--muted);
  font-size: .76rem;
}

.community-admin-badge {
  padding: 2px 7px;
  border-radius: 999px;
  color: #6f4b17;
  background: #f9e6bd;
  font-size: .68rem;
  font-weight: 900;
}

.community-post-body {
  margin: 16px 0 0;
  line-height: 1.8;
  overflow-wrap: anywhere;
}

.community-post-body a,
.community-reply-body a {
  color: #2878d8;
  font-weight: 700;
}

.community-image-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-top: 16px;
  overflow: hidden;
  border-radius: 15px;
}

.community-image-grid.count-1 {
  grid-template-columns: 1fr;
}

.community-image-grid a {
  min-width: 0;
  background: #eee;
}

.community-image-grid img {
  display: block;
  width: 100%;
  height: 230px;
  object-fit: cover;
}

.community-image-grid.count-1 img {
  height: auto;
  max-height: 580px;
  object-fit: contain;
  background: #f2eee8;
}

.community-post-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 15px;
  padding-top: 11px;
  border-top: 1px solid #f0ebe4;
}

.community-post-actions button {
  min-height: 34px;
  padding: 5px 10px;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-size: .82rem;
  font-weight: 800;
  cursor: pointer;
}

.community-post-actions button:hover {
  color: var(--brand-dark);
  background: var(--surface-soft);
}

.community-post-actions button.reacted {
  color: #b54052;
  background: #fcecef;
}

.community-replies {
  display: grid;
  gap: 12px;
  margin-top: 13px;
  padding: 14px;
  border-radius: 15px;
  background: #f8f5f0;
}

.community-reply {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 9px;
}

.community-reply + .community-reply {
  padding-top: 12px;
  border-top: 1px solid #e8e0d5;
}

.community-reply-body {
  margin: 7px 0 0;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.community-reply .community-post-actions {
  margin-top: 6px;
  padding-top: 0;
  border-top: 0;
}

.community-reply-form {
  display: grid;
  gap: 9px;
  margin-top: 13px;
  padding: 12px;
  border-radius: 14px;
  background: #f8f5f0;
}

.community-reply-form[hidden] {
  display: none;
}

.community-reply-form textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #d8cbbb;
  border-radius: 11px;
  resize: vertical;
}

.community-edit-form {
  display: grid;
  gap: 9px;
  margin: 0;
}

.community-edit-form textarea {
  width: 100%;
  min-height: 120px;
  padding: 11px 12px;
  border: 1px solid #b99b73;
  border-radius: 11px;
  background: #fffdf9;
  font: inherit;
  line-height: 1.65;
  resize: vertical;
}

.community-edit-form textarea:focus {
  outline: 3px solid rgba(185, 155, 115, .22);
  border-color: #8e7454;
}

.community-edit-form > div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.community-reply-form > div {
  display: flex;
  gap: 8px;
}

.community-empty-icon {
  display: block;
  margin-bottom: 10px;
  font-size: 2.2rem;
}

.community-course-links {
  display: grid;
  gap: 15px;
  margin-top: 8px;
}

.community-section-heading h2,
.community-section-heading p {
  margin: 0;
}

.community-course-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.community-course-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.community-course-toolbar input {
  width: min(100%, 520px);
  min-height: 44px;
  padding: 10px 13px;
  border: 1px solid #d8cbbb;
  border-radius: 12px;
  background: #fff;
}

.community-course-toolbar span {
  color: var(--muted);
  font-size: .84rem;
  white-space: nowrap;
}

.community-course-more {
  justify-self: center;
}

.community-course-grid > a {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: #fff;
  box-shadow: var(--shadow);
  text-decoration: none;
}

.community-course-grid > a:hover {
  border-color: #c9b79f;
  transform: translateY(-1px);
}

.community-course-grid > a[hidden] {
  display: none;
}

.community-course-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: #f5eadb;
  font-size: 1.3rem;
}

.community-course-grid strong,
.community-course-grid small {
  display: block;
}

.community-course-grid small {
  margin-top: 4px;
  color: var(--muted);
}

@media (max-width: 760px) {
  .community-hero {
    padding: 22px 18px;
  }

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

  .community-tabs button {
    min-height: 62px;
    flex-direction: column;
    gap: 2px;
    padding: 6px 3px;
    font-size: .78rem;
  }

  .community-tabs .community-unread {
    position: absolute;
    top: 4px;
    right: 5px;
  }

  .community-channel-heading {
    align-items: flex-start;
  }

  .community-channel-heading p {
    font-size: .88rem;
  }

  .community-channel-icon {
    width: 44px;
    height: 44px;
  }

  .community-compose,
  .community-post {
    padding: 16px;
  }

  .community-compose-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .community-compose-footer .button {
    width: 100%;
  }

  .community-image-picker {
    align-items: flex-start;
    flex-direction: column;
  }

  .community-image-preview {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .community-image-grid img {
    height: 170px;
  }

  .community-course-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .community-hero {
    display: block;
  }

  .community-notifications {
    margin-top: 18px;
  }

  .community-notification-panel {
    right: auto;
    left: 0;
    width: calc(100vw - 52px);
  }

  .community-post-actions {
    gap: 2px;
  }

  .community-image-grid img {
    height: 145px;
  }
}
