.community-workspace {
  display: grid;
  gap: 0;
  padding: 0 24px 24px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.community-workspace button {
  min-height: 36px;
  padding: 8px 13px;
  font: inherit;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.2;
}

.community-workspace h2,
.community-workspace h3,
.community-workspace h4,
.community-workspace p {
  margin: 0;
}

.community-control-card,
.community-safety,
.community-section {
  min-width: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.community-control-card {
  padding: 22px 0 19px;
}

.community-control-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.community-control-copy h2,
.community-section h2 {
  font-size: 18px;
  font-weight: 750;
  line-height: 1.35;
}

.community-control-copy h2 {
  display: inline;
  margin-left: 9px;
}

.community-control-copy p,
.community-section header p,
.community-profiles summary p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.community-state {
  display: inline-block;
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 800;
  vertical-align: 2px;
}

.community-state.is-active {
  background: var(--surface-green);
  color: var(--green-dark);
}

.community-state.is-inactive {
  background: var(--surface-orange);
  color: var(--orange-dark);
}

.community-control-actions {
  flex: 0 0 auto;
}

.community-counts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}

.community-counts > div {
  display: grid;
  align-content: center;
  gap: 3px;
  min-width: 0;
  min-height: 70px;
  padding: 11px 16px;
  background: transparent;
}

.community-counts > div + div {
  border-left: 1px solid var(--line);
}

.community-counts span {
  color: var(--text-soft);
  font-size: 12px;
}

.community-counts strong {
  font-size: 24px;
  font-weight: 750;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.community-counts strong small {
  margin-left: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.community-counts em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

.community-control-note {
  margin-top: 11px !important;
  color: var(--muted);
  font-size: 12px;
}

.community-safety {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(400px, 1.7fr);
  align-items: center;
  gap: 18px;
  padding: 14px 0;
}

.community-safety.is-paused {
  border-color: #e9c5bd;
}

.community-safety-copy {
  display: grid;
  gap: 3px;
  min-width: 190px;
}

.community-safety-copy strong {
  color: var(--green-dark);
  font-size: 14px;
}

.community-safety.is-paused .community-safety-copy strong {
  color: var(--red);
}

.community-safety-copy span {
  color: var(--muted);
  font-size: 12px;
}

.community-safety dl {
  display: grid;
  grid-template-columns: repeat(4, minmax(74px, 1fr));
  gap: 12px;
  margin: 0;
}

.community-safety dt {
  color: var(--muted);
  font-size: 11px;
}

.community-safety dd {
  margin: 2px 0 0;
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.community-section {
  padding: 22px 0;
}

.community-section > header,
.community-profiles > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 10px;
}

.community-section-count {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
}

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

.community-interaction-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.community-post-preview {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 12px;
  min-width: 0;
}

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

.community-post-preview > img {
  width: 360px;
  height: auto;
  max-width: 100%;
  max-height: 540px;
  border-radius: var(--radius-sm);
  object-fit: contain;
  background: var(--surface-soft);
}

.community-post-preview span {
  color: var(--green-dark);
  font-size: 11px;
  font-weight: 750;
}

.community-post-preview h4 {
  margin: 0 0 3px;
  font-size: 14px;
  font-weight: 750;
}

.community-post-preview p {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.5;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.community-post-preview small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.community-comment-review {
  display: grid;
  align-content: start;
  gap: 5px;
  min-width: 0;
}

.community-comment-head,
.community-interaction-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.community-comment-head {
  justify-content: flex-start;
  color: var(--text-soft);
  font-size: 12px;
}

.community-comment-head strong {
  font-weight: 750;
}

.community-comment-head small {
  color: var(--muted);
  font-size: 11px;
}

.community-comment-review label,
.community-agent-fields label {
  display: grid;
  gap: 5px;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 750;
}

.community-comment-review textarea,
.community-agent-fields input,
.community-agent-fields select,
.community-agent-fields textarea {
  width: 100%;
  min-width: 0;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  outline: none;
}

.community-comment-review textarea:focus,
.community-agent-fields input:focus,
.community-agent-fields select:focus,
.community-agent-fields textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(37, 134, 58, .12);
}

.community-comment-review textarea {
  min-height: 44px;
  resize: vertical;
  font-size: 13px;
  font-weight: 500;
}

.community-interaction-details {
  min-width: 92px;
  color: var(--muted);
  font-size: 12px;
}

.community-interaction-details summary {
  width: fit-content;
  cursor: pointer;
}

.community-interaction-details p {
  max-width: 380px;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.community-comment-review p,
.community-comment-review small {
  color: var(--muted);
  font-size: 11px;
}

.community-interaction-status,
.community-run-status {
  justify-self: start;
  padding: 3px 7px;
  border-radius: var(--radius-sm);
  background: var(--surface-green);
  color: var(--green-dark);
  font-size: 11px;
  font-weight: 750;
}

.community-interaction-status.status-published,
.community-run-status.completed {
  background: var(--surface-blue);
  color: var(--blue);
}

.community-interaction-status.status-withdrawn,
.community-run-status.paused {
  background: var(--surface-ink);
  color: var(--text-soft);
}

.community-run-status.failed {
  background: #fff0ed;
  color: var(--red);
}

.community-interaction-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 0;
}

.community-workspace .danger-button {
  border: 1px solid #e8b7af;
  border-radius: var(--radius-sm);
  background: #fff8f6;
  color: #a73f35;
}

.community-more {
  margin-top: 12px;
}

.community-more > summary {
  padding: 8px 0;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 750;
  cursor: pointer;
}

.community-more .community-interaction-list {
  margin-top: 8px;
}

.community-run-scroll {
  overflow-x: auto;
}

.community-run-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.community-run-table th {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.community-run-table td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  color: var(--text-soft);
  vertical-align: middle;
}

.community-run-table tr:last-child td {
  border-bottom: 0;
}

.community-run-table td:first-child {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.community-run-table td:nth-child(2) strong {
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
}

.community-run-table td:nth-child(4) {
  min-width: 250px;
}

.community-run-table td:nth-child(4) small {
  display: block;
  margin-top: 3px;
  color: var(--red);
  font-size: 11px;
}

.community-run-table td:last-child {
  white-space: nowrap;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.community-profiles > summary {
  margin-bottom: 0;
  list-style: none;
  cursor: pointer;
}

.community-profiles:not([open]) > .community-agent-grid {
  display: none;
}

.community-profiles > summary::-webkit-details-marker {
  display: none;
}

.community-profiles > summary > span {
  flex: 0 0 auto;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 750;
}

.community-profiles[open] > summary {
  margin-bottom: 12px;
}

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

.community-agent-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.community-agent-visual {
  position: relative;
  height: 100px;
  overflow: hidden;
  background: var(--surface-soft);
}

.community-agent-character {
  position: absolute;
  right: 7%;
  bottom: -10%;
  width: 38%;
  height: 120%;
  object-fit: contain;
}

.community-agent-avatar {
  position: absolute;
  left: 18px;
  top: 18px;
  width: 64px;
  height: 64px;
  border: 4px solid #fff;
  border-radius: 50%;
  object-fit: cover;
}

.community-agent-fields {
  display: grid;
  gap: 12px;
  padding: 17px;
}

.community-agent-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.community-agent-heading h3 {
  margin-top: 2px;
  font-size: 18px;
}

.community-agent-heading > div > span {
  color: var(--green-dark);
  font-size: 11px;
  font-weight: 750;
}

.community-switch {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 7px !important;
}

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

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

.community-form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.community-agent-fields textarea {
  min-height: 68px;
  resize: vertical;
}

.community-agent-fields select[multiple] {
  min-height: 104px;
}

@media (max-width: 1100px) {
  .community-agent-grid,
  .community-interaction-list {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 720px) {
  html[data-admin-view="community-agents"] .main,
  html[data-admin-view="community-agents"] .analytics-panel,
  .community-workspace {
    grid-template-columns: minmax(0, 1fr);
  }

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

  .community-workspace {
    padding: 0 16px 20px;
  }

  .community-control-card,
  .community-section {
    padding: 18px 0;
  }

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

  .community-counts,
  .community-safety dl {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .community-counts > div:nth-child(3) {
    border-left: 0;
  }

  .community-counts > div:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }

  .community-form-grid.three,
  .community-form-grid.two {
    grid-template-columns: 1fr;
  }

  .community-run-scroll {
    overflow: visible;
  }

  .community-run-table,
  .community-run-table tbody {
    display: block;
    width: 100%;
  }

  .community-run-table thead {
    display: none;
  }

  .community-run-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 8px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
  }

  .community-run-table tr:last-child {
    border-bottom: 0;
  }

  .community-run-table td {
    display: block;
    min-width: 0 !important;
    padding: 0;
    border: 0;
  }

  .community-run-table td:first-child {
    grid-column: 1;
    grid-row: 1;
  }

  .community-run-table td:nth-child(2) {
    grid-column: 1;
    grid-row: 2;
  }

  .community-run-table td:nth-child(3) {
    grid-column: 2;
    grid-row: 1;
  }

  .community-run-table td:nth-child(4) {
    grid-column: 1 / -1;
    grid-row: 3;
    overflow-wrap: anywhere;
  }

  .community-run-table td:last-child {
    grid-column: 2;
    grid-row: 2;
  }
}
