/* =========================================================
   Topichub — modern design system
   A complete redesign (light theme, violet accent)
   ========================================================= */

:root {
  --tp-bg: #f5f6fb;
  --tp-surface: #ffffff;
  --tp-surface-2: #f0f1f8;
  --tp-border: #e6e7f0;
  --tp-text: #14152b;
  --tp-muted: #6b6d84;
  --tp-faint: #9a9cb2;

  --tp-primary: #6c5ce7;
  --tp-primary-600: #5a49d6;
  --tp-primary-050: #eeebfd;
  --tp-accent: #00c2a8;
  --tp-danger: #ef4767;
  --tp-warning: #f7b733;

  --tp-shadow-sm: 0 1px 2px rgba(20, 21, 43, 0.06);
  --tp-shadow: 0 10px 30px rgba(20, 21, 43, 0.08);
  --tp-shadow-lg: 0 24px 60px rgba(20, 21, 43, 0.14);

  --tp-radius: 16px;
  --tp-radius-sm: 10px;
  --tp-radius-pill: 999px;

  --tp-header-h: 72px;
  --tp-container: 1240px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--tp-bg);
  color: var(--tp-text);
  font-family: "Plus Jakarta Sans", "Inter", -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
}

img {
  max-width: 100%;
  display: block;
}

.tp-container {
  width: 100%;
  max-width: var(--tp-container);
  margin: 0 auto;
  padding: 0 24px;
}

.tp-muted { color: var(--tp-muted); }

/* ---------- Buttons ---------- */
.tp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--tp-radius-pill);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.2s ease, box-shadow 0.2s ease,
    border-color 0.2s ease;
  white-space: nowrap;
}
.tp-btn:active { transform: translateY(1px); }

.tp-btn--primary {
  background: linear-gradient(135deg, var(--tp-primary), #8b7cf0);
  color: #fff;
  box-shadow: 0 8px 20px rgba(108, 92, 231, 0.35);
}
.tp-btn--primary:hover { box-shadow: 0 10px 26px rgba(108, 92, 231, 0.45); }

.tp-btn--ghost {
  background: var(--tp-surface);
  color: var(--tp-text);
  border-color: var(--tp-border);
}
.tp-btn--ghost:hover { background: var(--tp-surface-2); }

.tp-btn--danger {
  background: var(--tp-danger);
  color: #fff;
}
.tp-btn--danger:hover { filter: brightness(1.05); }

.tp-btn--sm { padding: 7px 14px; font-size: 13px; }
.tp-btn--block { width: 100%; }

.tp-link {
  color: var(--tp-primary);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.tp-link:hover { color: var(--tp-primary-600); }

/* ---------- Header / Navbar ---------- */
.tp-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--tp-header-h);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--tp-border);
}
.tp-header__inner {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 20px;
}
.tp-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.02em;
}
.tp-brand__mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--tp-primary), var(--tp-accent));
  color: #fff;
  box-shadow: 0 8px 18px rgba(108, 92, 231, 0.4);
}
.tp-brand__name span { color: var(--tp-primary); }

.tp-search {
  flex: 1;
  max-width: 460px;
  position: relative;
}
.tp-search svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  fill: var(--tp-faint);
}
.tp-search input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--tp-border);
  background: var(--tp-surface-2);
  border-radius: var(--tp-radius-pill);
  padding: 0 16px 0 42px;
  font-size: 14px;
  font-family: inherit;
  color: var(--tp-text);
  transition: border-color 0.2s, background 0.2s;
}
.tp-search input:focus {
  outline: none;
  border-color: var(--tp-primary);
  background: #fff;
  box-shadow: 0 0 0 4px var(--tp-primary-050);
}

.tp-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}
.tp-nav__link {
  padding: 9px 14px;
  border-radius: var(--tp-radius-pill);
  color: var(--tp-muted);
  font-weight: 600;
  font-size: 14px;
}
.tp-nav__link:hover { background: var(--tp-surface-2); color: var(--tp-text); }

.tp-user {
  position: relative;
  margin-left: 4px;
}
.tp-user__toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 6px 5px 5px;
  border-radius: var(--tp-radius-pill);
  border: 1px solid var(--tp-border);
  background: var(--tp-surface);
  cursor: pointer;
  font-family: inherit;
}
.tp-user__toggle:hover { background: var(--tp-surface-2); }
.tp-user__name { font-weight: 600; font-size: 14px; }
.tp-user__toggle svg { width: 14px; height: 14px; fill: var(--tp-faint); }

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  min-width: 200px;
  background: var(--tp-surface);
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-radius);
  box-shadow: var(--tp-shadow-lg);
  padding: 8px;
  display: none;
  flex-direction: column;
  gap: 2px;
}
.dropdown-menu.show { display: flex; }
.dropdown-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--tp-radius-sm);
  font-weight: 600;
  font-size: 14px;
  color: var(--tp-muted);
}
.dropdown-link:hover { background: var(--tp-surface-2); color: var(--tp-text); }
.dropdown-link svg { width: 18px; height: 18px; fill: currentColor; }

/* ---------- Avatars ---------- */
.tp-avatar {
  border-radius: 50%;
  object-fit: cover;
  background: var(--tp-surface-2);
  border: 2px solid #fff;
  box-shadow: var(--tp-shadow-sm);
}
.tp-avatar--xs { width: 28px; height: 28px; }
.tp-avatar--sm { width: 36px; height: 36px; }
.tp-avatar--md { width: 44px; height: 44px; }
.tp-avatar--lg { width: 96px; height: 96px; }

/* ---------- Cards ---------- */
.tp-card {
  background: var(--tp-surface);
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-radius);
  box-shadow: var(--tp-shadow-sm);
}
.tp-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--tp-border);
}
.tp-card__head h2, .tp-card__head h3 { font-size: 16px; }
.tp-card__body { padding: 18px 20px; }

/* ---------- Messages / toast ---------- */
.tp-messages {
  position: fixed;
  top: calc(var(--tp-header-h) + 14px);
  right: 24px;
  z-index: 80;
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tp-messages li {
  background: var(--tp-text);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--tp-radius-sm);
  box-shadow: var(--tp-shadow-lg);
  font-weight: 600;
  font-size: 14px;
  animation: tp-slide-in 0.3s ease;
}
@keyframes tp-slide-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ---------- Page wrapper ---------- */
.tp-page { padding: 28px 0 64px; }

/* ---------- Hero ---------- */
.tp-hero {
  position: relative;
  overflow: hidden;
  border-radius: 22px;
  padding: 36px 40px;
  margin-bottom: 24px;
  background: radial-gradient(1200px 400px at 10% -20%, #8b7cf0 0%, transparent 60%),
    linear-gradient(135deg, #6c5ce7 0%, #4834b5 100%);
  color: #fff;
  box-shadow: var(--tp-shadow);
}
.tp-hero__eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 12px;
  font-weight: 700;
  opacity: 0.85;
}
.tp-hero h1 {
  font-size: clamp(26px, 4vw, 40px);
  margin: 8px 0 10px;
  max-width: 620px;
}
.tp-hero p { max-width: 560px; opacity: 0.9; margin: 0 0 20px; }
.tp-hero__stats {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
}
.tp-hero__stat b { display: block; font-size: 24px; line-height: 1; }
.tp-hero__stat span { font-size: 13px; opacity: 0.85; }
.tp-hero__glow {
  position: absolute;
  right: -80px;
  bottom: -120px;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 194, 168, 0.5), transparent 65%);
  pointer-events: none;
}

/* ---------- Layout grids ---------- */
.tp-grid {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 320px;
  gap: 22px;
  align-items: start;
}
.tp-grid--2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 22px;
  align-items: start;
}
.tp-sticky { position: sticky; top: calc(var(--tp-header-h) + 20px); }

/* ---------- Section headers ---------- */
.tp-section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.tp-section-head h2 { font-size: 20px; }
.tp-section-head p { margin: 2px 0 0; color: var(--tp-muted); font-size: 14px; }

/* ---------- Topics ---------- */
.tp-topics { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.tp-topics a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--tp-radius-sm);
  color: var(--tp-muted);
  font-weight: 600;
  font-size: 14px;
}
.tp-topics a:hover { background: var(--tp-surface-2); color: var(--tp-text); }
.tp-topics a.active { background: var(--tp-primary-050); color: var(--tp-primary); }
.tp-topics a span {
  background: var(--tp-surface-2);
  color: var(--tp-muted);
  border-radius: var(--tp-radius-pill);
  padding: 1px 9px;
  font-size: 12px;
}
.tp-topics a.active span { background: #fff; color: var(--tp-primary); }

/* ---------- Room feed ---------- */
.tp-rooms { display: flex; flex-direction: column; gap: 16px; }
.tp-room {
  background: var(--tp-surface);
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-radius);
  padding: 20px;
  box-shadow: var(--tp-shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.tp-room:hover {
  transform: translateY(-3px);
  box-shadow: var(--tp-shadow);
  border-color: #d9d8f5;
}
.tp-room__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.tp-room__author {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 14px;
}
.tp-room__author span { color: var(--tp-text); }
.tp-room__time { color: var(--tp-faint); font-size: 13px; }
.tp-room__title {
  font-size: 19px;
  font-weight: 700;
  color: var(--tp-text);
  display: inline-block;
  margin-bottom: 12px;
}
.tp-room__title:hover { color: var(--tp-primary); }
.tp-room__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--tp-border);
}
.tp-room__joined {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--tp-muted);
  font-size: 13px;
  font-weight: 600;
}
.tp-room__joined svg { width: 16px; height: 16px; fill: var(--tp-faint); }
.tp-tag {
  background: var(--tp-primary-050);
  color: var(--tp-primary);
  border-radius: var(--tp-radius-pill);
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 700;
}

/* ---------- Activity ---------- */
.tp-activity { display: flex; flex-direction: column; gap: 4px; }
.tp-activity__item {
  display: flex;
  gap: 12px;
  padding: 12px;
  border-radius: var(--tp-radius-sm);
  transition: background 0.15s;
}
.tp-activity__item:hover { background: var(--tp-surface-2); }
.tp-activity__body { flex: 1; min-width: 0; }
.tp-activity__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.tp-activity__name { font-weight: 700; font-size: 14px; }
.tp-activity__time { color: var(--tp-faint); font-size: 12px; }
.tp-activity__text { color: var(--tp-muted); font-size: 13px; margin: 2px 0 0; }
.tp-activity__text a { color: var(--tp-primary); font-weight: 600; }
.tp-activity__snippet {
  margin-top: 8px;
  background: var(--tp-surface-2);
  border-radius: var(--tp-radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  color: var(--tp-text);
}
.tp-icon-btn {
  border: none;
  background: transparent;
  color: var(--tp-faint);
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
}
.tp-icon-btn svg { width: 16px; height: 16px; fill: currentColor; }
.tp-icon-btn:hover { background: rgba(239, 71, 103, 0.1); color: var(--tp-danger); }

/* ---------- Empty state ---------- */
.tp-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--tp-muted);
}
.tp-empty svg { width: 46px; height: 46px; fill: var(--tp-faint); margin-bottom: 10px; }

/* ---------- Forms ---------- */
.tp-form { display: flex; flex-direction: column; gap: 18px; }
.tp-field { display: flex; flex-direction: column; gap: 7px; }
.tp-field > label {
  font-size: 13px;
  font-weight: 700;
  color: var(--tp-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tp-form input,
.tp-form textarea,
.tp-form select {
  width: 100%;
  border: 1px solid var(--tp-border);
  background: var(--tp-surface-2);
  border-radius: var(--tp-radius-sm);
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  color: var(--tp-text);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.tp-form textarea { min-height: 120px; resize: vertical; }
.tp-form input:focus,
.tp-form textarea:focus,
.tp-form select:focus {
  outline: none;
  border-color: var(--tp-primary);
  background: #fff;
  box-shadow: 0 0 0 4px var(--tp-primary-050);
}
.tp-form__actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding-top: 4px;
}

/* ---------- Auth ---------- */
.tp-auth {
  min-height: calc(100vh - var(--tp-header-h));
  display: grid;
  place-items: center;
  padding: 40px 24px;
}
.tp-auth__card {
  width: 100%;
  max-width: 440px;
  background: var(--tp-surface);
  border: 1px solid var(--tp-border);
  border-radius: 22px;
  box-shadow: var(--tp-shadow);
  padding: 36px;
}
.tp-auth__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  margin-bottom: 22px;
  font-weight: 800;
  font-size: 20px;
}
.tp-auth h2 { font-size: 24px; text-align: center; }
.tp-auth__sub { text-align: center; color: var(--tp-muted); margin: 6px 0 26px; }
.tp-auth__foot {
  text-align: center;
  margin-top: 22px;
  color: var(--tp-muted);
  font-size: 14px;
}

/* ---------- Page card (forms/topics/activity pages) ---------- */
.tp-panel {
  max-width: 720px;
  margin: 0 auto;
}
.tp-panel__head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.tp-back {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--tp-surface);
  border: 1px solid var(--tp-border);
  box-shadow: var(--tp-shadow-sm);
}
.tp-back:hover { background: var(--tp-surface-2); }
.tp-back svg { width: 18px; height: 18px; fill: var(--tp-text); }
.tp-panel__head h1 { font-size: 22px; }

/* ---------- Profile ---------- */
.tp-profile {
  text-align: center;
  padding: 28px 22px;
}
.tp-profile .tp-avatar { margin: 0 auto 14px; }
.tp-profile h2 { font-size: 22px; }
.tp-profile__handle { color: var(--tp-primary); font-weight: 600; margin: 2px 0 16px; }
.tp-profile__bio {
  text-align: left;
  color: var(--tp-muted);
  font-size: 14px;
  border-top: 1px solid var(--tp-border);
  padding-top: 16px;
  margin-top: 16px;
}
.tp-profile__bio h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--tp-faint); margin-bottom: 6px; }

/* ---------- Room (chat) page ---------- */
.tp-chat {
  background: var(--tp-surface);
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-radius);
  box-shadow: var(--tp-shadow-sm);
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--tp-header-h) - 56px);
  overflow: hidden;
}
.tp-chat__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--tp-border);
}
.tp-chat__headLeft { display: flex; align-items: center; gap: 12px; }
.tp-chat__headLeft h1 { font-size: 18px; }
.tp-chat__topic { color: var(--tp-muted); font-size: 13px; }
.tp-chat__actions { display: flex; gap: 6px; }
.tp-chat__hosted {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--tp-border);
  background: var(--tp-surface-2);
  font-size: 13px;
}
.tp-chat__hosted .tp-room__author span { color: var(--tp-text); }

.threads {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.thread {
  background: var(--tp-surface-2);
  border-radius: 14px;
  padding: 12px 14px;
  max-width: 82%;
}
.thread__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.thread__author { display: flex; align-items: center; gap: 8px; }
.thread__author span { font-weight: 600; font-size: 13px; }
.thread__date { color: var(--tp-faint); font-size: 12px; }
.thread__details { color: var(--tp-text); font-size: 14px; word-break: break-word; }
.thread__delete { color: var(--tp-faint); cursor: pointer; }
.thread__delete svg { width: 14px; height: 14px; fill: currentColor; }
.thread__delete:hover { color: var(--tp-danger); }

.tp-chat__compose {
  padding: 14px 16px;
  border-top: 1px solid var(--tp-border);
}
.tp-chat__compose input {
  width: 100%;
  border: 1px solid var(--tp-border);
  background: var(--tp-surface-2);
  border-radius: var(--tp-radius-pill);
  padding: 13px 18px;
  font-size: 14px;
  font-family: inherit;
  color: var(--tp-text);
}
.tp-chat__compose input:focus {
  outline: none;
  border-color: var(--tp-primary);
  background: #fff;
  box-shadow: 0 0 0 4px var(--tp-primary-050);
}

/* Participants */
.tp-participants__list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: calc(100vh - var(--tp-header-h) - 130px);
  overflow-y: auto;
}
.tp-participant {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--tp-radius-sm);
}
.tp-participant:hover { background: var(--tp-surface-2); }
.tp-participant p { margin: 0; font-weight: 600; font-size: 14px; }
.tp-participant span { display: block; color: var(--tp-faint); font-weight: 500; font-size: 12px; }

/* ---------- Chips row ---------- */
.tp-chip-row { display: flex; flex-wrap: wrap; gap: 10px; }
.tp-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--tp-surface);
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-radius-pill);
  padding: 8px 16px;
  font-weight: 600;
  font-size: 14px;
  color: var(--tp-muted);
}
.tp-chip:hover { border-color: var(--tp-primary); color: var(--tp-primary); }
.tp-chip.active { background: var(--tp-primary); color: #fff; border-color: var(--tp-primary); }
.tp-chip span {
  background: var(--tp-surface-2);
  color: var(--tp-muted);
  border-radius: var(--tp-radius-pill);
  padding: 0 8px;
  font-size: 12px;
}
.tp-chip.active span { background: rgba(255,255,255,0.25); color: #fff; }

/* ---------- Utilities ---------- */
.tp-scroll::-webkit-scrollbar { width: 8px; }
.tp-scroll::-webkit-scrollbar-thumb { background: #d7d8e6; border-radius: 8px; }
.threads::-webkit-scrollbar { width: 8px; }
.threads::-webkit-scrollbar-thumb { background: #d7d8e6; border-radius: 8px; }

.tp-hide-mobile { display: block; }
.tp-show-mobile { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .tp-grid { grid-template-columns: minmax(0, 1fr) 300px; }
  .tp-grid .tp-col-topics { display: none; }
}
@media (max-width: 860px) {
  .tp-grid,
  .tp-grid--2 { grid-template-columns: minmax(0, 1fr); }
  .tp-grid .tp-col-topics { display: block; }
  .tp-sticky { position: static; }
  .tp-search { display: none; }
  .tp-nav__link { display: none; }
  .tp-chat { height: auto; min-height: 70vh; }
}
@media (max-width: 560px) {
  .tp-container { padding: 0 16px; }
  .tp-hero { padding: 26px 22px; }
  .tp-user__name { display: none; }
}
