.chat-topics {
  flex: 0 0 auto;
  min-width: 0;
  color: #233e50;
  background: #f5f9f9;
  border-bottom: 1px solid #d9e6e6;
}

.chat-topics [hidden], .topic-editor [hidden] { display: none !important; }

button.topics-toggle {
  width: 100%;
  display: grid;
  grid-template-columns: 16px auto auto minmax(0, 1fr) 16px;
  align-items: center;
  gap: 2px 8px;
  min-height: 42px;
  padding: 7px 16px;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: left;
  color: #20515a;
}
button.topics-toggle:hover { background: #eaf4f3; }
.topics-toggle > svg, .topics-chevron svg { width: 16px; height: 16px; flex-shrink: 0; }
.topics-heading { flex: none; font-weight: 700; font-size: 13px; }
.topics-count {
  flex: none;
  padding: 2px 6px;
  border-radius: 6px;
  background: #dfeceb;
  color: #28565b;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.topics-next {
  grid-column: 4;
  text-align: right;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-weight: 500;
  font-size: 11px;
  color: #4d6771;
}
.topics-subtitle {
  grid-column: 2 / 6;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #4e6470;
  font-size: 12px;
  font-weight: 450;
}
.topics-chevron { grid-column: 5; grid-row: 1; margin-left: auto; display: flex; color: #5c737b; }
.topics-toggle[aria-expanded="true"] .topics-chevron { transform: rotate(180deg); }
.topics-list {
  max-height: min(390px, 36vh);
  padding: 0 12px 6px;
  overflow: auto;
  scrollbar-width: thin;
  overscroll-behavior: contain;
}
.topic-row { border-top: 1px solid #dbe7e7; }
button.topic-row-toggle {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-height: 38px;
  width: 100%;
  padding: 7px 4px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  text-align: left;
  color: #273f4e;
}
.topic-row-name { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 13px; font-weight: 600; }
.topic-owner { flex-shrink: 0; padding: 1px 6px; border-radius: 4px; background: #e6eeee; font-size: 11px; color: #395761; }
.topic-row-toggle svg { flex: none; width: 13px; height: 13px; margin-top: 3px; }
.topic-row-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.topic-contents { padding: 0 5px 10px; overflow-wrap: anywhere; }
.topic-participant, .topic-detail, .topic-reason, .topic-readiness, .topics-feedback { margin: 0 0 6px; font-size: 12px; line-height: 1.5; }
.topic-participant { color: #4d6572; }
.topic-detail { color: #304958; }
.topic-readiness { color: #365862; }
.topic-readiness strong { margin-right: 4px; }
.topic-reason { color: #4f646f; }
.topic-actions { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.topic-actions button, .topics-feedback button, button.topics-add {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  min-height: 30px;
  padding: 3px 4px;
  border: 0;
  background: transparent;
  color: #0c646e;
  font-weight: 600;
  font-size: 12px;
}
button.topics-add svg { width: 14px; height: 14px; }
.topics-feedback { padding: 7px 4px; color: #894212; }
.topic-form .topic-done { display: flex; flex-direction: row; align-items: center; gap: 8px; }
.topic-done input { width: auto; min-height: auto; }
.topic-form-error { color: #8b371e; margin: 0; }

@media (max-width: 700px) {
  button.topics-toggle { min-height: 40px; padding: 6px 12px; gap: 2px 6px; }
  .topics-list { max-height: min(220px, calc(var(--app-height, 100dvh) * .28)); padding-inline: 10px; }
  .topic-owner { max-width: 39%; }
  .keyboard-open .topics-list { max-height: min(95px, calc(var(--app-height, 100dvh) * .20)); }
}

.topic-meta { min-width: 0; max-width: 100%; overflow-wrap: anywhere; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 7px; }
.topic-short { color: #4c6574; font-size: 11px; font-weight: 550; }
.topic-short[data-readiness="approved"] { color: #14684d; }
.topic-short[data-readiness="human"] { color: #844a20; }
.topic-row-toggle { flex-wrap: wrap; }
.topic-row-toggle .topic-owner { max-width: none; }
.topics-archive { border-top: 1px solid #dbe7e7; }
button.topics-archive-toggle { display: flex; align-items: center; gap: 6px; min-height: 38px; width: 100%; padding: 5px 4px; font-size: 12px; font-weight: 650; border: 0; background: transparent; text-align: left; color: #425d69; }
.topics-archive-toggle svg { width: 13px; height: 13px; }
.topics-archive-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }

@media (max-width: 1050px) {
  button.topic-row-toggle { display: grid; grid-template-columns: minmax(0, 1fr) 14px; gap: 3px 6px; }
  .topic-row-name { grid-column: 1; }
  .topic-row-toggle > svg { grid-column: 2; grid-row: 1; }
  .topic-meta { grid-row: 2; grid-column: 1 / -1; }
}
.topic-meta .topic-owner { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
@media (max-width: 700px) {
  .topics-next, .topics-subtitle { white-space: normal; overflow-wrap: anywhere; }
  .keyboard-open .topics-subtitle { white-space: nowrap; }
}
