/* Reference: fengchao.chat, measured 2026-10-27. Adapted to Rhex 1.1.0.
   The server-rendered addon style is the namespace for all overrides. */
html:has(style[data-dzpbw-community-theme]) {
  --dzpbw-panel-radius: 12px;
  --dzpbw-panel-shadow: 0 10px 30px -26px hsl(var(--foreground) / 0.22);
}

/* Use native theme tokens so personal palettes and dark mode still work. */
html:has(style[data-dzpbw-community-theme]) .forum-page-main > div.pb-12 > .overflow-hidden,
html:has(style[data-dzpbw-community-theme]) .forum-page-main > main > .space-y-3 > .overflow-hidden,
html:has(style[data-dzpbw-community-theme]) .forum-page-main .overflow-hidden.bg-background:has(h2) {
  background: hsl(var(--card));
  border-radius: var(--dzpbw-panel-radius);
  box-shadow: var(--dzpbw-panel-shadow);
  padding-bottom: 16px;
}

html:has(style[data-dzpbw-community-theme]) .forum-page-main > article > .space-y-0 > div > [data-slot="card"],
html:has(style[data-dzpbw-community-theme]) .forum-page-right-sidebar .mobile-sidebar-section {
  border-color: transparent;
  box-shadow: var(--dzpbw-panel-shadow);
}

html:has(style[data-dzpbw-community-theme]) [class~="group/avatar"] > div:first-child {
  border-radius: 50%;
}

html:has(style[data-dzpbw-community-theme]) .forum-page-main > main > .space-y-3 > .relative > .pointer-events-none {
  display: none;
}

html:has(style[data-dzpbw-community-theme]) .forum-page-main > main > .space-y-3 > .relative > .relative.grid .min-w-0 > .flex > p {
  font-size: 16px;
  line-height: 24px;
  letter-spacing: 0;
  font-weight: 600;
  color: hsl(var(--foreground));
}

/* List rows only: never match comment controls, user popovers or gallery tiles. */
html:has(style[data-dzpbw-community-theme]) .forum-page-main div:has(> [data-user-profile-preview-trigger]):has(> .min-w-0 h2) {
  align-items: center;
  padding: 12px 12px;
  gap: 12px;
  border-bottom-color: transparent;
  box-shadow: none;
}

html:has(style[data-dzpbw-community-theme]) .forum-page-main div:has(> [data-user-profile-preview-trigger]):has(> .min-w-0 h2) > .min-w-0 {
  position: relative;
}

html:has(style[data-dzpbw-community-theme]) .forum-page-main div:has(> [data-user-profile-preview-trigger]):has(> .min-w-0 h2):not(:last-child) > .min-w-0::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -12px;
  height: 1px;
  background: hsl(var(--border) / 0.5);
}

html:has(style[data-dzpbw-community-theme]) .forum-page-main div:has(> [data-user-profile-preview-trigger]):has(> .min-w-0 h2) h2 {
  font-size: 14.93px;
  line-height: 22.392px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

html:has(style[data-dzpbw-community-theme]) .forum-page-main div:has(> [data-user-profile-preview-trigger]):has(> .min-w-0 h2) > .min-w-0 > div:last-child {
  font-size: 11px;
  line-height: 18px;
  row-gap: 3px;
  min-height: 20.5px;
}

html:has(style[data-dzpbw-community-theme]) .forum-page-main div:has(> [data-user-profile-preview-trigger]):has(> .min-w-0 h2) a[href^="/boards/"] {
  border-radius: 999px;
  background: hsl(var(--accent) / 0.7);
  padding: 1px 6px;
  font-weight: 400;
}

html.dark:has(style[data-dzpbw-community-theme]) .forum-page-main div:has(> [data-user-profile-preview-trigger]):has(> .min-w-0 h2) a[title$=" 回复"] {
  background-color: hsl(var(--muted)) !important;
  color: hsl(var(--muted-foreground)) !important;
}

html:has(style[data-dzpbw-community-theme]) .forum-page-main > div.pb-12 > .overflow-hidden > div:first-child {
  border-bottom: 0;
}

/* Recompose the existing card without replacing its links, stats or check-in button. */
html:has(style[data-dzpbw-community-theme]) .sidebar-user-card-header {
  position: relative;
  padding: 16px 16px 12px;
  background: hsl(var(--card));
  text-align: center;
}

html:has(style[data-dzpbw-community-theme]) .sidebar-user-card-header > div {
  display: block;
}

html:has(style[data-dzpbw-community-theme]) .sidebar-user-card-header > div > div {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

html:has(style[data-dzpbw-community-theme]) .sidebar-user-card-header [class~="group/avatar"] {
  width: 80px;
  height: 80px;
}

html:has(style[data-dzpbw-community-theme]) .sidebar-user-card-header > div > div > .min-w-0 {
  width: 100%;
}

html:has(style[data-dzpbw-community-theme]) .sidebar-user-card-header .min-w-0 > div {
  justify-content: center;
}

html:has(style[data-dzpbw-community-theme]) .sidebar-user-card-header .min-w-0 > div:last-child > span {
  min-height: 28px;
  padding: 4px 10px;
  font-size: 12px;
}

html:has(style[data-dzpbw-community-theme]) .sidebar-user-card-header .min-w-0 > div > a {
  font-size: 18px;
  line-height: 26px;
  max-width: 100%;
}

html:has(style[data-dzpbw-community-theme]) .sidebar-user-card-header a[aria-label="前往设置"] {
  position: absolute;
  right: 8px;
  top: 8px;
  border: 0;
  background: transparent;
}

html:has(style[data-dzpbw-community-theme]) .sidebar-user-card-header + div {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 0;
  padding-bottom: 12px;
}

html:has(style[data-dzpbw-community-theme]) .sidebar-user-card-header + div > div {
  margin: 0;
}

html:has(style[data-dzpbw-community-theme]) .sidebar-user-card-header + div > div:has(> a[href="/settings?tab=points"]) {
  order: -1;
  padding: 14px 12px;
  border-radius: 12px;
  background: hsl(43 85% 96%);
  min-height: 80px;
  gap: 8px;
}

html.dark:has(style[data-dzpbw-community-theme]) .sidebar-user-card-header + div > div:has(> a[href="/settings?tab=points"]) {
  background: hsl(40 24% 16%);
}

html:has(style[data-dzpbw-community-theme]) .sidebar-user-card-header + div > div:has(> a[href="/settings?tab=points"]) a p:last-child {
  font-size: 24px;
  line-height: 28px;
}

html:has(style[data-dzpbw-community-theme]) .sidebar-user-card-header + div a[href="/settings?tab=points"] p:first-child {
  display: none;
}

html:has(style[data-dzpbw-community-theme]) .sidebar-user-card-header + div > div:has(> a[href="/settings?tab=points"]) > button {
  padding-inline: 8px;
  font-size: 11px;
  background: transparent;
}

html:has(style[data-dzpbw-community-theme]) .sidebar-user-card-header + div > .grid-cols-4 {
  gap: 0;
}

html:has(style[data-dzpbw-community-theme]) .sidebar-user-card-header + div > .grid-cols-4 > * {
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 6px 2px;
  min-height: 56px;
}

html:has(style[data-dzpbw-community-theme]) .sidebar-user-card-header + div > .grid-cols-4 > * + * {
  border-left: 1px solid hsl(var(--border));
}

html:has(style[data-dzpbw-community-theme]) .sidebar-user-card-header + div > .grid-cols-4 > * > div > span:first-child {
  display: none;
}

html:has(style[data-dzpbw-community-theme]) .sidebar-user-card-header + div > .grid-cols-4 p {
  margin-top: 8px;
  line-height: 16px;
  font-size: 11px;
}

html:has(style[data-dzpbw-community-theme]) .sidebar-user-card-header + div > .border-t {
  border-top: 0;
  padding-top: 0;
}

html:has(style[data-dzpbw-community-theme]) .sidebar-user-card-header + div a[href="/write"] > button {
  height: 40px;
  border-radius: 12px;
}

@media (min-width: 1024px) {
  html:has(style[data-dzpbw-community-theme]) .mx-auto:has(> [data-slot="sidebar-wrapper"] > .forum-page-shell),
  html:has(style[data-dzpbw-community-theme]) body:has(.forum-page-shell) header > .mx-auto {
    max-width: 1200px;
    width: 100%;
    padding-inline: 4px;
  }

  html:has(style[data-dzpbw-community-theme]) .forum-page-shell {
    column-gap: 8px;
    padding-top: 15px;
    align-items: start;
  }

  html:has(style[data-dzpbw-community-theme]) body:has(.forum-page-shell) header > .mx-auto > .grid > :first-child {
    grid-column: span 3;
  }

  html:has(style[data-dzpbw-community-theme]) body:has(.forum-page-shell) header > .mx-auto > .grid > :last-child {
    grid-column: span 9;
  }

  html:has(style[data-dzpbw-community-theme]) body:has(.forum-page-shell) header .hidden.flex-1 > .ml-4 {
    margin-left: 0;
  }

  html:has(style[data-dzpbw-community-theme]) .forum-page-right-sidebar {
    width: 100%;
    max-width: 100%;
    padding-left: 0;
  }

  html:has(style[data-dzpbw-community-theme]) .forum-page-sidebar {
    margin-left: 0;
  }

  html:has(style[data-dzpbw-community-theme]) .forum-page-shell:is([data-sidebar-display-mode="default"], [data-sidebar-display-mode="tree"]) .forum-page-sidebar {
    width: 100%;
    min-width: 0;
  }

  html:has(style[data-dzpbw-community-theme]) .forum-page-sidebar-inner {
    background: hsl(var(--card));
    border-radius: var(--dzpbw-panel-radius);
    box-shadow: var(--dzpbw-panel-shadow);
    padding: 8px;
    top: 76px;
    height: auto;
    max-height: none;
    position: relative;
    top: auto;
    overflow: visible;
    margin-top: 4px;
  }

  html:has(style[data-dzpbw-community-theme]) .forum-page-sidebar-scroll-area,
  html:has(style[data-dzpbw-community-theme]) .forum-page-sidebar-scroll-area > [data-slot="scroll-area-viewport"] {
    height: auto;
    overflow: visible !important;
  }

  html:has(style[data-dzpbw-community-theme]) .forum-page-main > :is(main,article),
  html:has(style[data-dzpbw-community-theme]) .forum-page-right-sidebar > :first-child {
    margin-top: 4px;
  }

  html:has(style[data-dzpbw-community-theme]) .forum-page-main > main > .space-y-3 > .overflow-hidden {
    padding: 8px 8px 16px;
  }

  html:has(style[data-dzpbw-community-theme]) .forum-page-main > article .markdown-body {
    line-height: 1.85;
  }
}

@media (min-width: 1536px) {
  html:has(style[data-dzpbw-community-theme]) .mx-auto:has(> [data-slot="sidebar-wrapper"] > .forum-page-shell),
  html:has(style[data-dzpbw-community-theme]) body:has(.forum-page-shell) header > .mx-auto {
    max-width: 1440px;
    padding-inline: 16px;
  }

  html[data-sidebar-collapsed="false"]:has(style[data-dzpbw-community-theme]) .forum-page-shell:is([data-sidebar-display-mode="default"], [data-sidebar-display-mode="tree"]):not([data-has-right-sidebar="false"]) {
    grid-template-columns: 216px minmax(0, 1fr) 304px;
  }

  html[data-sidebar-collapsed="true"]:has(style[data-dzpbw-community-theme]) .forum-page-shell:is([data-sidebar-display-mode="default"], [data-sidebar-display-mode="tree"]):not([data-has-right-sidebar="false"]) {
    grid-template-columns: 60px minmax(0, 1fr) 304px;
  }
}

@media (max-width: 1023px) {
  /* Settings uses 4px page gutters, while its native sticky bar assumes 16px. */
  html:has(style[data-dzpbw-community-theme]) main > .flex.flex-col.gap-6 > [class~="lg:hidden"] > .flex.flex-col.gap-4 > .sticky[class~="-mx-4"] {
    margin-inline: -4px;
  }

  /* Two text lines plus vertical padding cannot fit a narrow 16:3 placeholder. */
  html:has(style[data-dzpbw-community-theme]) a[href^="/funs/self-serve-ads/purchase?"][class~="aspect-[16/3]"] {
    aspect-ratio: auto;
    min-width: 0;
    min-height: 84px;
  }

  html:has(style[data-dzpbw-community-theme]) .forum-page-shell {
    padding-top: 4px;
  }

  html:has(style[data-dzpbw-community-theme]) .forum-page-main > div.pb-12 > .overflow-hidden {
    border-radius: 10px;
  }

  html:has(style[data-dzpbw-community-theme]) .forum-page-main > main > .space-y-3 > .overflow-hidden {
    padding-top: 8px;
  }

  html:has(style[data-dzpbw-community-theme]) .forum-page-main > main > .space-y-3 > .relative {
    display: flex;
    flex-direction: column;
    padding-bottom: 0;
  }

  html:has(style[data-dzpbw-community-theme]) .forum-page-main > main > .space-y-3 > .relative > .absolute {
    position: static;
    order: 1;
    width: auto;
    flex-direction: row;
    gap: 8px;
    padding: 0 16px 12px;
  }

  html:has(style[data-dzpbw-community-theme]) .forum-page-main > main > .space-y-3 > .relative > .relative.grid {
    padding: 12px 16px;
  }

  html:has(style[data-dzpbw-community-theme]) .forum-page-main div:has(> [data-user-profile-preview-trigger]):has(> .min-w-0 h2) {
    padding: 13px 8px;
    gap: 10px;
  }

  html:has(style[data-dzpbw-community-theme]) .forum-page-main div:has(> [data-user-profile-preview-trigger]):has(> .min-w-0 h2) > .min-w-0 {
    overflow-wrap: anywhere;
  }

  html:has(style[data-dzpbw-community-theme]) .forum-page-main div:has(> [data-user-profile-preview-trigger]):has(> .min-w-0 h2) > .min-w-0 > div:last-child {
    margin-top: 7px;
  }
}
