/**
 * Chat oversight — classic professional moderation suite
 * Light: executive slate · white panels · APC flag accents
 * Dark: refined command surfaces
 */

.ec-co-page {
  --co-ink: #0f172a;
  --co-muted: #64748b;
  --co-label: #475569;
  --co-line: rgba(15, 23, 42, 0.1);
  --co-line-strong: rgba(15, 23, 42, 0.14);
  --co-surface: #ffffff;
  --co-surface-2: #f8fafc;
  --co-surface-3: #f1f5f9;
  --co-red: #e91e2f;
  --co-blue: #0284c7;
  --co-sky: #6ec6e8;
  --co-green: #15803d;
  --co-warn: #b45309;
  --co-shadow: 0 1px 3px rgba(15, 23, 42, 0.05), 0 8px 28px rgba(15, 23, 42, 0.06);
  position: relative;
  display: grid;
  grid-template-columns: minmax(320px, 360px) 1fr;
  min-height: calc(100dvh - 7.5rem);
  border: 1px solid var(--co-line);
  border-radius: 0.85rem;
  overflow: hidden;
  background: var(--co-surface);
  color: var(--co-ink);
  box-shadow: var(--co-shadow);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}

.ec-co-page::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  z-index: 4;
  background: linear-gradient(
    90deg,
    #e91e2f 0%,
    #e91e2f 33.33%,
    #f5f5f5 33.33%,
    #f5f5f5 66.66%,
    #6ec6e8 66.66%,
    #6ec6e8 100%
  );
  pointer-events: none;
}

html.dark .ec-co-page {
  --co-ink: rgba(255, 255, 255, 0.94);
  --co-muted: rgba(255, 255, 255, 0.55);
  --co-label: rgba(255, 255, 255, 0.68);
  --co-line: rgba(255, 255, 255, 0.1);
  --co-line-strong: rgba(255, 255, 255, 0.14);
  --co-surface: rgba(8, 14, 24, 0.94);
  --co-surface-2: rgba(255, 255, 255, 0.035);
  --co-surface-3: rgba(255, 255, 255, 0.06);
  --co-blue: #6ec6e8;
  --co-green: #4ade80;
  --co-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  border-color: rgba(110, 198, 232, 0.22);
}

/* ── Sidebar ── */
.ec-co-sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--co-line);
  min-height: 0;
  background:
    linear-gradient(180deg, rgba(110, 198, 232, 0.045), transparent 40%),
    var(--co-surface);
}

.ec-co-sidebar__head {
  padding: 1.35rem 1.15rem 1rem;
  border-bottom: 1px solid var(--co-line);
  background: var(--co-surface);
}

.ec-co-sidebar__brand {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.95rem;
}

.ec-co-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  flex-shrink: 0;
  border-radius: 0.55rem;
  border: 1px solid rgba(233, 30, 47, 0.28);
  background: linear-gradient(145deg, rgba(233, 30, 47, 0.1), rgba(110, 198, 232, 0.1));
  overflow: hidden;
  padding: 0.15rem;
}

.ec-co-brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

html.dark .ec-co-brand-mark {
  border-color: rgba(110, 198, 232, 0.28);
  background: rgba(255, 255, 255, 0.94);
}

.ec-co-kicker {
  margin: 0;
  font-size: 0.62rem;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--co-blue);
}

.ec-co-sidebar__head h1 {
  margin: 0.2rem 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.28rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--co-ink);
}

.ec-co-sidebar__head > p,
.ec-co-sidebar__brand p {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  color: var(--co-muted);
  line-height: 1.45;
  max-width: 28ch;
}

.ec-co-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
  margin-bottom: 0.85rem;
}

.ec-co-stat {
  padding: 0.55rem 0.45rem;
  border-radius: 0.5rem;
  border: 1px solid var(--co-line);
  background: var(--co-surface-2);
  text-align: center;
}

.ec-co-stat strong {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--co-ink);
  line-height: 1.1;
}

.ec-co-stat span {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.62rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--co-muted);
}

.ec-co-filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.ec-co-filters input[type="search"] {
  grid-column: 1 / -1;
}

.ec-co-filters input,
.ec-co-filters select {
  width: 100%;
  border: 1px solid var(--co-line-strong);
  border-radius: 0.5rem;
  background: var(--co-surface-2);
  color: var(--co-ink);
  padding: 0.55rem 0.7rem;
  font: inherit;
  font-size: 0.8rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ec-co-filters input:focus,
.ec-co-filters select:focus {
  outline: none;
  border-color: rgba(110, 198, 232, 0.65);
  box-shadow: 0 0 0 3px rgba(110, 198, 232, 0.18);
  background: var(--co-surface);
}

.ec-co-filters [data-co-refresh] {
  grid-column: 1 / -1;
}

/* ── List ── */
.ec-co-list {
  flex: 1;
  overflow: auto;
  padding: 0.55rem;
  min-height: 0;
  background:
    linear-gradient(180deg, var(--co-surface-2), transparent 1.25rem),
    var(--co-surface-2);
}

.ec-co-row {
  width: 100%;
  display: grid;
  grid-template-columns: 2.4rem 1fr;
  gap: 0.7rem;
  align-items: flex-start;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  border-radius: 0.65rem;
  padding: 0.72rem 0.75rem;
  cursor: pointer;
  margin-bottom: 0.25rem;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.ec-co-row:hover {
  background: var(--co-surface);
  border-color: var(--co-line);
}

.ec-co-row.is-active {
  background: var(--co-surface);
  border-color: rgba(110, 198, 232, 0.45);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

html.dark .ec-co-row.is-active {
  background: rgba(110, 198, 232, 0.08);
  border-color: rgba(110, 198, 232, 0.3);
}

.ec-co-row.is-locked {
  box-shadow: inset 3px 0 0 var(--co-warn);
}

.ec-co-avatar {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 0.5rem;
  background: linear-gradient(145deg, #0369a1, #0284c7);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid rgba(15, 23, 42, 0.06);
}

.ec-co-avatar--group {
  background: linear-gradient(145deg, #0f766e, #15803d);
}

.ec-co-row__body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}

.ec-co-row__top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: baseline;
}

.ec-co-row__top strong {
  font-size: 0.88rem;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ec-co-row__top time,
.ec-co-row__meta,
.ec-co-row__preview,
.ec-co-muted,
.ec-co-members {
  font-size: 0.72rem;
  color: var(--co-muted);
}

.ec-co-row__top time {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.ec-co-row__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.ec-co-row__preview {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.78rem;
  color: var(--co-label);
}

.ec-co-badge {
  display: inline-flex;
  padding: 0.08rem 0.4rem;
  border-radius: 0.3rem;
  background: rgba(2, 132, 199, 0.1);
  color: var(--co-blue);
  border: 1px solid rgba(2, 132, 199, 0.16);
  font-size: 0.6rem;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.ec-co-badge--warn {
  background: rgba(180, 83, 9, 0.1);
  border-color: rgba(180, 83, 9, 0.22);
  color: var(--co-warn);
}

.ec-co-badge--ok {
  background: rgba(47, 168, 79, 0.1);
  border-color: rgba(47, 168, 79, 0.22);
  color: var(--co-green);
}

.ec-co-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.7rem 0.9rem;
  border-top: 1px solid var(--co-line);
  font-size: 0.74rem;
  color: var(--co-muted);
  background: var(--co-surface);
}

/* ── Thread ── */
.ec-co-thread {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--co-surface);
}

.ec-co-empty,
.ec-co-empty-pane {
  padding: 1.75rem 1.5rem;
  text-align: center;
  color: var(--co-muted);
  font-size: 0.85rem;
  line-height: 1.45;
}

.ec-co-empty-pane {
  margin: auto;
  max-width: 24rem;
}

.ec-co-empty-pane__icon {
  width: 3.25rem;
  height: 3.25rem;
  margin: 0 auto 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.75rem;
  border: 1px solid var(--co-line);
  background: linear-gradient(145deg, rgba(233, 30, 47, 0.08), rgba(110, 198, 232, 0.1));
  color: var(--co-blue);
}

.ec-co-empty-pane__icon svg {
  width: 1.45rem;
  height: 1.45rem;
}

.ec-co-empty-pane h2 {
  margin: 0 0 0.4rem;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--co-ink);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.ec-co-empty-pane p {
  margin: 0;
}

.ec-co-thread-head {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1.05rem 1.25rem;
  border-bottom: 1px solid var(--co-line);
  background: var(--co-surface);
  position: relative;
}

.ec-co-thread-head::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: linear-gradient(
    90deg,
    rgba(233, 30, 47, 0.55),
    rgba(245, 245, 245, 0.9),
    rgba(110, 198, 232, 0.65)
  );
  opacity: 0.7;
  pointer-events: none;
}

.ec-co-thread-head__meta {
  min-width: 0;
  flex: 1;
}

.ec-co-thread-head h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.ec-co-thread-head .ec-co-muted {
  margin: 0.28rem 0 0;
}

.ec-co-lock-note {
  margin: 0.45rem 0 0;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.55rem;
  border-radius: 0.4rem;
  background: rgba(180, 83, 9, 0.1);
  border: 1px solid rgba(180, 83, 9, 0.22);
  color: var(--co-warn);
  font-size: 0.74rem;
  font-weight: 650;
}

.ec-co-members {
  margin: 0.45rem 0 0;
  line-height: 1.45;
  max-width: 52ch;
}

.ec-co-member-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.55rem;
}

.ec-co-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--co-line);
  background: var(--co-surface-2);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--co-label);
}

.ec-co-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
  flex-shrink: 0;
}

.ec-co-btn {
  border: 1px solid var(--co-line-strong);
  background: var(--co-surface);
  color: var(--co-ink);
  border-radius: 0.5rem;
  padding: 0.48rem 0.8rem;
  font-size: 0.74rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.ec-co-btn:hover {
  background: var(--co-surface-2);
  border-color: rgba(110, 198, 232, 0.45);
}

.ec-co-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ec-co-btn--warn {
  border-color: rgba(180, 83, 9, 0.35);
  color: var(--co-warn);
  background: rgba(180, 83, 9, 0.06);
}

.ec-co-btn--warn:hover {
  background: rgba(180, 83, 9, 0.12);
  border-color: rgba(180, 83, 9, 0.45);
}

.ec-co-btn--danger {
  background: var(--co-red);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 8px rgba(233, 30, 47, 0.28);
}

.ec-co-btn--danger:hover {
  background: #c41828;
}

.ec-co-btn--primary {
  background: var(--co-blue);
  border-color: transparent;
  color: #fff;
}

html.light .ec-co-btn--primary {
  background: #0284c7;
}

/* ── Message stream ── */
.ec-co-stream {
  flex: 1;
  overflow: auto;
  padding: 1.2rem 1.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  min-height: 280px;
  background-color: var(--co-surface-2);
  background-image:
    linear-gradient(rgba(15, 23, 42, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.018) 1px, transparent 1px);
  background-size: 28px 28px;
}

html.dark .ec-co-stream {
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
}

.ec-co-msg {
  padding: 0.75rem 0.9rem 0.7rem;
  border-radius: 0.65rem;
  border: 1px solid var(--co-line);
  background: var(--co-surface);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.ec-co-msg__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.65rem;
  margin-bottom: 0.4rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--co-line);
}

.ec-co-msg__head strong {
  font-size: 0.84rem;
  font-weight: 650;
}

.ec-co-msg__head time {
  font-size: 0.68rem;
  color: var(--co-muted);
  font-variant-numeric: tabular-nums;
}

.ec-co-msg__del {
  margin-left: auto;
  border: 1px solid rgba(233, 30, 47, 0.22);
  background: rgba(233, 30, 47, 0.06);
  color: var(--co-red);
  border-radius: 0.35rem;
  padding: 0.2rem 0.5rem;
  font-size: 0.68rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
}

.ec-co-msg__del:hover {
  background: rgba(233, 30, 47, 0.12);
}

.ec-co-msg__body {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.9rem;
  line-height: 1.48;
  color: var(--co-ink);
}

html.light #main-content .ec-co-msg__body,
html.light #main-content .ec-co-empty-pane p,
html.light #main-content .ec-co-thread-head p {
  color: inherit !important;
}

html.light #main-content .ec-co-msg__body {
  color: var(--co-ink) !important;
}

.ec-co-msg__attach {
  margin-bottom: 0.4rem;
}

.ec-co-msg__attach img {
  max-width: min(100%, 14rem);
  max-height: 12rem;
  border-radius: 0.45rem;
  display: block;
  border: 1px solid var(--co-line);
  object-fit: cover;
}

.ec-co-msg__attach a {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--co-blue);
  font-weight: 650;
  font-size: 0.84rem;
  text-decoration: none;
  padding: 0.35rem 0.55rem;
  border-radius: 0.4rem;
  border: 1px solid rgba(2, 132, 199, 0.2);
  background: rgba(2, 132, 199, 0.06);
}

.ec-co-msg__attach a:hover {
  text-decoration: underline;
}

@media (max-width: 900px) {
  .ec-co-page {
    grid-template-columns: 1fr;
    border-radius: 0.75rem;
  }

  .ec-co-sidebar {
    max-height: 44vh;
    border-right: 0;
    border-bottom: 1px solid var(--co-line);
  }

  .ec-co-thread-head {
    flex-direction: column;
  }

  .ec-co-actions {
    width: 100%;
  }

  .ec-co-stats {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 520px) {
  .ec-co-filters {
    grid-template-columns: 1fr;
  }
}
