.forum-page {
  width: min(100% - 2rem, 880px);
  margin: 0 auto;
  padding: 4rem 0 5rem;
}

.forum-hero {
  text-align: center;
  margin-bottom: 2rem;
}

.forum-hero .title {
  margin-top: 0;
}

.forum-prompt {
  color: var(--color-text-muted);
  margin: 0.75rem 0 0;
  font-size: 0.95rem;
}

.eyebrow {
  margin: 0 0 0.25rem;
  color: var(--color-accent);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.composer {
  background: var(--color-bg);
  border: 1px solid #e7e7e7;
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-heading h2 {
  margin: 0;
  color: var(--color-heading);
  font-size: 1.35rem;
}

.composer-form {
  display: grid;
  gap: 0.55rem;
}

.composer-form label,
.search-field label,
.reply-form label {
  margin-top: 0.35rem;
  color: var(--color-heading);
  font-size: 0.85rem;
  font-weight: 700;
}

.composer-form .form-input,
.search-field .form-input,
.sort-control .form-input,
.reply-form textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #d8d8d8;
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--color-text);
  font: inherit;
  font-size: 0.95rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.file-input {
  width: 100%;
  padding: 0.6rem;
  border: 1px dashed #c4b5fd;
  border-radius: var(--radius-sm);
  background: #faf5ff;
  color: #4338ca;
  font: inherit;
  font-size: 0.85rem;
}

.optional-label {
  color: var(--color-text-muted);
  font-size: 0.75rem;
  font-weight: 400;
}

.media-preview {
  margin: 0;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

.media-preview img,
.media-preview video {
  display: block;
  width: 100%;
  max-height: 360px;
  margin-top: 0.5rem;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

.composer-form .form-input:focus,
.search-field .form-input:focus,
.sort-control .form-input:focus,
.reply-form textarea:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
  outline: none;
}

.composer-form .nav-btn {
  justify-self: start;
  margin-top: 0.5rem;
}

.forum-controls {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: 1.5rem;
}

.search-field {
  max-width: 38rem;
}

.search-field label {
  display: block;
  margin: 0 0 0.5rem;
}

.filter-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
}

.category-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.category-filter {
  border: 1px solid #d8d8d8;
  border-radius: 999px;
  padding: 0.5rem 0.85rem;
  background: #ffffff;
  color: var(--color-text-muted);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.category-filter:hover,
.category-filter.active {
  border-color: var(--color-accent);
  background: var(--color-accent);
  color: #ffffff;
}

.sort-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--color-text-muted);
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

.sort-control .form-input {
  width: auto;
  padding: 0.45rem 2rem 0.45rem 0.65rem;
}

.form-message {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  background: #ede9fe;
  color: #4338ca;
  font-size: 0.9rem;
}

.forum-feed {
  display: grid;
  gap: 1rem;
}

.forum-card {
  overflow: hidden;
  background: var(--color-bg);
  border: 1px solid #e7e7e7;
  border-radius: var(--radius-md);
  padding: var(--space-md);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
}

.forum-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.post-header,
.post-author,
.post-footer,
.reply-meta {
  display: flex;
  align-items: center;
}

.post-header {
  justify-content: space-between;
  gap: 1rem;
}

.post-author {
  gap: 0.7rem;
}

.post-avatar,
.reply-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 50%;
  background: #ede9fe;
  color: var(--color-accent);
  font-weight: 700;
}

.post-avatar {
  width: 42px;
  height: 42px;
}

.post-author strong,
.reply-meta strong {
  display: block;
  color: var(--color-heading);
  font-size: 0.9rem;
}

.post-author time,
.reply-meta time {
  color: var(--color-text-muted);
  font-size: 0.75rem;
}

.category-pill {
  border-radius: 999px;
  padding: 0.35rem 0.65rem;
  background: #eef2ff;
  color: #4338ca;
  font-size: 0.72rem;
  font-weight: 700;
}

.forum-card h2 {
  margin: 1rem 0 0.65rem;
  color: var(--color-heading);
  font-size: 1.25rem;
  line-height: 1.35;
}

.post-content {
  margin: 0;
  color: #555555;
  line-height: 1.7;
  white-space: pre-wrap;
}

.post-media {
  display: block;
  width: 100%;
  max-height: 420px;
  margin-top: 1rem;
  object-fit: contain;
  border-radius: var(--radius-md);
  background: #000000;
}

.post-footer {
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.25rem;
  padding-top: 0.8rem;
  border-top: 1px solid #eeeeee;
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

.post-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.delete-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: #b3261e;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.delete-button:hover {
  text-decoration: underline;
}

.reply-delete {
  margin-left: auto;
  padding: 0.25rem 0.4rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: #b3261e;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}

.text-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--color-accent);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.replies {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #eeeeee;
}

.replies-list {
  display: grid;
  gap: 0.75rem;
}

.reply {
  display: flex;
  gap: 0.7rem;
}

.reply-avatar {
  width: 34px;
  height: 34px;
  font-size: 0.8rem;
}

.reply-body {
  flex: 1;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--color-surface);
}

.reply-meta {
  justify-content: space-between;
  gap: 1rem;
}

.reply-body p {
  margin: 0.5rem 0 0;
  color: #555555;
  line-height: 1.55;
  white-space: pre-wrap;
}

.reply-form {
  display: grid;
  gap: 0.5rem;
  margin-top: 1rem;
}

.reply-form textarea {
  resize: vertical;
}

.reply-form .nav-btn {
  justify-self: start;
}

.login-prompt,
.empty-replies,
.loading-state,
.error-state {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.empty-state,
.error-state {
  padding: 3rem 1rem;
  border: 1px dashed #d8d8d8;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  text-align: center;
}

.empty-state span {
  font-size: 2rem;
}

.empty-state h2 {
  margin: 0.5rem 0 0.25rem;
  color: var(--color-heading);
}

.empty-state p {
  margin: 0;
  color: var(--color-text-muted);
}

@media (max-width: 700px) {
  .forum-page {
    width: min(100% - 1rem, 880px);
    padding-top: 2.5rem;
  }

  .section-heading,
  .filter-row {
    align-items: stretch;
    flex-direction: column;
  }

  .section-heading .nav-btn {
    align-self: flex-start;
  }

  .sort-control {
    align-items: flex-start;
    flex-direction: column;
  }

  .sort-control .form-input {
    width: 100%;
  }

  .post-header {
    align-items: flex-start;
  }

  .category-pill {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .post-footer {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .forum-card {
    padding: 1rem;
  }

  .post-header {
    flex-direction: column;
  }

  .reply-meta {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.2rem;
  }
}