/* /topics — Topic Hubs.
   Standalone like /ads: it does not load app.css, because that file carries the
   shell's game view-switching rules. The palette below is restated from the
   same tokens public/app/app.css and public/styles/exp-theme.css use, so a
   visitor crossing from the home feed into a topic never feels the seam.
   Keep these in step with those two files. */

:root {
  --app-bg: #ffffff;
  --app-fg: #0f0f10;
  --app-dim: #606069;
  --app-line: rgba(0, 0, 0, .12);
  --app-hover: rgba(0, 0, 0, .06);
  --app-tile: #e8e8ec;
  --app-accent: #22d37a;
  --app-nav-h: 62px;

  /* From exp-theme.css — the turquoise/green EXP Tube identity. */
  --exp-turq: #16c8d2;
  --exp-green: #39df37;
  --exp-ink: #08242c;
  --exp-danger: #e0203a;
  --exp-warn: #b26b00;

  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

body.topics-page {
  margin: 0;
  min-width: 320px;
  background: var(--app-bg);
  color: var(--app-fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

a { color: inherit; }
img { max-width: 100%; }

.topic-muted { color: var(--app-dim); font-size: 14px; margin: 4px 0; }
.topic-error { color: var(--exp-danger); font-size: 14px; }
.topic-ok { color: #0a7a44; font-size: 14px; }

/* ---- Header --------------------------------------------------------------- */
.topics-nav {
  position: sticky;
  top: 0;
  z-index: 300;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
  min-height: var(--app-nav-h);
  padding: 0 16px;
  background: var(--app-bg);
  border-bottom: 1px solid var(--app-line);
}
.topics-nav__brand { display: inline-flex; align-items: center; height: 40px; }
.topics-nav__brand img { height: 34px; width: auto; display: block; }

.topics-search { display: flex; max-width: 620px; width: 100%; margin: 0 auto; }
.topics-search__input {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 14px;
  font: inherit;
  font-size: 15px;
  color: var(--app-fg);
  background: #fff;
  border: 1px solid #c8c8ce;
  border-right: 0;
  border-radius: 19px 0 0 19px;
  outline: none;
}
.topics-search__input:focus { border-color: var(--app-accent); }
.topics-search__go {
  padding: 0 18px;
  height: 38px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: #3a3a42;
  background: #f2f2f4;
  border: 1px solid #c8c8ce;
  border-radius: 0 19px 19px 0;
  cursor: pointer;
}
.topics-search__go:hover { background: #e6e6ea; }

.topics-nav__links { display: flex; align-items: center; gap: 8px; }
.topics-nav__link {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 13px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  color: var(--app-fg);
  background: transparent;
  border: 1px solid var(--app-line);
  border-radius: 999px;
  cursor: pointer;
}
.topics-nav__link:hover { background: var(--app-hover); }
.topics-nav__link--solid { background: #f2f2f4; }
.topics-nav__link--accent {
  background: var(--app-accent);
  border-color: var(--app-accent);
  color: #06210f;
}
.topics-nav__link--accent:hover { filter: brightness(1.08); }

.topics-bell {
  position: relative;
  width: 34px;
  height: 34px;
  font-size: 15px;
  background: transparent;
  border: 1px solid var(--app-line);
  border-radius: 999px;
  cursor: pointer;
}
.topics-bell:hover { background: var(--app-hover); }
.topics-bell__dot {
  position: absolute;
  top: 4px;
  right: 5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--exp-danger);
}
.topics-bell__dot[hidden] { display: none; }

/* ---- Layout --------------------------------------------------------------- */
.topics-main {
  max-width: 1240px;
  margin: 0 auto;
  padding: 20px 24px 96px;
}

.topics-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.topics-hero__title { font-size: 30px; font-weight: 800; margin: 0 0 4px; }
.topics-hero__sub { color: var(--app-dim); margin: 0; max-width: 62ch; }

.topic-shelf { margin: 28px 0 0; }
.topic-shelf__head { margin: 0 0 12px; }
.topic-shelf__title { font-size: 19px; font-weight: 700; margin: 0; }
.topic-shelf__sub { color: var(--app-dim); font-size: 14px; margin: 2px 0 0; }

.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.topic-grid--compact { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

/* ---- Chips ---------------------------------------------------------------- */
.topic-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 14px;
  scrollbar-width: none;
}
.topic-chips::-webkit-scrollbar { display: none; }
.topic-chip {
  flex: 0 0 auto;
  height: 32px;
  padding: 0 13px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--app-fg);
  background: #f0f0f3;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.topic-chip:hover { background: #e2e2e7; }
.topic-chip.is-active { background: var(--app-fg); color: #fff; }
.topic-chip--sm { height: 24px; padding: 0 10px; font-size: 12px; }
.topic-chip--muted { background: transparent; border: 1px solid var(--app-line); color: var(--app-dim); }

/* ---- Buttons -------------------------------------------------------------- */
.topic-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 15px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  color: var(--app-fg);
  background: #fff;
  border: 1px solid var(--app-line);
  border-radius: 999px;
  cursor: pointer;
}
.topic-btn:hover { background: var(--app-hover); }
.topic-btn:disabled { opacity: .55; cursor: default; }
.topic-btn--primary {
  background: var(--app-accent);
  border-color: var(--app-accent);
  color: #06210f;
}
.topic-btn--primary:hover { filter: brightness(1.08); background: var(--app-accent); }
.topic-btn--danger { color: #fff; background: var(--exp-danger); border-color: var(--exp-danger); }
.topic-btn--danger:hover { filter: brightness(1.08); background: var(--exp-danger); }
.topic-btn--sm { height: 30px; padding: 0 11px; font-size: 13px; }
.topic-btn--lg { height: 44px; padding: 0 24px; font-size: 15px; }
.topic-btn--icon { width: 36px; padding: 0; }

.topic-follow.is-following {
  background: var(--app-fg);
  border-color: var(--app-fg);
  color: #fff;
}
/* Follow is the primary action on a card, so it keeps a comfortable target even
   though it uses the --sm size for density on desktop. On touch it grows to the
   44px guideline, because a 30px target next to a full-card link is a mis-tap. */
.topic-card .topic-follow { height: 34px; padding: 0 16px; }
@media (hover: none) {
  .topic-card .topic-follow { height: 44px; padding: 0 20px; font-size: 14px; }
  .topic-action { padding: 10px 12px; }
  .topic-btn--sm { height: 38px; }
}

.topic-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--app-dim);
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}
.topic-action:hover { background: var(--app-hover); color: var(--app-fg); }
.topic-action--sm { font-size: 12.5px; padding: 3px 7px; }
.topic-action--danger:hover { color: var(--exp-danger); }
.topic-action--icon { padding: 6px 9px; }

/* ---- Icons and avatars ---------------------------------------------------- */
.topic-icon,
.topic-avatar {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: var(--icon-size, 48px);
  height: var(--icon-size, 48px);
  border-radius: 30%;
  overflow: hidden;
  background: hsl(var(--icon-hue, 180) 62% 92%);
  color: hsl(var(--icon-hue, 180) 55% 28%);
  font-weight: 800;
  font-size: calc(var(--icon-size, 48px) * .38);
  user-select: none;
}
.topic-avatar { border-radius: 50%; }
.topic-icon::before,
.topic-avatar::before { content: attr(data-fallback); }
.topic-icon__img,
.topic-avatar__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ---- Topic card ----------------------------------------------------------- */
.topic-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--app-line);
  border-radius: var(--radius);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.topic-card:hover {
  border-color: rgba(22, 200, 210, .5);
  box-shadow: 0 8px 22px rgba(20, 150, 160, .10);
}
/* A full-card link that sits under the interactive controls, so the whole card
   is clickable without nesting a button inside an anchor. */
.topic-card__hit { position: absolute; inset: 0; z-index: 0; border-radius: var(--radius); }
.topic-card > *:not(.topic-card__hit) { position: relative; z-index: 1; pointer-events: none; }
.topic-card button,
.topic-card a:not(.topic-card__hit) { pointer-events: auto; }

.topic-card__head { display: flex; gap: 11px; align-items: center; }
.topic-card__id { min-width: 0; }
.topic-card__name {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topic-card__cat { display: flex; flex-wrap: wrap; gap: 5px; }
.topic-card__desc {
  margin: 0;
  font-size: 14px;
  color: var(--app-dim);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.topic-card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
}
.topic-card__meta { font-size: 12.5px; color: var(--app-dim); }

.topic-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  background: rgba(22, 200, 210, .14);
  color: #0a6a72;
}
.topic-badge--verified { background: var(--app-accent); color: #06210f; }
.topic-badge--system { background: rgba(0, 0, 0, .07); color: var(--app-dim); }
.topic-badge--urgent { background: rgba(224, 32, 58, .12); color: var(--exp-danger); }

/* ---- Topic header --------------------------------------------------------- */
.topic-cover {
  height: 190px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--app-tile);
}
.topic-cover--generated {
  background:
    radial-gradient(circle at 18% 0%, rgba(57, 223, 55, .28), transparent 42%),
    radial-gradient(circle at 82% 12%, rgba(22, 200, 210, .32), transparent 45%),
    linear-gradient(180deg, #ffffff 0%, #eefcff 100%);
}
.topic-cover__img { width: 100%; height: 100%; object-fit: cover; display: block; }

.topic-head__body {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 18px;
  align-items: flex-start;
  margin: -34px 0 0;
  padding: 0 18px 16px;
}
.topic-head__body > .topic-icon {
  border: 4px solid #fff;
  border-radius: 26%;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .12);
}
.topic-head__id { min-width: 0; padding-top: 38px; }
.topic-head__name {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 6px;
  font-size: 27px;
  font-weight: 800;
}
.topic-head__chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.topic-head__desc { margin: 0 0 10px; color: var(--app-dim); max-width: 70ch; }
.topic-head__stats { display: flex; flex-wrap: wrap; gap: 14px; font-size: 14px; }
.topic-head__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 40px;
  justify-content: flex-end;
}

.topic-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  border-bottom: 1px solid var(--app-line);
  margin-bottom: 18px;
  scrollbar-width: none;
}
.topic-tabs::-webkit-scrollbar { display: none; }
.topic-tab {
  flex: 0 0 auto;
  padding: 12px 16px;
  font: inherit;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--app-dim);
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  cursor: pointer;
}
.topic-tab:hover { color: var(--app-fg); }
.topic-tab.is-active { color: var(--app-fg); border-bottom-color: var(--app-accent); }

.topic-notice {
  padding: 11px 14px;
  margin-bottom: 16px;
  font-size: 14px;
  border-radius: var(--radius-sm);
  background: rgba(22, 200, 210, .10);
  border: 1px solid rgba(22, 200, 210, .28);
}
.topic-notice--warn {
  background: rgba(224, 32, 58, .07);
  border-color: rgba(224, 32, 58, .26);
  color: #8a1023;
}

/* ---- Panels --------------------------------------------------------------- */
.topic-panel {
  padding: 16px 18px;
  margin-bottom: 16px;
  background: #fff;
  border: 1px solid var(--app-line);
  border-radius: var(--radius);
}
.topic-panel__title { font-size: 17px; font-weight: 700; margin: 0 0 10px; }
.topic-panel__text { margin: 0 0 10px; }

.topic-rules { margin: 0; padding-left: 20px; }
.topic-rules li { margin-bottom: 6px; }

.topic-details { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; margin: 0; font-size: 14px; }
.topic-details dt { color: var(--app-dim); }
.topic-details dd { margin: 0; }

.topic-people { display: flex; flex-direction: column; gap: 10px; }
.topic-people--grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.topic-person {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: #fafafb;
}
.topic-person--managed { flex-wrap: wrap; }
.topic-person.is-banned { background: rgba(224, 32, 58, .06); }
.topic-person__info { min-width: 0; flex: 1; }
.topic-person__name { font-weight: 600; font-size: 14px; }
.topic-person__role { font-size: 12.5px; color: var(--app-dim); }
.topic-person__flag { font-size: 12px; color: var(--exp-danger); font-weight: 600; }
.topic-person__actions { display: flex; flex-wrap: wrap; gap: 5px; width: 100%; }

/* ---- Composer ------------------------------------------------------------- */
.topic-composer {
  padding: 14px;
  margin-bottom: 16px;
  background: #fff;
  border: 1px solid var(--app-line);
  border-radius: var(--radius);
}
.topic-composer__head { display: flex; align-items: center; gap: 10px; }
.topic-composer__open {
  flex: 1;
  text-align: left;
  padding: 10px 14px;
  font: inherit;
  font-size: 14px;
  color: var(--app-dim);
  background: #f4f4f6;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}
.topic-composer__open:hover { background: #eaeaee; }
.topic-composer__form { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.topic-composer__types { display: flex; gap: 6px; flex-wrap: wrap; }
.topic-composer__field { display: flex; flex-direction: column; gap: 6px; }
.topic-composer__field[hidden] { display: none; }
.topic-composer__actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.topic-composer__preview img,
.topic-composer__img { max-height: 220px; border-radius: var(--radius-sm); margin-top: 8px; }
.topic-composer__poll { display: flex; flex-direction: column; gap: 6px; }
.topic-composer__status:empty { display: none; }

/* ---- Inputs --------------------------------------------------------------- */
.topic-input {
  width: 100%;
  padding: 9px 12px;
  font: inherit;
  font-size: 14.5px;
  color: var(--app-fg);
  background: #fff;
  border: 1px solid #c8c8ce;
  border-radius: var(--radius-sm);
  outline: none;
}
.topic-input:focus { border-color: var(--app-accent); box-shadow: 0 0 0 3px rgba(34, 211, 122, .16); }
.topic-input:disabled { background: #f5f5f7; color: var(--app-dim); }
.topic-input--area { resize: vertical; min-height: 68px; font-family: inherit; }
.topic-input--sm { padding: 6px 10px; font-size: 13.5px; }
.topic-label { display: block; font-size: 13.5px; font-weight: 700; margin-bottom: 2px; }
.topic-hint { font-size: 12.5px; color: var(--app-dim); margin: 2px 0 0; }
.topic-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.topic-form { display: flex; flex-direction: column; gap: 10px; }
.topic-file { font-size: 13px; }
.topic-file--hidden { display: none; }

.topic-toggle {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 0;
  cursor: pointer;
}
.topic-toggle--inline { padding: 12px 0 0; }
.topic-toggle__input { margin-top: 3px; width: 17px; height: 17px; accent-color: var(--app-accent); }
.topic-toggle__body { display: flex; flex-direction: column; }
.topic-toggle__label { font-size: 14.5px; font-weight: 600; }
.topic-toggle__hint { font-size: 12.5px; color: var(--app-dim); }

.topic-slugrow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.topic-slug {
  padding: 6px 10px;
  font-size: 13px;
  background: #f2f2f4;
  border-radius: var(--radius-sm);
  color: var(--app-dim);
}

/* ---- Create form ---------------------------------------------------------- */
.topic-create { max-width: 760px; margin: 0 auto; }
.topic-create__head { margin-bottom: 18px; }
.topic-create__section {
  padding: 18px;
  margin-bottom: 16px;
  background: #fff;
  border: 1px solid var(--app-line);
  border-radius: var(--radius);
}
.topic-create__submit { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.topic-upload { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.topic-upload__preview img { max-height: 120px; border-radius: var(--radius-sm); margin-top: 8px; }
.topic-upload__preview--wide img { max-height: 100px; width: 100%; object-fit: cover; }

.topic-duplicates {
  padding: 14px;
  margin: 8px 0 14px;
  background: #fffdf3;
  border: 1px solid #e8dda8;
  border-radius: var(--radius-sm);
}
.topic-duplicates__title { font-size: 15px; margin: 0 0 4px; }
.topic-duplicates__list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.topic-duplicates__row { display: flex; align-items: center; gap: 10px; }
.topic-duplicates__info { flex: 1; min-width: 0; }
.topic-duplicates__name { font-weight: 600; font-size: 14px; }

.topic-errors {
  padding: 12px 16px;
  margin-bottom: 16px;
  background: rgba(224, 32, 58, .07);
  border: 1px solid rgba(224, 32, 58, .26);
  border-radius: var(--radius-sm);
}
.topic-errors__title { margin: 0 0 6px; font-weight: 700; }
.topic-errors ul { margin: 0; padding-left: 20px; }

/* ---- Posts ---------------------------------------------------------------- */
.topic-feed { display: flex; flex-direction: column; gap: 14px; }
.topic-post {
  padding: 14px 16px;
  background: #fff;
  border: 1px solid var(--app-line);
  border-radius: var(--radius);
}
.topic-post.is-pinned { border-color: rgba(22, 200, 210, .45); background: #fbffff; }
.topic-post__pin { font-size: 12px; font-weight: 700; color: #0a6a72; margin-bottom: 6px; }
.topic-post__head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.topic-post__who { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; min-width: 0; }
.topic-post__author { font-weight: 600; font-size: 14px; }
.topic-post__title { font-size: 17px; font-weight: 700; margin: 0 0 8px; }
.topic-post__text { margin: 0 0 10px; white-space: pre-wrap; word-break: break-word; }
.topic-post__image { border-radius: var(--radius-sm); max-height: 520px; object-fit: cover; width: 100%; }
.topic-post__video {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--app-tile);
}
.topic-post__video img { width: 100%; height: 100%; object-fit: cover; }
.topic-post__play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 40px;
  color: #fff;
  text-shadow: 0 2px 14px rgba(0, 0, 0, .6);
}
.topic-post__link { margin: 8px 0; word-break: break-all; }
.topic-post__tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.topic-post__actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px solid var(--app-line);
  margin-top: 10px;
}

.topic-link { color: #1768aa; text-decoration: underline; word-break: break-all; }
.topic-link--blocked { color: var(--app-dim); text-decoration: line-through; }
.topic-mention, .topic-hashtag {
  font: inherit;
  font-weight: 600;
  color: #1768aa;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.topic-mention:hover, .topic-hashtag:hover { text-decoration: underline; }

.topic-reactions { display: flex; align-items: center; gap: 2px; }
.topic-reaction {
  padding: 5px 7px;
  font-size: 15px;
  line-height: 1;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
}
.topic-reaction:hover { background: var(--app-hover); }
.topic-reaction.is-mine { background: rgba(34, 211, 122, .18); border-color: var(--app-accent); }
.topic-reactions__count { font-size: 13px; color: var(--app-dim); margin-left: 4px; }
.topic-reaction-picker { display: flex; gap: 6px; justify-content: center; }

.topic-poll { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.topic-poll__option {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  font: inherit;
  font-size: 14px;
  text-align: left;
  background: #f4f4f6;
  border: 1px solid var(--app-line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  overflow: hidden;
}
.topic-poll__option::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--pct, 0%);
  background: rgba(34, 211, 122, .22);
  transition: width .3s ease;
}
.topic-poll__option.is-mine { border-color: var(--app-accent); font-weight: 600; }
.topic-poll__label, .topic-poll__pct { position: relative; }

/* ---- Comments ------------------------------------------------------------- */
.topic-comments { margin-top: 12px; border-top: 1px solid var(--app-line); padding-top: 12px; }
.topic-comments__composer { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 12px; }
.topic-comments__composer .topic-input { flex: 1; }
.topic-comments__list { display: flex; flex-direction: column; gap: 10px; }
.topic-comment {
  display: flex;
  gap: 9px;
  margin-left: calc(var(--depth, 0) * 22px);
}
.topic-comment__body { flex: 1; min-width: 0; }
.topic-comment__meta { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-size: 12.5px; }
.topic-comment__author { font-weight: 600; font-size: 13.5px; }
.topic-comment__text { margin: 2px 0 4px; font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.topic-comment__actions { display: flex; gap: 2px; }

/* ---- Chat ----------------------------------------------------------------- */
.topic-chat {
  display: flex;
  flex-direction: column;
  height: min(70vh, 640px);
  background: #fff;
  border: 1px solid var(--app-line);
  border-radius: var(--radius);
  overflow: hidden;
}
.topic-chat__pinned {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: 13px;
  background: rgba(22, 200, 210, .10);
  border-bottom: 1px solid var(--app-line);
}
.topic-chat__pinned[hidden] { display: none; }
.topic-chat__pinned-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topic-chat__history { padding: 8px; text-align: center; border-bottom: 1px solid var(--app-line); }
.topic-chat__stream {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.topic-chat__hint { text-align: center; margin: auto; }

.topic-msg { display: flex; gap: 9px; align-items: flex-start; }
.topic-msg__body { flex: 1; min-width: 0; }
.topic-msg__meta { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-size: 12px; }
.topic-msg__author { font-weight: 600; font-size: 13.5px; }
.topic-msg__text { margin: 2px 0; font-size: 14.5px; white-space: pre-wrap; word-break: break-word; }
.topic-msg__quote {
  display: flex;
  flex-direction: column;
  padding: 4px 9px;
  margin: 3px 0;
  font-size: 12.5px;
  border-left: 3px solid rgba(22, 200, 210, .5);
  background: #f6fdfe;
  border-radius: 0 6px 6px 0;
}
.topic-msg__quote-author { font-weight: 600; }
.topic-msg__quote-text { color: var(--app-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topic-msg__attach img { max-height: 220px; border-radius: var(--radius-sm); margin-top: 4px; }
.topic-msg__reactions { display: flex; gap: 5px; margin-top: 3px; }
.topic-msg__reaction {
  font-size: 12px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--app-hover);
}
.topic-msg__tools { display: flex; gap: 1px; opacity: 0; transition: opacity .12s ease; }
.topic-msg:hover .topic-msg__tools,
.topic-msg:focus-within .topic-msg__tools { opacity: 1; }
.topic-msg__tool {
  padding: 3px 6px;
  font-size: 13px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  color: var(--app-dim);
}
.topic-msg__tool:hover { background: var(--app-hover); color: var(--app-fg); }
.topic-msg.is-pinned { background: rgba(22, 200, 210, .06); border-radius: var(--radius-sm); padding: 6px; }

.topic-chat__replybar,
.topic-chat__attach {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-top: 1px solid var(--app-line);
  font-size: 13px;
}
.topic-chat__replybar[hidden], .topic-chat__attach[hidden] { display: none; }
.topic-chat__attach img { max-height: 60px; border-radius: 6px; }

.topic-chat__composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--app-line);
  background: #fafafb;
}
.topic-chat__attachbtn {
  flex: 0 0 auto;
  padding: 8px;
  font-size: 17px;
  cursor: pointer;
  border-radius: 8px;
}
.topic-chat__attachbtn:hover { background: var(--app-hover); }
.topic-chat__input {
  flex: 1;
  min-height: 38px;
  max-height: 140px;
  padding: 9px 12px;
  font: inherit;
  font-size: 14.5px;
  resize: none;
  border: 1px solid #c8c8ce;
  border-radius: 19px;
  outline: none;
}
.topic-chat__input:focus { border-color: var(--app-accent); }

/* ---- Manage / queues ------------------------------------------------------ */
.topic-manage { max-width: 900px; margin: 0 auto; }
.topic-manage__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.topic-queue { display: flex; flex-direction: column; gap: 10px; }
.topic-queue__row {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  padding: 11px;
  background: #fafafb;
  border-radius: var(--radius-sm);
}
.topic-queue__row.is-high { background: rgba(224, 32, 58, .06); }
.topic-queue__main { flex: 1; min-width: 200px; }
.topic-queue__reason { display: flex; align-items: center; gap: 7px; font-weight: 600; font-size: 14px; text-transform: capitalize; }
.topic-queue__details { margin: 4px 0; font-size: 13.5px; word-break: break-word; }
.topic-queue__actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---- States --------------------------------------------------------------- */
.topic-empty {
  grid-column: 1 / -1;
  padding: 40px 20px;
  text-align: center;
  border: 1px dashed var(--app-line);
  border-radius: var(--radius);
}
.topic-empty__title { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.topic-empty__body { color: var(--app-dim); margin: 0 auto 14px; max-width: 46ch; }
.topic-empty--error { border-color: rgba(224, 32, 58, .3); }

.topic-skeleton {
  border-radius: var(--radius);
  background: linear-gradient(90deg, #eeeef1 25%, #f7f7f9 50%, #eeeef1 75%);
  background-size: 200% 100%;
  animation: topicShimmer 1.3s linear infinite;
}
.topic-skeleton--card { height: 148px; }
.topic-skeleton--post { height: 190px; }
.topic-skeleton--row { height: 58px; }
.topic-skeleton--head { height: 300px; }
@keyframes topicShimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) {
  .topic-skeleton { animation: none; }
}

.topic-sentinel { height: 1px; }

.topic-toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 20px);
  z-index: 900;
  max-width: min(440px, calc(100vw - 32px));
  padding: 11px 18px;
  border-radius: 999px;
  background: rgba(12, 14, 18, .95);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.topic-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.topic-toast[data-kind="error"] { background: rgba(160, 18, 36, .96); }

/* ---- Modal ---------------------------------------------------------------- */
.topic-modal {
  width: min(560px, calc(100vw - 28px));
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .3);
}
.topic-modal::backdrop { background: rgba(8, 12, 18, .5); }
.topic-modal__inner { padding: 18px; }
.topic-modal__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.topic-modal__title { font-size: 18px; font-weight: 700; margin: 0; }
.topic-modal__close {
  width: 30px;
  height: 30px;
  font-size: 15px;
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}
.topic-modal__close:hover { background: var(--app-hover); }
.topic-modal__body { max-height: min(64vh, 560px); overflow-y: auto; }
.topic-modal__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.topic-menu { display: flex; flex-direction: column; gap: 2px; }
.topic-menu__item {
  width: 100%;
  justify-content: flex-start;
  padding: 11px 13px;
  font: inherit;
  font-size: 14.5px;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.topic-menu__item:hover { background: var(--app-hover); }
.topic-menu__item--danger { color: var(--exp-danger); }

.topics-notifications { display: flex; flex-direction: column; gap: 4px; }
.topics-notification {
  display: block;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
}
.topics-notification:hover { background: var(--app-hover); }
.topics-notification.is-unread { background: rgba(34, 211, 122, .10); }
.topics-notification__title { font-weight: 600; font-size: 14px; }
.topics-notification__body { font-size: 13px; color: var(--app-dim); }
.topics-notification__time { font-size: 12px; color: var(--app-dim); margin-top: 2px; }

/* ---- Responsive ----------------------------------------------------------- */
@media (max-width: 900px) {
  .topics-nav {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px 12px;
    padding: 10px 12px;
  }
  .topics-nav__links {
    grid-column: 1 / -1;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .topics-nav__links::-webkit-scrollbar { display: none; }
  .topics-main { padding: 16px 14px 80px; }

  .topic-head__body {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    padding: 0 12px 14px;
  }
  .topic-head__id { padding-top: 40px; }
  .topic-head__actions {
    grid-column: 1 / -1;
    padding-top: 0;
    justify-content: flex-start;
  }
  .topic-head__name { font-size: 22px; }
  .topic-cover { height: 140px; border-radius: 0; }
}

@media (max-width: 640px) {
  .topics-hero__title { font-size: 24px; }
  .topic-grid { grid-template-columns: 1fr; }
  .topic-people--grid { grid-template-columns: 1fr; }
  .topic-chat { height: min(76vh, 560px); border-radius: 0; border-left: 0; border-right: 0; }
  .topic-head__body > .topic-icon { --icon-size: 62px !important; }
  .topic-comment { margin-left: calc(var(--depth, 0) * 14px); }
  /* Chat tools are hover-revealed on desktop; on touch there is no hover, so
     they are always visible. */
  .topic-msg__tools { opacity: 1; }
  .topic-modal { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: var(--radius) var(--radius) 0 0; }
}

@media (hover: none) {
  .topic-msg__tools { opacity: 1; }
}
