/* =========================================================
   Shu Zhang — Portfolio
   Editorial / typographic system
   Two families: Fraunces (display) + Inter (UI/body)
   Restrained palette: warm paper, ink, one accent
   ========================================================= */

:root {
  /* palette — light (default) */
  --paper:      #F5F2EC;
  --paper-2:    #EFEBE2;
  --ink:        #18181B;
  --ink-soft:   #3A3A3F;
  --muted:      #75726B;
  --line:       #E0DACE;
  --line-soft:  #EAE5DA;
  --accent:     #C23A22;
  --accent-ink: #A22F1B;

  /* type */
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans:  "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  /* rhythm */
  --wrap:    1120px;
  --measure: 68ch;
  --gap:     clamp(1.5rem, 4vw, 3rem);

  /* motion */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* System dark mode preference (unless light mode is explicitly set) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:      #151417;
    --paper-2:    #1C1B1F;
    --ink:        #ECE9E2;
    --ink-soft:   #C9C5BC;
    --muted:      #8E8A81;
    --line:       #2C2A30;
    --line-soft:  #232228;
    --accent:     #E75C40;
    --accent-ink: #F07A61;
  }
}

/* Explicit dark mode override */
:root[data-theme="dark"] {
  --paper:      #151417;
  --paper-2:    #1C1B1F;
  --ink:        #ECE9E2;
  --ink-soft:   #C9C5BC;
  --muted:      #8E8A81;
  --line:       #2C2A30;
  --line-soft:  #232228;
  --accent:     #E75C40;
  --accent-ink: #F07A61;
}

/* Explicit light mode override (forces light even if system prefers dark) */
:root[data-theme="light"] {
  --paper:      #F5F2EC;
  --paper-2:    #EFEBE2;
  --ink:        #18181B;
  --ink-soft:   #3A3A3F;
  --muted:      #75726B;
  --line:       #E0DACE;
  --line-soft:  #EAE5DA;
  --accent:     #C23A22;
  --accent-ink: #A22F1B;
}

:lang(zh) {
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
}

body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.6;
  font-size: 1.0625rem;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-optical-sizing: auto;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }

::selection { background: var(--accent); color: var(--paper); }

/* ---------- layout ---------- */
.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: clamp(1.25rem, 5vw, 3.5rem);
}
.measure { max-width: var(--measure); }

/* ---------- shared type ---------- */
.eyebrow {
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.accent { color: var(--accent); }

/* ---------- header ---------- */
.site-head {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem clamp(1.25rem, 5vw, 3.5rem);
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s var(--ease);
}
.site-head.is-stuck { border-bottom-color: var(--line); }
.header-right {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 3vw, 1.5rem);
}
.brand {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}
.site-nav {
  display: flex;
  gap: clamp(1rem, 3vw, 2.25rem);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.site-nav a {
  color: var(--muted);
  position: relative;
  padding-bottom: 2px;
  transition: color 0.2s var(--ease);
}
.site-nav a::after {
  content: "";
  position: absolute;
  left: 0; right: 100%;
  bottom: 0;
  height: 1px;
  background: var(--accent);
  transition: right 0.3s var(--ease);
}
.site-nav a:hover { color: var(--ink); }
.site-nav a:hover::after { right: 0; }

.lang-toggle {
  border: 1px solid var(--line);
  border-radius: 100px;
  padding: 0.25rem 0.7rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--muted);
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease), background 0.2s var(--ease);
}
.lang-toggle:hover {
  color: var(--ink);
  border-color: var(--accent);
  background: var(--line-soft);
}

.theme-toggle {
  background: none;
  border: none;
  padding: 0.4rem;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.2s var(--ease), background 0.2s var(--ease);
}
.theme-toggle:hover {
  color: var(--ink);
  background: var(--line-soft);
}
.theme-toggle svg {
  display: block;
  transition: transform 0.3s var(--ease);
}
.theme-toggle:hover svg {
  transform: rotate(15deg);
}
.sun-icon { display: none; }
.moon-icon { display: block; }

html[data-theme="light"] .sun-icon { display: block; }
html[data-theme="light"] .moon-icon { display: none; }
html[data-theme="dark"] .sun-icon { display: none; }
html[data-theme="dark"] .moon-icon { display: block; }

/* ---------- hero ---------- */
.hero {
  padding-top: clamp(4rem, 12vh, 9rem);
  padding-bottom: clamp(3rem, 9vh, 7rem);
}
.hero .kicker {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: clamp(1.75rem, 5vh, 3rem);
}
.hero .kicker::after {
  content: "";
  height: 1px;
  flex: 1;
  max-width: 120px;
  background: var(--line);
}
.display {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.6rem, 7.2vw, 6rem);
  line-height: 1.02;
  letter-spacing: -0.025em;
  max-width: 16ch;
}
.display em {
  font-style: italic;
  font-weight: 400;
}
.hero .lede {
  margin-top: clamp(1.75rem, 5vh, 2.75rem);
  font-size: clamp(1.05rem, 1.6vw, 1.3rem);
  line-height: 1.55;
  color: var(--ink-soft);
  max-width: 52ch;
}

/* hero lower: lede + stats on the left, portrait on the right */
.hero-lower {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(2rem, 5vw, 4rem);
  align-items: end;
  margin-top: clamp(1.75rem, 5vh, 2.75rem);
}
@media (min-width: 820px) {
  .hero-lower { grid-template-columns: 1.35fr 0.65fr; }
}
.hero-lower .lede { margin-top: 0; }

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(1.5rem, 4vw, 3rem);
  margin-top: clamp(1.75rem, 4vh, 2.5rem);
  padding-top: clamp(1.5rem, 3vh, 2rem);
  border-top: 1px solid var(--line);
}
.hstat-num {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.7rem, 3.2vw, 2.5rem);
  letter-spacing: -0.02em;
  color: var(--accent);
  line-height: 1;
  font-feature-settings: "tnum";
}
.hstat-label {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.55rem;
  max-width: 17ch;
  line-height: 1.35;
}

.hero-portrait {
  aspect-ratio: 4 / 5;
  border-radius: 6px;
  overflow: hidden;
  background: var(--paper-2);
  border: 1px solid var(--line);
  position: relative;
}
.hero-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 28%;
  /* editorial B&W lock: slight contrast lift, subtle warm tone to match paper */
  filter: grayscale(100%) contrast(1.06);
  transition: filter 0.6s var(--ease), transform 0.6s var(--ease);
}
.hero-portrait:hover img {
  filter: grayscale(0%) contrast(1.02);
  transform: scale(1.02);
}

/* ---------- section frame ---------- */
.section { padding-block: clamp(3.5rem, 9vh, 7rem); }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1.5rem;
  margin-bottom: clamp(1.5rem, 4vh, 3rem);
  border-bottom: 1px solid var(--line);
}
.section-head h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  letter-spacing: -0.02em;
}

/* ---------- work list ---------- */
.work-list { display: flex; flex-direction: column; }
.work-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: clamp(1rem, 4vw, 3rem);
  align-items: center;
  padding: clamp(1.75rem, 4vh, 2.75rem) 0;
  border-top: 1px solid var(--line);
  transition: padding-left 0.4s var(--ease);
}
.work-item:first-child { border-top: none; }
.work-item:last-child { border-bottom: 1px solid var(--line); }
.work-num {
  font-family: var(--serif);
  font-size: clamp(1rem, 1.4vw, 1.15rem);
  color: var(--accent);
  font-feature-settings: "tnum";
  padding-top: 0.35em;
  align-self: start;
}
.work-body h3 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.6rem, 3.6vw, 2.6rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
  transition: color 0.25s var(--ease);
}
.work-body .work-sub {
  margin-top: 0.6rem;
  color: var(--muted);
  font-size: 1rem;
  max-width: 54ch;
}
.work-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.5rem;
  margin-top: 1rem;
}
.tag {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 100px;
  padding: 0.3em 0.75em;
}
.work-go {
  font-family: var(--serif);
  font-size: 1.5rem;
  color: var(--muted);
  transform: translateX(0);
  transition: transform 0.35s var(--ease), color 0.25s var(--ease);
  align-self: center;
}
.work-item:hover { padding-left: clamp(0.5rem, 2vw, 1.5rem); }
.work-item:hover .work-body h3 { color: var(--accent); }
.work-item:hover .work-go { color: var(--accent); transform: translateX(6px); }

/* ---------- about ---------- */
.about-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(1.5rem, 4vw, 3.5rem);
}
.about-lede {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.5rem, 3vw, 2.15rem);
  line-height: 1.28;
  letter-spacing: -0.015em;
  max-width: 22ch;
}
.about-body p + p { margin-top: 1.15rem; }
.about-body p { color: var(--ink-soft); max-width: var(--measure); }
@media (min-width: 800px) {
  .about-grid { grid-template-columns: 0.9fr 1.1fr; }
}

/* ---------- footer ---------- */
.site-foot {
  border-top: 1px solid var(--line);
  padding-block: clamp(2.5rem, 6vh, 4rem);
  margin-top: clamp(3rem, 8vh, 6rem);
}
.foot-cta {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.8rem, 5vw, 3.2rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 2rem;
}
.foot-cta a { border-bottom: 2px solid var(--accent); transition: color 0.2s var(--ease); }
.foot-cta a:hover { color: var(--accent); }
.foot-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 2rem;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.85rem;
}
.foot-links { display: flex; gap: 1.5rem; }
.foot-links a { transition: color 0.2s var(--ease); }
.foot-links a:hover { color: var(--ink); }
.foot-note {
  font-size: 0.8rem;
  color: var(--muted);
  max-width: 60ch;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line-soft);
}

/* =========================================================
   CASE STUDY PAGES
   ========================================================= */
.case-hero { padding-top: clamp(2.5rem, 7vh, 5rem); padding-bottom: clamp(2rem, 5vh, 3.5rem); }
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: clamp(2rem, 6vh, 3.5rem);
  transition: gap 0.3s var(--ease), color 0.2s var(--ease);
}
.back-link:hover { color: var(--ink); gap: 0.75rem; }
.case-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.2rem, 6vw, 4.4rem);
  line-height: 1.03;
  letter-spacing: -0.025em;
  text-wrap: balance;
  max-width: 18ch;
  margin-top: 1.25rem;
}
.case-sub {
  margin-top: clamp(1.25rem, 3vh, 2rem);
  font-size: clamp(1.1rem, 1.9vw, 1.4rem);
  line-height: 1.5;
  color: var(--ink-soft);
  max-width: 46ch;
}
.case-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1.5rem;
  margin-top: clamp(2.5rem, 6vh, 4rem);
  padding-top: 1.75rem;
  border-top: 1px solid var(--line);
}
.case-meta dt {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
.case-meta dd { font-size: 0.95rem; color: var(--ink-soft); line-height: 1.4; }

/* prose */
.prose { max-width: var(--measure); margin-inline: auto; }
.prose > * + * { margin-top: 1.3rem; }
.prose h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.6rem, 3.2vw, 2.3rem);
  line-height: 1.12;
  letter-spacing: -0.02em;
  margin-top: clamp(3rem, 7vh, 5rem);
}
.prose h2 + p { margin-top: 1rem; }
.prose h3 {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  margin-top: 2rem;
}
.prose p { color: var(--ink-soft); }
.prose strong { color: var(--ink); font-weight: 600; }
.prose a { border-bottom: 1px solid var(--accent); color: var(--ink); }
.prose ul { padding-left: 0; list-style: none; }
.prose li {
  position: relative;
  padding-left: 1.5rem;
  color: var(--ink-soft);
}
.prose li + li { margin-top: 0.65rem; }
.prose li::before {
  content: "";
  position: absolute;
  left: 0; top: 0.65em;
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
}
.prose .lead {
  font-family: var(--serif);
  font-size: clamp(1.3rem, 2.4vw, 1.7rem);
  line-height: 1.4;
  color: var(--ink);
  letter-spacing: -0.01em;
}

/* pull quote */
.prose blockquote {
  border-left: 2px solid var(--accent);
  padding-left: clamp(1.25rem, 3vw, 2rem);
  margin-block: clamp(2rem, 5vh, 3rem);
}
.prose blockquote p {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.25rem, 2.6vw, 1.75rem);
  line-height: 1.35;
  color: var(--ink);
}
.prose blockquote cite {
  display: block;
  margin-top: 0.85rem;
  font-family: var(--sans);
  font-style: normal;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* stats row */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  margin-block: clamp(2rem, 5vh, 3rem);
}
.stat { background: var(--paper); padding: clamp(1.25rem, 3vw, 1.75rem); }
.stat-num {
  display: block;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.9rem, 4vw, 2.8rem);
  letter-spacing: -0.02em;
  color: var(--accent);
  line-height: 1;
}
.stat-label {
  display: block;
  margin-top: 0.6rem;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.35;
}

/* callout — the highlighted insight/failure story */
.callout {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: clamp(1.5rem, 4vw, 2.5rem);
  margin-block: clamp(2rem, 5vh, 3rem);
}
.callout .eyebrow { color: var(--accent); }
.callout p {
  margin-top: 0.85rem;
  font-family: var(--serif);
  font-size: clamp(1.15rem, 2.2vw, 1.5rem);
  line-height: 1.4;
  color: var(--ink);
}

/* figure placeholder */
.figure { margin-block: clamp(2.5rem, 6vh, 4rem); }
.figure.-wide {
  /* break out of the narrow prose column to full page width */
  width: min(var(--wrap), 92vw);
  margin-left: 50%;
  transform: translateX(-50%);
  max-width: none;
}
.figure-frame {
  aspect-ratio: 16 / 9;
  border: 1.5px dashed var(--line);
  border-radius: 6px;
  background:
    repeating-linear-gradient(-45deg,
      transparent, transparent 11px,
      var(--line-soft) 11px, var(--line-soft) 12px);
  display: grid;
  place-content: center;
  text-align: center;
  padding: 2rem;
  gap: 0.5rem;
}
.figure-frame .fig-kind {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}
.figure-frame .fig-desc {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1rem, 2vw, 1.25rem);
  color: var(--muted);
  max-width: 30ch;
}
.figure img {
  border-radius: 6px;
}
.figure figcaption {
  margin-top: 0.9rem;
  font-size: 0.82rem;
  color: var(--muted);
  max-width: 60ch;
}
/* wide figures span the page, so center their caption under the artwork */
.figure.-wide figcaption {
  margin-inline: auto;
  text-align: center;
}

/* next case */
.next-case {
  border-top: 1px solid var(--line);
  margin-top: clamp(3.5rem, 9vh, 6rem);
  padding-top: clamp(2rem, 5vh, 3rem);
}
.next-case a { display: block; transition: padding-left 0.4s var(--ease); }
.next-case a:hover { padding-left: 0.75rem; }
.next-case .eyebrow { margin-bottom: 0.75rem; }
.next-case h3 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.8rem, 4.5vw, 3rem);
  letter-spacing: -0.02em;
  line-height: 1.05;
  transition: color 0.25s var(--ease);
}
.next-case a:hover h3 { color: var(--accent); }

/* reveal on scroll */
.reveal { opacity: 0; transform: translateY(18px); }
.reveal.in { opacity: 1; transform: none; transition: opacity 0.7s var(--ease), transform 0.7s var(--ease); }

/* responsive work item */
@media (max-width: 640px) {
  .site-head { align-items: center; }
  .brand { white-space: nowrap; }
  .site-nav { display: none; }
  .header-right { gap: 0.65rem; }
  .work-item { grid-template-columns: auto 1fr; }
  .work-go { display: none; }
  .work-num { grid-row: 1; }
}

/* =========================================================
   MOTION SYSTEM
   Restrained, editorial. Entrance choreography + refined
   scroll reveals + micro-interactions. Fully gated behind
   .js-anim (JS-added) and prefers-reduced-motion.
   ========================================================= */

/* Entrance primitives — hidden until JS plays them */
.js-anim .anim { opacity: 0; will-change: opacity, transform; transition-delay: var(--d, 0s); }
.js-anim .anim-rise    { transform: translateY(22px); }
.js-anim .anim-focus   { transform: translateY(18px); filter: blur(9px); }
.js-anim .anim-portrait{ transform: translateY(26px) scale(1.015); }

.js-anim .anim.played {
  opacity: 1; transform: none; filter: none;
  transition:
    opacity 0.9s var(--ease),
    transform 1.05s var(--ease),
    filter 0.9s var(--ease);
  transition-delay: var(--d, 0s);
}

/* Refined scroll reveals (upgrades the base .reveal) */
.js-anim .reveal { opacity: 0; transform: translateY(22px); filter: blur(4px); }
.js-anim .reveal.in {
  opacity: 1; transform: none; filter: none;
  transition: opacity 0.8s var(--ease), transform 0.9s var(--ease), filter 0.8s var(--ease);
}

/* Portrait idle — near-imperceptible float, only after entrance */
@keyframes floatIdle {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-7px); }
}
.hero-portrait.portrait-live img { animation: floatIdle 7s ease-in-out infinite; }
.hero-portrait.portrait-live:hover img { animation-play-state: paused; }

/* Micro-interactions */
.work-item .work-num { transition: transform 0.4s var(--ease), color 0.25s var(--ease); }
.work-item:hover .work-num { transform: translateY(-2px); }
.site-nav a { transition: color 0.2s var(--ease), transform 0.2s var(--ease); }
.site-nav a:hover { transform: translateY(-1px); }
.hstat-num { transition: transform 0.35s var(--ease); }
.hero-stats > div:hover .hstat-num { transform: translateY(-2px); }

/* Whole-page load fade (prevents flash, feels smooth) */
.js-anim body { opacity: 0; }
.js-anim body.page-in { opacity: 1; transition: opacity 0.5s var(--ease); }

/* Accessibility — reduced motion disables everything above */
@media (prefers-reduced-motion: reduce) {
  .js-anim .anim,
  .js-anim .reveal { opacity: 1 !important; transform: none !important; filter: none !important; }
  .hero-portrait.portrait-live img { animation: none !important; }
  .js-anim body { opacity: 1 !important; }
}

/* =========================================================
   DIAGRAM — DTS: one ad's asset pool → model assembles →
   contextual assemblies. Self-contained, token-driven,
   light/dark aware. 16:9 container.
   ========================================================= */
.diagram {
  width: 100%;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(1.25rem, 3.5vw, 2.75rem);
  container-type: inline-size;
}
.dg-grid {
  display: grid;
  grid-template-columns: 1fr auto 1.15fr;
  gap: clamp(0.75rem, 3vw, 2.5rem);
  align-items: center; /* center the middle column */
}
/* Force left and right columns to align to top */
.dg-grid > div:first-child,
.dg-grid > div:last-child {
  align-self: start;
}
.dg-col-label {
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1rem;
  text-align: center;
  line-height: 1.1rem; /* fixed height for alignment */
}

/* ---- asset pool (left) ---- */
.dg-pool-wrap {
  position: relative;
}
.dg-pool {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper-2);
  padding: clamp(0.75rem, 2cqw, 1.1rem);
  min-height: 300px; /* ensure consistent height */
}
.dg-asset {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: clamp(0.72rem, 1.7cqw, 0.9rem);
  color: var(--ink-soft);
  padding: 0.4rem 0.15rem;
  border-bottom: 1px solid var(--line-soft);
}
.dg-asset:last-child { border-bottom: 0; }
.dg-asset.-core {
  color: var(--ink);
  font-weight: 500;
}
.dg-asset.-fade {
  opacity: 0.35;
}
.dg-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  flex: none;
}
.dg-asset .dg-tag {
  margin-left: auto;
  font-size: 0.62rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
/* Fade-out overlay to suggest continuation */
.dg-pool-fade {
  position: absolute;
  bottom: 1px;
  left: 1px;
  right: 1px;
  height: 70px;
  pointer-events: none;
  background: linear-gradient(to bottom, transparent 0%, var(--paper-2) 85%);
  border-radius: 0 0 7px 7px;
}
.dg-pool-note {
  margin-top: 1rem;
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  color: var(--muted);
  text-align: center;
  line-height: 1.3;
  opacity: 0.7;
  min-height: 2.5rem; /* ensure alignment with right side */
}

/* ---- selection node (middle) ---- */
.dg-mid {
  text-align: center;
  min-width: 96px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.dg-node {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(0.85rem, 2cqw, 1.05rem);
  color: var(--paper);
  background: var(--accent);
  border-radius: 100px;
  padding: 0.55em 1.1em;
  display: inline-block;
  line-height: 1.15;
  box-shadow: 0 8px 22px -12px var(--accent);
}
.dg-signals {
  margin-top: 0.9rem;
  font-size: 0.63rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.5;
}
.dg-signals b { color: var(--ink-soft); font-weight: 600; display:block; margin-bottom:0.25rem; font-size:0.6rem; }
.dg-arrow {
  color: var(--muted);
  font-size: 1.1rem;
  margin: 0.5rem 0;
  line-height: 1;
}

/* ---- assemblies (right) ---- */
.dg-outs-wrap {
  position: relative;
}
.dg-outs { display: flex; flex-direction: column; gap: clamp(0.6rem, 1.8cqw, 1rem); }
.dg-out {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  padding: clamp(0.6rem, 1.8cqw, 0.9rem);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.75rem;
  align-items: center;
}
.dg-wire { display: grid; gap: 3px; width: clamp(46px, 12cqw, 66px); }
.dg-wire .w-img {
  background: color-mix(in srgb, var(--accent) 16%, var(--paper-2));
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line));
  border-radius: 3px;
}
.dg-wire .w-bar { height: 5px; background: var(--line); border-radius: 2px; }
.dg-wire .w-bar.-accent { background: color-mix(in srgb, var(--accent) 55%, transparent); }
.dg-wire .w-imgrow { display: flex; gap: 3px; }
.dg-wire .w-imgrow .w-img { flex: 1; height: 22px; }
.dg-out-meta .dg-out-name {
  font-weight: 600;
  font-size: clamp(0.75rem, 1.8cqw, 0.92rem);
  color: var(--ink);
}
.dg-out-meta .dg-out-uses {
  font-size: clamp(0.64rem, 1.5cqw, 0.76rem);
  color: var(--muted);
  margin-top: 0.2rem;
  line-height: 1.35;
}
.dg-out-meta .dg-out-uses .u-on { color: var(--accent); font-weight: 600; }

/* connectors row hint */
.dg-flow-note {
  margin-top: 1.4rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line-soft);
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.4;
}
.dg-flow-note b { color: var(--ink-soft); font-weight: 600; }

/* Fade-out overlay for right column */
.dg-outs-fade {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 70px;
  pointer-events: none;
  background: linear-gradient(to bottom, transparent 0%, var(--paper) 85%);
}

/* stack on narrow */
@container (max-width: 560px) {
  .dg-grid { grid-template-columns: 1fr; gap: 1.25rem; }
  .dg-mid { display: flex; flex-direction: column; align-items: center; }
}

/* ---- DTS diagram: fan-out (ghosted branches + more) ---- */
.dg-col-sub {
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--muted);
  opacity: 0.8;
}
.dg-out.-ghost { opacity: 0.42; border-style: dashed; }
.dg-out.-ghost-2 { opacity: 0.24; }
.dg-more {
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  color: var(--muted);
  text-align: center;
  padding: 1rem 0 0 0;
  opacity: 0.7;
  min-height: 2.5rem; /* match left side */
}
