/* =============================================================================
   CommunityHub — main.css
   Navigation, layout chrome, shared components
   ============================================================================= */

/* =============================================================================
   Top Navigation
   ============================================================================= */
.ch-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-lg);
  background: rgba(15, 23, 42, 0.62);
  backdrop-filter: blur(4px);
}

.ch-modal-overlay.is-open {
  display: flex;
}

.ch-modal {
  width: min(100%, 680px);
  max-height: min(86vh, 760px);
  overflow: auto;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.ch-modal-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-md);
  padding: var(--spacing-lg);
  background: var(--color-card);
  border-bottom: 1px solid var(--color-border);
}

.ch-modal-title {
  margin: 0;
  font-size: var(--font-size-lg);
  line-height: 1.25;
}

.ch-modal-close {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-card);
  color: var(--color-text-secondary);
  cursor: pointer;
}

.ch-modal-close:hover {
  color: var(--color-text-primary);
  background: var(--color-bg);
}

.ch-modal-close.ch-btn {
  width: auto;
  height: 36px;
  padding: 0 var(--spacing-lg);
  font-size: var(--font-size-sm);
  line-height: 1;
}

.ch-modal-body {
  padding: var(--spacing-lg);
}

@media (max-width: 600px) {
  .ch-modal-overlay { padding: var(--spacing-sm); }
  .ch-modal { max-height: 92vh; border-radius: var(--radius-md); }
  .ch-modal-header,
  .ch-modal-body { padding: var(--spacing-md); }
}

.ch-nav {
  background: #fff;
  height: var(--nav-height);
  border-bottom: 1px solid var(--color-border);
  position: relative;
  z-index: var(--z-sticky);
}

.ch-nav-sticky {
  position: sticky;
  top: 0;
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition-fast);
}

body.admin-bar .ch-nav-sticky {
  top: 32px;
}

@media screen and (max-width: 782px) {
  body.admin-bar .ch-nav-sticky {
    top: 46px;
  }
}

.ch-nav-sticky.is-scrolled {
  box-shadow: var(--shadow-md);
}

.ch-nav-inner {
  display: flex;
  align-items: center;
  height: var(--nav-height);
  gap: var(--spacing-lg);
}

/* Logo */
.ch-nav-logo { flex-shrink: 0; }

.ch-logo-text {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--color-primary);
}

.ch-logo-mark {
  width: 34px;
  height: 34px;
  display: inline-flex;
  flex: 0 0 34px;
  align-items: center;
  justify-content: center;
  background: transparent;
  border-radius: 50%;
}

.ch-logo-mark::after {
  content: none;
}

.ch-logo-mark-img {
  display: block;
  width: 100%;
  height: 100%;
}

.ch-logo-text:hover { color: var(--color-primary-dark); }

.ch-logo-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ch-nav-logo .custom-logo { height: 36px; width: auto; display: block; }

/* Nav links */
.ch-nav-links {
  flex: 1;
  display: flex;
  align-items: center;
}

.ch-nav-menu {
  display: flex;
  align-items: center;
  gap: 2px;
  height: var(--nav-height);
}

.ch-nav-menu li { height: 100%; list-style: none; }

.ch-nav-menu li a {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 var(--spacing-md);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.ch-nav-menu li a:hover,
.ch-nav-menu li.current-menu-item > a,
.ch-nav-menu li.current-page-ancestor > a {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}

/* Sub-menus */
.ch-nav-menu .sub-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  min-width: 160px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: all var(--transition-fast);
  z-index: var(--z-dropdown);
  padding: 6px 0;
}

.ch-nav-menu li:hover > .sub-menu,
.ch-nav-menu li:focus-within > .sub-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.ch-nav-menu .sub-menu li { height: auto; }

.ch-nav-menu .sub-menu li a {
  height: 36px;
  padding: 0 var(--spacing-lg);
  border-bottom: none;
  font-weight: 400;
  color: var(--color-text-primary);
}

/* ---- Cards mega-dropdown (consolidated card-system entry) ---- */
.ch-nav-cards { position: relative; }

.ch-nav-cards-trigger {
  display: flex !important;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.ch-nav-cards-icon,
.ch-nav-cards-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.ch-nav-cards-icon { width: 16px; height: 16px; }
.ch-nav-cards-arrow { width: 14px; height: 14px; opacity: .8; transition: transform 0.15s ease; }
.ch-nav-cards.is-open .ch-nav-cards-arrow { transform: rotate(180deg); }

.ch-nav-cards-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 0;
  min-width: 220px;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 6px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s linear 0.15s;
  z-index: var(--z-dropdown);
}

/* Bridge so hover doesn't drop while crossing the gap */
.ch-nav-cards-menu::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: -8px;
  height: 8px;
}

.ch-nav-cards:hover > .ch-nav-cards-menu,
.ch-nav-cards:focus-within > .ch-nav-cards-menu,
.ch-nav-cards.is-open > .ch-nav-cards-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
  transition-delay: 0s;
}

.ch-nav-cards-item {
  display: flex !important;
  align-items: center;
  gap: 10px;
  padding: 10px 12px !important;
  height: auto !important;
  border-radius: var(--radius-sm);
  border-bottom: none !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  color: var(--color-text-primary) !important;
  text-decoration: none;
  transition: background 0.15s ease;
}

.ch-nav-cards-item:hover {
  background: var(--color-border-light) !important;
  color: var(--color-primary) !important;
  border-bottom: none !important;
}

.ch-nav-cards-item-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1;
  flex-shrink: 0;
}

.ch-nav-menu .sub-menu li a:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-bottom: none;
}

/* Nav right */
.ch-nav-right {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  flex-shrink: 0;
}

/* Language switcher */
.ch-language-switcher {
  position: relative;
  flex-shrink: 0;
}

.ch-language-btn {
  min-width: 64px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--color-card);
  color: var(--color-text-secondary);
  cursor: pointer;
  font: inherit;
  font-size: var(--font-size-sm);
  font-weight: 700;
  line-height: 1;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.ch-language-btn:hover,
.ch-language-switcher.is-open .ch-language-btn,
.ch-language-switcher:focus-within .ch-language-btn {
  background: var(--color-bg);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.ch-language-icon,
.ch-language-arrow {
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.ch-language-arrow {
  width: 14px;
  height: 14px;
  color: var(--color-text-muted);
  transition: transform var(--transition-fast);
}

.ch-language-switcher.is-open .ch-language-arrow {
  transform: rotate(180deg);
}

.ch-language-current {
  min-width: 22px;
  text-align: center;
  letter-spacing: 0;
}

.ch-language-menu {
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 190px;
  margin-top: 6px;
  padding: 6px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-card);
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity var(--transition-fast), transform var(--transition-fast), visibility 0s linear var(--transition-fast);
  z-index: var(--z-dropdown);
}

.ch-language-menu::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: -6px;
  height: 6px;
}

.ch-language-switcher.is-open .ch-language-menu,
.ch-language-switcher:focus-within .ch-language-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
  transition-delay: 0s;
}

.ch-language-option,
.ch-language-option.fanyi2-lang-option {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
  font-weight: 600;
  text-decoration: none;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.ch-language-option:hover,
.ch-language-option:focus,
.ch-language-option.is-active {
  background: var(--color-primary-light);
  color: var(--color-primary);
  outline: none;
}

.ch-language-code {
  min-width: 34px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--color-bg);
  color: var(--color-text-secondary);
  font-size: 11px;
  font-weight: 800;
}

.ch-language-option.is-active .ch-language-code {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: #fff;
}

.ch-language-switcher-mobile {
  width: 100%;
  margin-bottom: 8px;
}

.ch-language-switcher-mobile .ch-language-btn {
  width: 100%;
  justify-content: center;
}

.ch-language-switcher-mobile .ch-language-menu {
  position: static;
  width: 100%;
  margin-top: 8px;
  opacity: 1;
  pointer-events: auto;
  transform: none;
  box-shadow: none;
  display: none;
}

.ch-language-switcher-mobile.is-open .ch-language-menu,
.ch-language-switcher-mobile:focus-within .ch-language-menu {
  display: block;
}

/* Search */
.ch-search-wrap { position: relative; }

.ch-search-form {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  padding: 0 var(--spacing-md);
  height: 32px;
  width: 200px;
  transition: all var(--transition-fast);
}

.ch-search-form:focus-within {
  width: 260px;
  border-color: var(--color-primary);
  box-shadow: var(--shadow-focus);
  background: var(--color-card);
}

.ch-search-icon {
  display: inline-flex;
  width: 14px;
  height: 14px;
  color: var(--color-text-muted);
}

.ch-search-input {
  background: none;
  border: none;
  outline: none;
  font-size: var(--font-size-sm);
  color: var(--color-text-primary);
  width: 100%;
}

.ch-search-input::placeholder { color: var(--color-text-muted); }

/* Backpack badge */
.ch-nav-backpack {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  line-height: 1;
  color: var(--color-text-secondary);
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.ch-nav-backpack:hover,
.ch-nav-backpack:focus-visible {
  color: var(--color-text-secondary);
  background: var(--color-bg);
}

.ch-card-count-badge,
.ch-notif-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--color-danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  line-height: 1;
  pointer-events: none;
}

/* User dropdown */
.ch-user-dropdown {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}
.ch-user-dropdown:hover,
.ch-user-dropdown:focus { background: var(--color-bg); outline: none; }

.ch-username {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-primary);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 1080px) {
  .ch-username { max-width: 120px; }
}

.ch-dropdown-arrow {
  font-size: 10px;
  color: var(--color-text-muted);
  transition: transform var(--transition-fast);
}

.ch-user-dropdown:hover .ch-dropdown-arrow,
.ch-user-dropdown:focus .ch-dropdown-arrow { transform: rotate(180deg); }

.ch-user-menu {
  position: absolute;
  top: 100%;          /* no gap → bridge below covers visual whitespace */
  right: 0;
  margin-top: 4px;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  min-width: 220px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity var(--transition-fast), transform var(--transition-fast), visibility 0s linear var(--transition-fast);
  z-index: var(--z-dropdown);
  padding: 6px 0;
}

/* Invisible bridge so hover doesn't drop when crossing the gap. */
.ch-user-menu::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: -4px;
  height: 4px;
  background: transparent;
}

.ch-user-dropdown.is-open .ch-user-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
  transition-delay: 0s;
}

.ch-user-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  font-size: var(--font-size-sm);
  color: var(--color-text-primary);
  transition: background var(--transition-fast);
  text-decoration: none;
}
.ch-user-menu a:hover { background: var(--color-primary-light); color: var(--color-primary); }
.ch-user-menu a.ch-menu-danger { color: #b42318; }
.ch-user-menu a.ch-menu-danger:hover { background: #fef3f2; color: #7a271a; }

.ch-user-menu .ch-menu-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1;
  flex-shrink: 0;
}

.ch-menu-divider {
  height: 1px;
  background: var(--color-border);
  margin: 6px 0;
}

/* ---- Cards group: My Backpack with hover-out submenu ---- */
.ch-menu-group {
  position: relative;
}

.ch-menu-group-head {
  display: flex !important;
  align-items: center;
  gap: 10px;
}

.ch-menu-group-label { flex: 1; }

.ch-menu-group-arrow {
  font-size: 16px;
  line-height: 1;
  color: var(--color-text-muted);
  margin-left: auto;
}

.ch-menu-group-children {
  position: absolute;
  top: 0;
  right: 100%;
  min-width: 200px;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 6px 0;
  margin-right: 6px;
  opacity: 0;
  pointer-events: none;
  transform: translateX(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: var(--z-dropdown);
}

/* Bridge so the cursor can travel from group head → submenu without crossing
   a hover-dead zone. */
.ch-menu-group-children::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  right: -8px;
  width: 8px;
  background: transparent;
}

.ch-menu-group:hover .ch-menu-group-children,
.ch-menu-group:focus-within .ch-menu-group-children {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

@media (max-width: 720px) {
  /* On narrow screens, expand the submenu inline instead of side-flipping. */
  .ch-menu-group-children {
    position: static;
    box-shadow: none;
    border: 0;
    background: var(--color-bg);
    margin: 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: none;
    padding-left: 12px;
  }
  .ch-user-dropdown.is-open .ch-menu-group-children,
  .ch-user-dropdown:focus-within .ch-menu-group-children {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
  .ch-menu-group-arrow { display: none; }
}

/* Login button */
.ch-login-btn { height: 32px; font-size: var(--font-size-sm); }

/* Hamburger */
.ch-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}
.ch-hamburger:hover { background: var(--color-bg); }

.ch-hamburger-line {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--color-text-primary);
  border-radius: 1px;
  transition: all var(--transition-base);
}

.ch-hamburger.is-open .ch-hamburger-line:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.ch-hamburger.is-open .ch-hamburger-line:nth-child(2) { opacity: 0; }
.ch-hamburger.is-open .ch-hamburger-line:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Mobile nav */
.ch-mobile-nav {
  position: fixed;
  top: 0;
  right: 0;
  width: 280px;
  height: 100vh;
  background: var(--color-card);
  z-index: var(--z-modal);
  box-shadow: var(--shadow-lg);
  transform: translateX(calc(100% + 40px));
  transition: transform var(--transition-base);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.ch-mobile-nav.is-open { transform: translateX(0); }

.ch-mobile-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-lg) var(--spacing-xl);
  border-bottom: 1px solid var(--color-border);
}

.ch-mobile-nav-title { font-weight: 700; font-size: var(--font-size-lg); color: var(--color-primary); }

.ch-mobile-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--color-text-muted);
  line-height: 1;
  padding: 4px;
}

.ch-mobile-menu {
  flex: 1;
  padding: var(--spacing-md) 0;
}

.ch-mobile-menu li a {
  display: block;
  padding: 12px var(--spacing-xl);
  font-size: var(--font-size-md);
  color: var(--color-text-primary);
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all var(--transition-fast);
}
.ch-mobile-menu li a:hover,
.ch-mobile-menu li.current-menu-item > a {
  color: var(--color-primary);
  border-left-color: var(--color-primary);
  background: var(--color-primary-light);
}

.ch-mobile-menu .sub-menu { display: none; }
.ch-mobile-menu .sub-menu.is-open { display: block; background: var(--color-bg); }
.ch-mobile-menu .sub-menu li a { padding-left: calc(var(--spacing-xl) + 16px); font-size: var(--font-size-sm); }

.ch-mobile-nav-footer {
  padding: var(--spacing-lg) var(--spacing-xl);
  border-top: 1px solid var(--color-border);
}

.ch-mobile-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: calc(var(--z-modal) - 1);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}
.ch-mobile-overlay.is-visible { opacity: 1; pointer-events: auto; }

.ch-mobile-bottom-nav {
  display: none;
}

.ch-mobile-card-menu {
  display: none;
}

.ch-mobile-bottom-cards {
  min-width: 0;
}

.ch-mobile-bottom-nav-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 2px;
  width: min(100%, 480px);
  margin: 0 auto;
}

.ch-mobile-bottom-nav-item {
  min-width: 0;
  min-height: 54px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 5px 4px;
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}

.ch-mobile-bottom-cards-summary {
  min-height: 54px;
  display: block;
  list-style: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

.ch-mobile-bottom-cards-summary::-webkit-details-marker {
  display: none;
}

.ch-mobile-bottom-cards-summary .ch-mobile-bottom-nav-item {
  height: 100%;
}

.ch-mobile-bottom-nav-item .ch-icon {
  width: 21px;
  height: 21px;
}

.ch-mobile-bottom-nav-item:hover,
.ch-mobile-bottom-nav-item:focus-visible {
  color: var(--color-primary);
  background: var(--reddit-hover, var(--color-primary-light));
}

.ch-mobile-bottom-nav-item.is-active {
  color: var(--color-primary);
  background: var(--color-primary-light);
}

.ch-mobile-bottom-cards[open] .ch-mobile-bottom-nav-item {
  color: var(--color-primary);
  background: var(--reddit-hover, var(--color-primary-light));
}

#instantappy-installer {
  z-index: calc(var(--z-float) - 10) !important;
}

body.ch-mobile-nav-open #instantappy-installer,
body.ch-modal-open #instantappy-installer,
body.ch-user-hovercard-open #instantappy-installer {
  display: none !important;
}

body:has(.ch-mobile-bottom-cards[open]) #instantappy-installer {
  display: none !important;
}

body.ch-mobile-cards-open #instantappy-installer {
  display: none !important;
}

@media (max-width: 600px) {
  body {
    padding-bottom: calc(70px + env(safe-area-inset-bottom));
  }

  .ch-mobile-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: calc(var(--z-sticky) + 30);
    display: block;
    padding: 6px max(8px, env(safe-area-inset-left)) max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-right));
    background: var(--color-card);
    background: color-mix(in srgb, var(--color-card) 96%, transparent);
    border-top: 1px solid var(--color-border);
    box-shadow: 0 -10px 24px rgba(15, 23, 42, 0.14);
    backdrop-filter: blur(16px);
  }

  .ch-mobile-card-menu {
    position: absolute;
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
    bottom: calc(100% + 8px);
    padding: 10px;
    background: var(--color-card);
    background: color-mix(in srgb, var(--color-card) 97%, transparent);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: 0 -14px 34px rgba(15, 23, 42, 0.18);
    backdrop-filter: blur(18px);
  }

  .ch-mobile-bottom-cards[open] .ch-mobile-card-menu {
    display: block;
  }

  .ch-mobile-card-menu-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-sm);
    padding: 0 2px 8px;
    color: var(--color-text-primary);
    font-size: var(--font-size-sm);
    font-weight: 800;
  }

  .ch-mobile-card-menu-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .ch-mobile-card-menu-link {
    min-width: 0;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--color-bg) 58%, var(--color-card));
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    font-weight: 800;
    line-height: 1.15;
    text-decoration: none;
    transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
  }

  .ch-mobile-card-menu-link span {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .ch-mobile-card-menu-icon {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
  }

  .ch-mobile-card-menu-link:hover,
  .ch-mobile-card-menu-link:focus-visible,
  .ch-mobile-card-menu-link.is-active {
    color: var(--color-primary);
    border-color: color-mix(in srgb, var(--color-primary) 38%, var(--color-border));
    background: var(--color-primary-light);
  }

  .ch-chat-window {
    bottom: calc(78px + env(safe-area-inset-bottom));
  }

  #instantappy-installer {
    right: 12px !important;
    bottom: calc(84px + env(safe-area-inset-bottom)) !important;
    transform: scale(0.92);
    transform-origin: bottom right;
  }

  .ch-footer {
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
  }
}

/* =============================================================================
   Default nav fallback function output
   ============================================================================= */
.ch-nav-menu-fallback {
  display: flex;
  align-items: center;
  gap: 2px;
  height: var(--nav-height);
}
.ch-nav-menu-fallback a {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 var(--spacing-md);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
}
.ch-nav-menu-fallback a:hover { color: var(--color-primary); }

/* =============================================================================
   Breadcrumbs
   ============================================================================= */
.ch-breadcrumbs {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: var(--spacing-md) 0;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}
.ch-breadcrumbs a { color: var(--color-text-muted); }
.ch-breadcrumbs a:hover { color: var(--color-primary); }
.ch-bc-sep { color: var(--color-border); }
.ch-bc-current { color: var(--color-text-primary); font-weight: 500; }

/* =============================================================================
   Jackpot ticker
   ============================================================================= */
.ch-jackpot-ticker {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  height: 36px;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: var(--spacing-lg);
}

.ch-ticker-label {
  flex-shrink: 0;
  padding: 0 var(--spacing-md);
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: var(--color-warning);
  background: #FFFBEB;
  height: 100%;
  display: flex;
  align-items: center;
  border-right: 1px solid var(--color-border);
}

.ch-ticker-track {
  flex: 1;
  overflow: hidden;
  height: 100%;
  display: flex;
  align-items: center;
}

.ch-ticker-inner {
  display: flex;
  gap: var(--spacing-xl);
  /* Speed is set via the --ch-ticker-duration CSS variable from the theme;
     default is a leisurely 120s scroll. */
  white-space: nowrap;
  animation: ch-ticker-scroll var(--ch-ticker-duration, 120s) linear infinite;
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

/* Pause on hover so users can actually read the message they care about */
.ch-jackpot-ticker:hover .ch-ticker-inner,
.ch-ticker-track:hover .ch-ticker-inner {
  animation-play-state: paused;
}

@keyframes ch-ticker-scroll {
  0%   { transform: translateX(100%); }
  100% { transform: translateX(-100%); }
}

/* =============================================================================
   Post card shared
   ============================================================================= */
.ch-post-card,
.ch-blog-post-card {
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}
.ch-post-card:hover,
.ch-blog-post-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* =============================================================================
   Author link
   ============================================================================= */
.ch-author-link {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-xs);
  max-width: 100%;
  color: var(--color-text-secondary);
}
.ch-author-link:hover .ch-author-name { color: var(--color-primary); }

.ch-author-name {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
}

.ch-author-sidebar-card-link {
  display: block;
  color: inherit;
  text-decoration: none;
  border-radius: inherit;
}

.ch-author-sidebar-card-link:hover .ch-fw-700 {
  color: var(--color-primary);
}

.ch-author-sidebar-card-link:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
}

/* =============================================================================
   User hovercard
   ============================================================================= */
.ch-user-hover-trigger {
  cursor: pointer;
  text-decoration: none;
}

.ch-user-hover-trigger:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

.ch-user-hovercard-layer {
  position: fixed;
  z-index: calc(var(--z-modal) + 20);
  width: min(324px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity var(--transition-fast), transform var(--transition-fast), visibility var(--transition-fast);
}

.ch-user-hovercard-layer.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

.ch-user-hovercard-layer:not(.is-mobile-sheet)::before {
  content: "";
  position: absolute;
  top: -6px;
  left: var(--ch-hovercard-arrow-left, 50%);
  width: 12px;
  height: 12px;
  background: var(--color-card);
  border-top: 1px solid var(--color-border);
  border-left: 1px solid var(--color-border);
  transform: translateX(-50%) rotate(45deg);
}

.ch-user-hovercard-layer.is-above:not(.is-mobile-sheet)::before {
  top: auto;
  bottom: -6px;
  border: 0;
  border-right: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

.ch-user-hovercard-layer.is-side:not(.is-mobile-sheet)::before {
  display: none;
}

.ch-user-hovercard {
  position: relative;
  overflow: hidden;
  padding: var(--spacing-lg);
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  color: var(--color-text-primary);
}

.ch-user-hovercard-close {
  position: absolute;
  top: var(--spacing-sm);
  right: var(--spacing-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
}

.ch-user-hovercard-close:hover,
.ch-user-hovercard-close:focus-visible {
  background: var(--color-bg);
  color: var(--color-text-primary);
  border-color: var(--color-border);
}

.ch-user-hovercard-head {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding-right: 28px;
}

.ch-user-hovercard-avatar {
  display: inline-flex;
  flex: 0 0 auto;
}

.ch-user-hovercard-avatar .ch-avatar {
  box-shadow: 0 0 0 3px var(--color-card), 0 0 0 4px var(--color-border);
}

.ch-user-hovercard-title {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.ch-user-hovercard-name {
  min-width: 0;
  overflow: hidden;
  color: var(--color-text-primary);
  font-size: var(--font-size-lg);
  font-weight: 800;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-decoration: none;
}

.ch-user-hovercard-name:hover {
  color: var(--color-primary);
}

.ch-user-hovercard-handle,
.ch-user-hovercard-joined,
.ch-user-hovercard-bio {
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
}

.ch-user-hovercard-joined {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-xs);
  margin-top: 2px;
}

.ch-user-hovercard-bio {
  margin-top: var(--spacing-md);
  line-height: 1.5;
}

.ch-user-hovercard-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--spacing-sm);
  margin-top: var(--spacing-md);
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--color-border);
}

.ch-user-hovercard-stats div {
  min-width: 0;
}

.ch-user-hovercard-stats strong {
  display: block;
  color: var(--color-text-primary);
  font-size: var(--font-size-md);
  font-weight: 800;
  line-height: 1.2;
}

.ch-user-hovercard-stats span {
  display: block;
  margin-top: 2px;
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  line-height: 1.25;
}

.ch-user-hovercard-achievements {
  margin-top: var(--spacing-md);
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--color-border);
}

.ch-user-hovercard-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-sm);
  color: var(--color-text-secondary);
  font-size: var(--font-size-xs);
  font-weight: 700;
}

.ch-user-hovercard-section-title a,
.ch-user-hovercard-profile-link {
  color: var(--color-primary);
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.ch-user-hovercard-section-title a:hover,
.ch-user-hovercard-profile-link:hover {
  color: var(--color-primary-hover);
}

.ch-user-hovercard-achievement-list {
  display: grid;
  gap: var(--spacing-xs);
  margin-top: var(--spacing-sm);
}

.ch-user-hovercard-achievement {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  min-width: 0;
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
  font-weight: 600;
}

.ch-user-hovercard-achievement-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-primary-light);
}

.ch-user-hovercard-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-md);
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--color-border);
}

.ch-user-hovercard-actions .ch-btn {
  flex: 1 1 118px;
  justify-content: center;
  min-width: 0;
}

.ch-user-hovercard-profile-link {
  margin-left: auto;
}

.ch-user-hovercard-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  min-height: 120px;
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
}

.ch-user-hovercard-loading .ch-icon {
  animation: ch-user-hovercard-spin 0.8s linear infinite;
}

@keyframes ch-user-hovercard-spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 719px) {
  body.ch-user-hovercard-open {
    overflow: hidden;
  }

  body.ch-user-hovercard-open::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: calc(var(--z-modal) + 10);
    background: rgba(15, 23, 42, 0.54);
    backdrop-filter: blur(2px);
  }

  .ch-user-hovercard-layer.is-mobile-sheet {
    left: 0 !important;
    right: 0;
    top: auto !important;
    bottom: 0;
    width: 100%;
    max-height: calc(100vh - 48px);
    padding: 0 var(--spacing-sm) var(--spacing-sm);
    transform: translateY(16px);
  }

  .ch-user-hovercard-layer.is-mobile-sheet.is-open {
    transform: translateY(0);
  }

  .ch-user-hovercard-layer.is-mobile-sheet .ch-user-hovercard {
    max-height: calc(100vh - 56px);
    overflow: auto;
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-md) var(--radius-md);
  }

  .ch-user-hovercard-head {
    align-items: flex-start;
  }

  .ch-user-hovercard-name {
    white-space: normal;
  }

  .ch-user-hovercard-actions .ch-btn {
    flex-basis: calc(50% - var(--spacing-sm));
  }

  .ch-user-hovercard-profile-link {
    flex: 1 0 100%;
    margin-left: 0;
    text-align: center;
  }
}

/* =============================================================================
   Post meta
   ============================================================================= */
.ch-post-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--spacing-xs);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.ch-meta-sep { color: var(--color-border); }
.ch-post-date, .ch-read-time { color: var(--color-text-muted); }

/* =============================================================================
   Category badge
   ============================================================================= */
.ch-cat-badge { margin-right: var(--spacing-xs); }

/* =============================================================================
   Sidebar titles
   ============================================================================= */
.ch-sidebar-title {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: var(--spacing-sm);
}

/* =============================================================================
   Widget styling
   ============================================================================= */
.ch-widget { margin-bottom: var(--spacing-lg); }

.ch-widget-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: var(--spacing-md);
  padding-bottom: var(--spacing-sm);
  border-bottom: 2px solid var(--color-primary);
}

.ch-widget-list { list-style: none; padding: 0; margin: 0; }
.ch-widget-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  font-size: var(--font-size-sm);
  border-bottom: 1px solid var(--color-border, rgba(0,0,0,0.06));
}
.ch-widget-list li:last-child { border-bottom: 0; }
.ch-widget-list li a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--color-text-primary);
  text-decoration: none;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ch-widget-list li a:hover { color: var(--color-primary); }

/* =============================================================================
   Footer
   ============================================================================= */
.ch-footer {
  margin-top: auto;
  padding: var(--spacing-3xl) 0 0;
  background: var(--reddit-nav, var(--color-card)) !important;
  color: var(--color-text-secondary) !important;
  border-top: 1px solid var(--color-border);
}

.ch-footer-widgets.ch-footer-grid-1 { display: grid; grid-template-columns: 1fr; gap: var(--spacing-2xl); }
.ch-footer-widgets.ch-footer-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--spacing-2xl); }
.ch-footer-widgets.ch-footer-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--spacing-2xl); }
.ch-footer-widgets.ch-footer-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--spacing-2xl); }

.ch-footer-col { color: inherit; }

.ch-footer-col .ch-widget-title {
  color: var(--color-text-primary);
  border-color: var(--color-primary);
}

.ch-footer-col a { color: inherit; opacity: 0.75; }
.ch-footer-col a:hover { opacity: 1; color: inherit; }
.ch-footer-col li { margin-bottom: 6px; font-size: var(--font-size-sm); }

.ch-footer-divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--spacing-xl) 0;
}

.ch-footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--spacing-md);
  padding: var(--spacing-lg) 0;
  font-size: var(--font-size-sm);
}

.ch-footer-copyright { opacity: 0.7; }

.ch-footer-social {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.ch-footer-social-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--reddit-vote-bg, var(--color-bg));
  color: inherit;
  font-size: 14px;
  transition: all var(--transition-fast);
  border: none;
  cursor: pointer;
}

.ch-footer-social-link:hover {
  background: var(--color-primary);
  color: #fff;
  transform: translateY(-2px);
}

.ch-footer-nav .ch-footer-nav-list {
  display: flex;
  align-items: center;
  gap: var(--spacing-lg);
  flex-wrap: wrap;
}

.ch-footer-nav .ch-footer-nav-list a {
  font-size: var(--font-size-sm);
  opacity: 0.7;
  color: inherit;
}
.ch-footer-nav .ch-footer-nav-list a:hover { opacity: 1; }

@media (max-width: 600px) {
  .ch-footer {
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
  }
}

/* =============================================================================
   Single post / page
   ============================================================================= */
.ch-single-post {
  padding: var(--spacing-xl) 0;
}

.ch-single-header {
  position: relative;
  margin-bottom: var(--spacing-xl);
}

.ch-single-title-row,
.ch-forum-single-title-row {
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-lg);
}

.ch-single-title-row .ch-single-title,
.ch-forum-single-title-row .ch-forum-single-title {
  flex: 1 1 auto;
  min-width: 0;
  margin-bottom: 0;
}

.ch-single-title-row .ch-report-btn,
.ch-forum-single-title-row .ch-report-btn {
  margin-top: 5px;
}

.ch-report-btn {
  position: static;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex: 0 0 auto;
  min-width: 0;
  height: 24px;
  padding: 0 8px;
  border: 1px solid color-mix(in srgb, var(--color-danger) 26%, var(--color-border));
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--color-danger) 6%, var(--color-card));
  color: color-mix(in srgb, var(--color-danger) 80%, var(--color-text-secondary));
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: none;
  transition: border-color var(--transition-fast), color var(--transition-fast), background var(--transition-fast), transform var(--transition-fast);
}

.ch-report-btn:hover,
.ch-report-btn:focus-visible {
  border-color: var(--color-danger);
  background: #fff;
  color: var(--color-danger);
  transform: translateY(-1px);
  outline: none;
}

.ch-report-btn .ch-icon {
  width: 13px;
  height: 13px;
}

@media (max-width: 520px) {
  .ch-report-btn {
    width: 26px;
    height: 26px;
    padding: 0;
  }

  .ch-report-btn__label {
    display: none;
  }
}

.ch-single-title {
  font-size: var(--font-size-4xl);
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: var(--spacing-lg);
}

.ch-single-featured-image {
  width: 100%;
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: var(--spacing-xl);
}

.ch-single-featured-image img {
  width: 100%;
  height: auto;
  display: block;
}

.ch-single-content {
  font-size: var(--font-size-md);
  line-height: 1.8;
  color: var(--color-text-secondary);
}

.ch-single-content h1,
.ch-single-content h2,
.ch-single-content h3,
.ch-single-content h4 {
  margin: 1.5em 0 0.75em;
  color: var(--color-text-primary);
}

.ch-single-content p   { margin-bottom: 1.2em; }
.ch-single-content img { border-radius: var(--radius-md); }
.ch-single-content a   { color: var(--color-primary); text-decoration: underline; }
.ch-single-content blockquote {
  border-left: 3px solid var(--color-primary);
  padding-left: var(--spacing-lg);
  margin: 1.5em 0;
  color: var(--color-text-muted);
  font-style: italic;
}

.ch-single-content code {
  background: var(--color-bg);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 0.9em;
}

.ch-single-content pre {
  background: #1E1E2E;
  color: #cdd6f4;
  padding: var(--spacing-lg);
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin-bottom: 1.2em;
}

/* =============================================================================
   404 page
   ============================================================================= */
.ch-404-page {
  min-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--spacing-3xl) var(--spacing-xl);
}

/* =============================================================================
   Search results
   ============================================================================= */
.ch-search-results-header {
  padding: var(--spacing-xl) 0;
}

.ch-search-results-title {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  margin-bottom: var(--spacing-sm);
}

/* =============================================================================
   Rankings page
   ============================================================================= */
.ch-rankings-page {
  padding: var(--spacing-xl) 0;
}

.ch-rankings-tabs {
  display: flex;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-xl);
  flex-wrap: wrap;
}

.ch-leaderboard {
  background: var(--color-card);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.ch-leaderboard-header {
  display: grid;
  grid-template-columns: 60px 1fr 120px 120px;
  padding: var(--spacing-md) var(--spacing-lg);
  background: var(--color-bg);
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--color-border);
}

.ch-leaderboard-row {
  display: grid;
  grid-template-columns: 60px 1fr 120px 120px;
  padding: var(--spacing-md) var(--spacing-lg);
  align-items: center;
  border-bottom: 1px solid var(--color-border-light);
  transition: background var(--transition-fast);
}
.ch-leaderboard-row:hover { background: var(--color-bg); }
.ch-leaderboard-row:last-child { border-bottom: none; }

.ch-rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-weight: 700;
  font-size: var(--font-size-sm);
}

.ch-rank-1 { background: #FFD700; color: #7B5800; }
.ch-rank-2 { background: #C0C0C0; color: #4A4A4A; }
.ch-rank-3 { background: #CD7F32; color: #5C3200; }
.ch-rank-other { background: var(--color-bg); color: var(--color-text-muted); }

.ch-leaderboard-user {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

/* =============================================================================
   Calendar
   ============================================================================= */
.ch-calendar { font-size: var(--font-size-xs); }

.ch-calendar-head {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 4px;
}

.ch-cal-dow {
  text-align: center;
  font-weight: 700;
  color: var(--color-text-muted);
  padding: 2px 0;
}

.ch-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.ch-cal-day {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  cursor: default;
  transition: background var(--transition-fast);
}

.ch-cal-empty { visibility: hidden; }

.ch-cal-day.is-today {
  background: var(--color-primary);
  color: #fff;
  font-weight: 700;
}

.ch-cal-day.is-checked {
  background: var(--color-success);
  color: #fff;
}

.ch-checkin-streak {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-warning);
  margin-bottom: var(--spacing-sm);
  text-align: center;
}

/* =============================================================================
   Comment form
   ============================================================================= */
.ch-comment-area {
  margin-top: var(--spacing-2xl);
  padding-top: var(--spacing-xl);
  border-top: 1px solid var(--color-border);
}

.ch-comment-area .comment-reply-title { font-size: var(--font-size-xl); font-weight: 700; margin-bottom: var(--spacing-lg); }
.ch-comment-area .comment-form-comment label { display: block; font-size: var(--font-size-sm); font-weight: 600; margin-bottom: 6px; }
.ch-comment-area textarea,
.ch-comment-area input[type="text"],
.ch-comment-area input[type="email"],
.ch-comment-area input[type="url"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  background: var(--color-card);
  color: var(--color-text-primary);
  transition: border-color var(--transition-fast);
  outline: none;
}
.ch-comment-area textarea:focus,
.ch-comment-area input:focus { border-color: var(--color-primary); }
.ch-comment-area textarea { min-height: 120px; resize: vertical; }
.ch-comment-area .submit {
  background: var(--color-primary);
  color: #fff;
  border: none;
  padding: 10px 24px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast);
}
.ch-comment-area .submit:hover { background: var(--color-primary-hover); }

/* =============================================================================
   Homepage — Hero
   ============================================================================= */
.ch-hero-section {
  position: relative;
  background: linear-gradient(135deg, #0a1a3a 0%, #1e3a8a 50%, #3b82f6 100%);
  color: #fff;
  padding: clamp(72px, 7vw, 120px) 0 clamp(80px, 8vw, 140px);
  min-height: clamp(520px, 60vh, 640px);
  display: flex;
  align-items: center;
  overflow: hidden;
  isolation: isolate;
}

.ch-hero-section > .ch-container { width: 100%; }

.ch-hero-bg-accents { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.ch-hero-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.35;
}
.ch-hero-blob-1 {
  width: 380px; height: 380px;
  background: radial-gradient(circle, #7c3aed, transparent 70%);
  top: -120px; left: -80px;
}
.ch-hero-blob-2 {
  width: 420px; height: 420px;
  background: radial-gradient(circle, #06b6d4, transparent 70%);
  bottom: -160px; right: -60px;
}

.ch-hero-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: var(--spacing-2xl);
  align-items: center;
}

.ch-hero-content { display: flex; flex-direction: column; gap: var(--spacing-md); }

.ch-hero-eyebrow {
  align-self: flex-start;
  font-size: var(--font-size-xs);
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 6px 14px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 999px;
  backdrop-filter: blur(6px);
}

.ch-hero-title {
  font-size: clamp(2.2rem, 4.5vw, 3.4rem);
  font-weight: 800;
  line-height: 1.15;
  margin: 0;
  letter-spacing: -0.02em;
}

.ch-hero-subtitle {
  font-size: var(--font-size-md);
  opacity: 0.85;
  margin: 0;
  max-width: 520px;
  line-height: 1.6;
}

.ch-hero-actions {
  display: flex;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
  margin-top: var(--spacing-sm);
}
.ch-hero-actions .ch-btn-primary {
  background: #fff;
  color: #1e3a8a;
  border-color: #fff;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}
.ch-hero-actions .ch-btn-primary:hover {
  background: #f1f5ff;
  color: #1e3a8a;
  transform: translateY(-1px);
}
.ch-hero-actions .ch-btn-outline {
  border-color: rgba(255,255,255,0.6);
  color: #fff;
  background: rgba(255,255,255,0.05);
}
.ch-hero-actions .ch-btn-outline:hover {
  background: rgba(255,255,255,0.18);
  border-color: #fff;
}

/* Inline metrics row */
.ch-hero-metrics {
  display: flex;
  gap: clamp(18px, 3vw, 40px);
  list-style: none;
  margin: var(--spacing-md) 0 0;
  padding: var(--spacing-md) 0 0;
  border-top: 1px solid rgba(255,255,255,0.18);
  flex-wrap: wrap;
}
.ch-hero-metrics li { display: flex; flex-direction: column; gap: 2px; }
.ch-hero-metrics strong {
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ch-hero-metrics span {
  font-size: 11px;
  opacity: 0.7;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.ch-dot-live {
  display: inline-block;
  width: 8px; height: 8px;
  background: #34d399;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(52,211,153,0.25);
  animation: ch-dot-pulse 1.8s ease-in-out infinite;
}
@keyframes ch-dot-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.6; transform: scale(1.15); }
}

/* Hero decorative visual (right) */
.ch-hero-visual {
  position: relative;
  min-height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ch-hero-cards {
  position: relative;
  width: 320px;
  height: 300px;
}
.ch-hero-card {
  position: absolute;
  width: 160px;
  height: 220px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 60px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.25);
  border: 1px solid rgba(255,255,255,0.25);
  animation: ch-hero-card-float 5s ease-in-out infinite;
}
.ch-hero-card-1 {
  left: 0; top: 30px;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  transform: rotate(-10deg);
  animation-delay: 0s;
}
.ch-hero-card-2 {
  left: 80px; top: 0;
  background: linear-gradient(135deg, #8b5cf6, #3b82f6);
  transform: rotate(2deg);
  animation-delay: 0.6s;
  z-index: 2;
}
.ch-hero-card-3 {
  left: 160px; top: 40px;
  background: linear-gradient(135deg, #10b981, #06b6d4);
  transform: rotate(12deg);
  animation-delay: 1.2s;
}
@keyframes ch-hero-card-float {
  0%, 100% { transform: translateY(0) rotate(var(--r, 0deg)); }
  50%      { transform: translateY(-12px) rotate(var(--r, 0deg)); }
}
.ch-hero-card-1 { --r: -10deg; }
.ch-hero-card-2 { --r: 2deg; }
.ch-hero-card-3 { --r: 12deg; }
.ch-hero-sparkle {
  position: absolute;
  color: rgba(255,255,255,0.7);
  font-size: 22px;
  animation: ch-sparkle-twinkle 2s ease-in-out infinite;
}
.ch-hero-sparkle-1 { top: 12%; right: 18%; animation-delay: 0s; }
.ch-hero-sparkle-2 { bottom: 18%; left: 8%;  font-size: 16px; animation-delay: 1s; }
@keyframes ch-sparkle-twinkle {
  0%, 100% { opacity: 0.2; transform: scale(0.85); }
  50%      { opacity: 1;   transform: scale(1.1); }
}

@media (max-width: 900px) {
  .ch-hero-section { min-height: auto; padding: clamp(48px, 6vw, 72px) 0 clamp(56px, 7vw, 80px); }
  .ch-hero-grid { grid-template-columns: 1fr; gap: var(--spacing-lg); }
  .ch-hero-visual { min-height: 240px; order: -1; }
  .ch-hero-cards { transform: scale(0.8); }
}
@media (max-width: 600px) {
  .ch-hero-visual { display: none; }
  .ch-hero-metrics strong { font-size: 1.25rem; }
}

/* =============================================================================
   Homepage — Grid
   ============================================================================= */
.ch-home-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: var(--spacing-xl);
  padding: var(--spacing-2xl) 0;
}

.ch-home-section {
  margin-bottom: var(--spacing-2xl);
}

.ch-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-lg);
}

.ch-section-title {
  font-size: var(--font-size-xl);
  font-weight: 700;
}

.ch-section-link {
  font-size: var(--font-size-sm);
  color: var(--color-primary);
  font-weight: 500;
}

/* Homepage — Forum post list */
.ch-home-post-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.ch-home-post-card {
  display: flex;
  gap: var(--spacing-md);
  padding: var(--spacing-md) var(--spacing-lg);
  border-radius: var(--radius-md);
  transition: box-shadow var(--transition-fast);
}
.ch-home-post-card:hover {
  box-shadow: var(--shadow-md);
}

.ch-home-post-top {
  display: flex;
  gap: var(--spacing-sm);
  align-items: center;
  margin-bottom: 4px;
}

.ch-home-post-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  margin-bottom: 4px;
  line-height: 1.4;
}
.ch-home-post-title a {
  color: var(--color-text-primary);
  text-decoration: none;
}
.ch-home-post-title a:hover {
  color: var(--color-primary);
}

.ch-home-post-stats {
  display: flex;
  gap: var(--spacing-md);
}

/* Homepage — Blog grid */
.ch-home-blog-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--spacing-lg);
}

.ch-home-blog-card {
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}
.ch-home-blog-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.ch-home-blog-thumb {
  height: 140px;
  overflow: hidden;
}
.ch-home-blog-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ch-home-blog-info {
  padding: var(--spacing-md);
}

.ch-home-blog-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  margin: var(--spacing-xs) 0;
  line-height: 1.4;
}
.ch-home-blog-title a {
  color: var(--color-text-primary);
  text-decoration: none;
}
.ch-home-blog-title a:hover { color: var(--color-primary); }

.ch-home-blog-meta {
  display: flex;
  gap: var(--spacing-xs);
  margin-top: var(--spacing-xs);
}

/* Homepage — Sidebar widgets */
.ch-home-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
}

.ch-home-widget {
  padding: var(--spacing-lg);
  border-radius: var(--radius-md);
}

.ch-card-promo-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-sm);
}
.ch-card-promo-icon { font-size: 24px; }
.ch-card-promo-header h3 { font-size: var(--font-size-md); font-weight: 700; }

.ch-card-promo-actions {
  display: flex;
  gap: var(--spacing-sm);
  margin: var(--spacing-md) 0;
}

.ch-card-promo-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--spacing-sm);
  text-align: center;
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--color-border);
}

.ch-mini-stat { display: flex; flex-direction: column; gap: 2px; }
.ch-mini-stat-val { font-size: var(--font-size-lg); font-weight: 700; color: var(--color-primary); }
.ch-mini-stat-label { font-size: var(--font-size-xs); color: var(--color-text-muted); }

/* Hot topics list */
.ch-hot-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.ch-hot-item {
  display: flex;
  align-items: baseline;
  gap: var(--spacing-sm);
  padding: var(--spacing-xs) 0;
  border-bottom: 1px solid var(--color-border-light, #f0f0f0);
  font-size: var(--font-size-sm);
}
.ch-hot-item:last-child { border-bottom: none; }

.ch-hot-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: var(--color-text-muted);
  background: var(--color-bg);
  flex-shrink: 0;
}
.ch-hot-rank.is-top { background: var(--color-primary); color: #fff; }

.ch-hot-link {
  color: var(--color-text-primary);
  text-decoration: none;
  line-height: 1.4;
}
.ch-hot-link:hover { color: var(--color-primary); }

/* Quick links */
.ch-quick-links {
  list-style: none;
  padding: 0;
  margin: 0;
}
.ch-quick-links li { padding: var(--spacing-xs) 0; }
.ch-quick-links a {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  text-decoration: none;
}
.ch-quick-links a:hover { color: var(--color-primary); }

/* =============================================================================
   Notification bell & dropdown
   ============================================================================= */
.ch-notif-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.ch-notif-bell:hover,
.ch-notif-bell:focus-visible {
  background: var(--color-bg);
  outline: none;
}

.ch-notif-bell .ch-icon {
  width: 18px;
  height: 18px;
}

.ch-ticker-label .ch-icon,
.ch-announcement .ch-icon,
.ch-cat-icon .ch-icon,
.ch-tab .ch-icon,
.ch-stat .ch-icon,
.ch-blog-stat-row .ch-icon {
  width: 1em;
  height: 1em;
}

.ch-notif-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--color-danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  line-height: 1;
  pointer-events: none;
}

.ch-notif-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  width: 320px;
  max-height: 400px;
  overflow-y: auto;
  background: var(--color-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg, 0 8px 24px rgba(0,0,0,0.15));
  z-index: var(--z-dropdown, 1010);
  display: none;
  border: 1px solid var(--color-border);
}
.ch-notif-dropdown.is-open { display: block; }

.ch-notif-dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--color-border);
  font-size: var(--font-size-sm);
  font-weight: 600;
}

.ch-notif-item {
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--color-border-light, #f5f5f5);
  font-size: var(--font-size-sm);
  transition: background var(--transition-fast);
}
.ch-notif-item:last-child { border-bottom: none; }
.ch-notif-item:hover { background: var(--color-bg); }
.ch-notif-item.is-unread { background: #f0f7ff; }

.ch-notif-msg { line-height: 1.5; margin-bottom: 4px; }
.ch-notif-time { font-size: var(--font-size-xs); }
.ch-notif-empty { padding: var(--spacing-2xl); text-align: center; color: var(--color-text-muted); font-size: var(--font-size-sm); }

/* =============================================================================
   Header chat window
   ============================================================================= */
.ch-chat-wrap {
  position: relative;
  flex-shrink: 0;
}

.ch-chat-toggle {
  position: relative;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text-primary);
  cursor: pointer;
  line-height: 1;
  transition: background var(--transition-fast), color var(--transition-fast);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.ch-chat-toggle:hover,
.ch-chat-toggle:focus-visible,
.ch-chat-toggle[aria-expanded="true"] {
  background: var(--color-bg);
  color: var(--color-primary);
  outline: none;
}

.ch-chat-toggle .ch-icon {
  width: 18px;
  height: 18px;
}

.ch-chat-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--color-danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
}

.ch-nav-backpack .ch-icon,
.ch-notif-bell .ch-icon,
.ch-chat-toggle .ch-icon {
  pointer-events: none;
}

.ch-chat-window {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 1200;
  width: min(960px, calc(100vw - 48px));
  height: min(520px, calc(100vh - 96px));
  display: none;
  grid-template-columns: 280px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-card);
  box-shadow: 0 22px 55px rgba(15, 23, 42, 0.22);
}

.ch-chat-window.is-open {
  display: grid;
}

.ch-chat-sidebar {
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--color-border);
  background: var(--color-card);
}

.ch-chat-window-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-sm);
  height: 54px;
  flex: 0 0 54px;
  padding: 0 14px;
  border-bottom: 1px solid var(--color-border-light, #f4f4f5);
}

.ch-chat-window-header strong {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--color-text-primary);
  font-size: var(--font-size-lg);
  font-weight: 800;
}

.ch-chat-header-actions,
.ch-chat-pane-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ch-chat-pane-actions {
  position: absolute;
  top: 10px;
  right: 12px;
}

.ch-chat-icon-action {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  text-decoration: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.ch-chat-icon-action .ch-icon {
  pointer-events: none;
}

.ch-chat-icon-action:hover,
.ch-chat-icon-action:focus-visible {
  background: var(--color-bg);
  color: var(--color-text-primary);
  outline: none;
}

.ch-chat-icon-action .ch-icon {
  width: 17px;
  height: 17px;
}

.ch-chat-sidebar-body {
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
}

.ch-chat-threads-link {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid var(--color-border-light, #f4f4f5);
  color: var(--color-text-primary);
  font-weight: 700;
  text-decoration: none;
}

.ch-chat-threads-link:hover,
.ch-chat-threads-link:focus-visible {
  background: var(--color-bg);
  outline: none;
}

.ch-chat-threads-link span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ch-chat-threads-link .ch-icon {
  width: 18px;
  height: 18px;
}

.ch-chat-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-sm);
  padding: 13px 14px 8px;
  color: var(--color-text-secondary);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ch-chat-section-head.is-compact {
  border-top: 1px solid var(--color-border-light, #f4f4f5);
}

.ch-chat-section-head a {
  color: var(--color-primary);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-decoration: none;
  text-transform: none;
}

.ch-chat-thread-list {
  border-top: 0;
}

.ch-chat-thread {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border-light, #f4f4f5);
  transition: background var(--transition-fast);
}

.ch-chat-thread:hover {
  background: var(--color-bg);
}

.ch-chat-thread.is-unread {
  background: var(--color-primary-light);
}

.ch-chat-thread-avatar {
  display: inline-flex;
  width: 36px;
  height: 36px;
  text-decoration: none;
}

.ch-chat-thread-main {
  min-width: 0;
}

.ch-chat-thread-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.ch-chat-thread-top strong {
  overflow: hidden;
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ch-chat-thread-top time {
  flex: 0 0 auto;
  color: var(--color-text-muted);
  font-size: 10px;
}

.ch-chat-thread-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 5px;
}

.ch-chat-thread-meta span {
  padding: 2px 6px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
}

.ch-chat-thread-meta .is-inbox {
  color: var(--color-primary);
}

.ch-chat-thread-meta .is-sent {
  color: var(--color-success);
}

.ch-chat-thread p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.ch-chat-reply {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--color-primary);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
}

.ch-chat-reply .ch-icon {
  width: 13px;
  height: 13px;
}

.ch-chat-quick-list {
  display: grid;
  gap: 4px;
  padding: 0 10px 14px;
}

.ch-chat-direct-target {
  border-bottom: 1px solid var(--color-border-light, #f4f4f5);
}

.ch-chat-direct-target .ch-chat-section-head {
  border-top: 0;
}

.ch-chat-direct-person {
  margin: 0 10px 12px;
  width: calc(100% - 20px);
  background: var(--color-primary-light);
}

.ch-chat-direct-avatar {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--color-card);
  color: var(--color-primary);
}

.ch-chat-direct-avatar .ch-icon {
  width: 17px;
  height: 17px;
}

.ch-chat-quick-person {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 16px;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text-primary);
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.ch-chat-quick-person:hover,
.ch-chat-quick-person:focus-visible {
  background: var(--color-bg);
  outline: none;
}

.ch-chat-quick-person span {
  min-width: 0;
}

.ch-chat-quick-person strong,
.ch-chat-quick-person small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ch-chat-quick-person strong {
  font-size: var(--font-size-sm);
  line-height: 1.2;
}

.ch-chat-quick-person small {
  color: var(--color-text-muted);
  font-size: 11px;
}

.ch-chat-quick-person > .ch-icon {
  width: 16px;
  height: 16px;
  color: var(--color-text-muted);
}

.ch-chat-empty {
  padding: 18px 14px;
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  text-align: center;
}

.ch-chat-empty.is-small {
  padding-top: 2px;
}

.ch-chat-main-pane {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.86), rgba(255,255,255,0.98)),
    var(--color-card);
}

html[data-theme="dark"] .ch-chat-main-pane {
  background:
    linear-gradient(180deg, rgba(17, 24, 39, 0.86), rgba(17, 24, 39, 0.98)),
    var(--color-card);
}

.ch-chat-welcome {
  width: min(420px, 80%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--color-text-primary);
  text-align: center;
}

.ch-chat-welcome-art {
  width: 138px;
  height: 138px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 69, 0, 0.2), transparent 34%),
    radial-gradient(circle at 68% 24%, rgba(0, 121, 211, 0.2), transparent 34%),
    var(--color-bg);
  color: var(--color-primary);
}

.ch-chat-welcome-art .ch-icon {
  width: 58px;
  height: 58px;
}

.ch-chat-welcome h2 {
  margin: 2px 0 0;
  font-size: var(--font-size-lg);
  font-weight: 800;
  line-height: 1.25;
}

.ch-chat-welcome p {
  max-width: 360px;
  margin: 0 0 8px;
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  line-height: 1.55;
}

/* =============================================================================
   Responsive — Navigation
   ============================================================================= */
@media (max-width: 1024px) {
  .ch-nav-links { display: none; }
  .ch-hamburger { display: flex; }
}

@media (max-width: 1024px) {
  .ch-home-grid {
    grid-template-columns: 1fr;
  }
  .ch-home-sidebar {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-lg);
  }
}

@media (max-width: 768px) {
  .ch-search-form { width: 160px; }
  .ch-search-form:focus-within { width: 200px; }
  .ch-username { display: none; }

  .ch-home-blog-grid { grid-template-columns: 1fr; }
  .ch-home-sidebar { grid-template-columns: 1fr; }

  .ch-notif-dropdown { width: 280px; right: -40px; }
  .ch-chat-window {
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
    height: calc(100vh - 88px);
    grid-template-columns: minmax(220px, 40%) minmax(0, 1fr);
  }

  .ch-footer-widgets.ch-footer-grid-3,
  .ch-footer-widgets.ch-footer-grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
  .ch-footer-bottom {
    flex-direction: column;
    text-align: center;
  }
  .ch-leaderboard-header,
  .ch-leaderboard-row {
    grid-template-columns: 50px 1fr 80px;
  }
  .ch-leaderboard-header > *:last-child,
  .ch-leaderboard-row > *:last-child { display: none; }
}

@media (max-width: 480px) {
  .ch-search-form { display: none; }
  .ch-nav-inner { gap: var(--spacing-sm); justify-content: space-between; min-width: 0; }
  .ch-nav-logo { min-width: 0; }
  .ch-logo-text { max-width: 132px; overflow: hidden; font-size: var(--font-size-lg); gap: 6px; white-space: nowrap; }
  .ch-logo-mark { width: 28px; height: 28px; flex-basis: 28px; }
  .ch-nav-right { flex: 1 1 auto; justify-content: flex-end; gap: 8px; min-width: 0; }
  .ch-login-btn { display: none; }
  .ch-language-btn { min-width: 84px; height: 36px; padding-inline: 10px; }
  .ch-compose-btn { padding-inline: 8px; }
  #ch-notif-bell { display: none; }
  .ch-user-dropdown { padding: 2px; }
  .ch-hamburger { flex: 0 0 36px; }
  .ch-chat-window {
    grid-template-columns: 1fr;
  }
  .ch-chat-window-header {
    padding: 0 8px 0 14px;
  }
  .ch-chat-header-actions,
  .ch-chat-pane-actions {
    gap: 2px;
  }
  .ch-chat-icon-action {
    width: 44px;
    height: 44px;
    flex-basis: 44px;
  }
  .ch-chat-sidebar {
    border-right: 0;
  }
  .ch-chat-main-pane {
    display: none;
  }
  .ch-footer-widgets.ch-footer-grid-2,
  .ch-footer-widgets.ch-footer-grid-3,
  .ch-footer-widgets.ch-footer-grid-4 {
    grid-template-columns: 1fr;
  }
  .ch-single-title { font-size: var(--font-size-2xl); }
}

@media (max-width: 640px) {
  .ch-nav-inner {
    justify-content: space-between;
    gap: var(--spacing-sm);
    min-width: 0;
  }

  .ch-nav-logo {
    flex: 1 1 auto;
    min-width: 0;
  }

  .ch-logo-text {
    max-width: min(150px, 42vw);
    min-width: 0;
    gap: 6px;
    font-size: var(--font-size-lg);
    white-space: nowrap;
  }

  .ch-logo-mark {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
  }

  .ch-nav-right {
    flex: 0 0 auto;
    justify-content: flex-end;
    gap: 6px;
    min-width: 0;
  }

  .ch-nav-right > .ch-language-switcher,
  .ch-nav-right > .ch-compose-wrap,
  .ch-nav-right > .ch-nav-backpack {
    display: none;
  }

  .ch-chat-toggle,
  .ch-user-dropdown,
  .ch-hamburger {
    width: 36px;
    height: 36px;
  }

  .ch-chat-toggle .ch-icon {
    width: 20px;
    height: 20px;
  }

  .ch-user-dropdown {
    justify-content: center;
    padding: 0;
    gap: 0;
  }

  .ch-user-dropdown .ch-dropdown-arrow {
    display: none;
  }
}

@media (max-width: 360px) {
  .ch-logo-name {
    display: none;
  }

  .ch-nav-logo {
    flex: 0 0 auto;
  }
}
